MATLAB Answers

How to Setup Surrogate Optimization with Data input

2 views (last 30 days)
Clayton Leung
Clayton Leung on 12 Jul 2021
Commented: Clayton Leung on 16 Jul 2021
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 Comments
Clayton Leung
Clayton Leung on 13 Jul 2021
Thanks for replying, to answer your question, here are the variable declaration. I know the @fun arguement is incorrect, but I dont know how to write it properly.
I am using the version R2021a.
NumerOfVariable = 3;
lb = [60,10,1];
ub = [900,240,4];
intCon = 1:900;
fun = @CC_Pairs_Surrogate;
options = optimoptions('surrogateopt','Display','iter','PlotFcn',...
{'surrogateoptplot','optimplotfvalconstr','optimplotfval',...
'optimplotconstrviolation','optimplotx'});
[solution,objectiveValue,exitflag,output,trials] = surrogateopt(fun,lb,ub,intCon,[],[],[],[],options);
Error Message:
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);
Thanks in advance.

Sign in to comment.

Answers (1)

Alan Weiss
Alan Weiss on 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 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by