Input user data into Surrogate Optimization Function
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jadon Latta
le 31 Mai 2021
Réponse apportée : Alan Weiss
le 2 Juin 2021
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.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Direct Search dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!