Input user data into Surrogate Optimization Function

2 次查看(过去 30 天)
I need to be able to pass some data of my own, that is inputted by a user, into the surrograteopt function in order to have it work properly. Here is the code I have: (most of it, I removed a lot of the code within the function because it is not useful in this scenario. The function works perfectly, until I added these inputs)
clear;
clc;
addpath ../
nvar = 2;
upperBounds = [10,10];
lowerBounds = [1,1];
intcon = 1:nvar;
inputs = inputCaller();
[unitCostLaborFile, unitCostLaborPath] = uigetfile('*.xlsx','Select file with Welding Unit Costs for labor');
[unitCostFile, unitCostPath] = uigetfile('*.xlsx','Select file with Welding Unit Costs for equipment');
[weldSpeedsFile, weldSpeedsPath] = uigetfile('*.xlsx','Select file with Welding Speeds from WPS');
% Set nondefault solver options
options = optimoptions('surrogateopt','MaxFunctionEvaluations',10,'PlotFcn',...
[]);
% Solve
[solution,objectiveValue] = surrogateopt(@objConstrFcn,lowerBounds,...
upperBounds,intcon,[],[],[],[],options);
% Clear variables
clearvars options
% disp(solution);
% disp(objectiveValue);
fill = solution(1);
cap = solution(2);
cost = objectiveValue;
print(fill,cap,cost);
function f = objConstrFcn(optimInput, inputs, unitCostLaborFile, unitCostFile, weldSpeedsFile)
startDateInput = inputs(1);
endDateInput = inputs(2);
pipeSize = inputs(3);
pipeThickness = inputs(4);
welds = inputs(5);
workHours = inputs(6);
travelTime = inputs(7);
weight = inputs(8);
overhang = inputs(9);
qaqc = inputs(10);
useTackRig = inputs(11);
Does anyone know how I would make this possible? This is pretty integral to my program, as without these user inputs I won't get the proper utilization of this program.

采纳的回答

Alan Weiss
Alan Weiss 2021-6-2
To pass extra parameters see Passing Extra Parameters.
Alan Weiss
MATLAB mathematical toolbox documentation

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by