How to Setup Surrogate Optimization with Data input
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a function "SurrogateFunction" I would like to use Surrogate to optimse. However, i dont know how to setup the options.
Data1 and Data2 are double vectors (500x2 and 500x2 in size). They do not need to be optimize and are the data for testing.
Variable1, 2 are integer
Variable3 is a double
I would like to optimise variable 1, 2 and 3.
Variables have lower bound level of [60, 10 and 0.5] respectively
Variables have upper bound level of [900, 240 and 3.5] respectively
Using the optimse solver, i got the following code
% Set nondefault solver options
options = optimoptions('surrogateopt','Display','iter','PlotFcn',[]);
% Solve
[solution,objectiveValue] = surrogateopt(fun,lb,ub,intCon,[],[],[],[],options);
% Clear variables
clearvars options
function Value = SurrogateFunction(Data1, Data2, Variable1, Variable2, Variable3)
%some code
end
This is the error i am getting:
INTCON must be in the range [1 3].
Error in globaloptim.bmo.createSolver
self = globaloptim.bmo.createSolver(self,expensive,lb,ub, ...
controller = globaloptim.bmo.BlackboxModelOptimizer(expensive,lb,ub,intcon, ...
controller = createController(expensivefcn,lb,ub,intcon,Aineq,bineq,Aeq,beq,options);
How do I config the optimization so it runs?
2 Kommentare
Alan Weiss
am 13 Jul. 2021
Please report the version of MATLAB you use.
Please report the values of fun, lb, ub, and intCon for your problem. (I suspect that your fun argument might be incorrect, meaning does not satisfy the requirements of an objective function.)
Please do not clear the options variable after creating it.
Alan Weiss
MATLAB mathematical toolbox documentation
Antworten (1)
Alan Weiss
am 14 Jul. 2021
The error is clear: you have just three variables, so the indices of the integer variables have to be in the range 1 through 3. I don't know what you are trying to do by specifying intCon = 1:900; but that specification makes no sense for the syntax.
In addition, I suspect that your definition of your objective function is incorrect. If you want help debugging your objective function, please provide the first line of the definition of CC_Pairs_Surrogate, which will be something like
function y = CC_Pairs_Surrogate(X,L,R)
Alan Weiss
MATLAB mathematical toolbox documentation
3 Kommentare
Alan Weiss
am 15 Jul. 2021
You have three variables. If all three should be integers, then set intCon = 1:3. If just variables 1 and 2 should be integer, set intCon = [1 2]. If you want the variables bounded as you say, set
lb = [60, 10, 0.5];
ub = [900, 240, 3.5];
As for your objective function, you need to write it this way:
function Value = SurrogateFunction(Data1, Data2, Variables)
Variable1 = Variables(1);
Variable2 = Variables(2);
Variable3 = Variables(3);
% Now the rest of your code
end
And when you specify fun in your surrogateopt call, do it like this. Firt get the Data1 and Data2 arrays into your workspace. Then execute
fun = @(Variables)SurrogateFunction(Data1, Data2, Variables);
Alan Weiss
MATLAB mathematical toolbox documentation
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!