Change MaxFunctionEvaluations in optimization problem

58 次查看(过去 30 天)
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
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
Walter Roberson 2021-6-23
options = optimoptions(prob,'Algorithm','interior-point','MaxFunEvals',10000);
[sol,fval,exitflag,output] = solve(prob, x0, 'Options', options);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by