Change MaxFunctionEvaluations in optimization problem

조회 수: 38 (최근 30일)
Andrea Mazzetto
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
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);
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 6월 23일
Notice that the problem was passed into optimoptions, rather than @fmincon

댓글을 달려면 로그인하십시오.

추가 답변 (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