Change MaxFunctionEvaluations in optimization problem
33 views (last 30 days)
Show older comments
Andrea Mazzetto
on 23 Jun 2021
Commented: Walter Roberson
on 23 Jun 2021
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 Comment
Steven Lord
on 23 Jun 2021
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.)
Accepted Answer
Walter Roberson
on 23 Jun 2021
options = optimoptions(prob,'Algorithm','interior-point','MaxFunEvals',10000);
[sol,fval,exitflag,output] = solve(prob, x0, 'Options', options);
1 Comment
Walter Roberson
on 23 Jun 2021
Notice that the problem was passed into optimoptions, rather than @fmincon
More Answers (0)
See Also
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!