Change MaxFunctionEvaluations in optimization problem
27 ビュー (過去 30 日間)
古いコメントを表示
Andrea Mazzetto
2021 年 6 月 23 日
コメント済み: Walter Roberson
2021 年 6 月 23 日
Hi, everyone.
I'm doing an optimization problem, all works until I change the constraints when i make them more restrictive, cause the solver stopped prematurely. I tried to increase the function evaluation limit by using
options = optimoptions(@fmincon,'Algorithm','interior-point','MaxFunctionEvaluations',10000)
But nothing changed. How can I change the limit?
The script is as follows:
aymax = 5;
V = 70;
limro = aymax / (V/3.6)^2;
....
type objfun
rof1 = optimvar('rof1');
rof2 = optimvar('rof2');
....
sf4 = optimvar('sf4');
obj = fcn2optimexpr(@objfun,rof1,rof2,rof3,rof4,sf1,sf2,sf3,sf4);
prob = optimproblem('Objective',obj);
constr1 = rof1 >= 0;
prob.Constraints.curvatura1 = constr1;
constr2 = rof1 <= (-aymax / (V/3.6)^2)*0.8;
prob.Constraints.curvatura2 = constr2;
constr3 = rof2 >= -0.0005;
prob.Constraints.curvatura3 = constr3;
....
....
constr17 = sf4 >= intorno;
prob.Constraints.ascissa9 = constr17;
x0.rof1 = 0.1;
x0.rof2 = 0.2;
....
....
x0.sf4 = 30;
options = optimoptions(@fmincon,'Algorithm','interior-point','MaxFunEvals',10000);
[sol,fval,exitflag,output] = solve(prob,x0);
1 件のコメント
Steven Lord
2021 年 6 月 23 日
Walter has showed you how to use the options. What you had written didn't work because the optimoptions function does not "change some global options" (though I've seen a number of users expect it to behave that way over the years) but instead creates the options that you would then need to pass into the solver (either by calling fmincon in the solver-based approach or calling solve in the problem-based approach.)
採用された回答
Walter Roberson
2021 年 6 月 23 日
options = optimoptions(prob,'Algorithm','interior-point','MaxFunEvals',10000);
[sol,fval,exitflag,output] = solve(prob, x0, 'Options', options);
1 件のコメント
Walter Roberson
2021 年 6 月 23 日
Notice that the problem was passed into optimoptions, rather than @fmincon
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Text Data Preparation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!