How to Setup Surrogate Optimization with Data input

4 ビュー (過去 30 日間)
Clayton Leung
Clayton Leung 2021 年 7 月 12 日
コメント済み: Clayton Leung 2021 年 7 月 16 日
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 件のコメント
Alan Weiss
Alan Weiss 2021 年 7 月 13 日
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
Clayton Leung
Clayton Leung 2021 年 7 月 13 日
編集済み: Clayton Leung 2021 年 7 月 13 日
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.

サインインしてコメントする。

回答 (1 件)

Alan Weiss
Alan Weiss 2021 年 7 月 14 日
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 件のコメント
Alan Weiss
Alan Weiss 2021 年 7 月 15 日
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
Clayton Leung
Clayton Leung 2021 年 7 月 16 日
Thank you, I will try it as you said.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurrogate Optimization についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by