How to manually change MaxFunctionEvaluations in fmincon
27 views (last 30 days)
Show older comments
I would like to manually change the number of evaluations from 3000 to something bigger. Is it possible that with more evaluations I could increase the chance of finding global minimum of given function fun? How can I change this in script?
Thank you for your help:)
0 Comments
Accepted Answer
Alan Weiss
on 26 Oct 2016
I think that the short answer to your question is to set the MaxFunctionEvaluations option to a higher-than-default value. See Set and Change Options. You might also want to increase the MaxIterations option.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 Comments
More Answers (2)
John D'Errico
on 25 Oct 2016
No. Increasing the maximum number of function evaluations is NOT how you will ensure finding the global minimum. In fact, if the optimization has terminated happily in the first instance, then changing that limit will not do a thing.
Fmincon is not a global optimizer anyway. It will find a solution that is as best as it can, but different start points can yield different solutions. An increase in the function evals allowed will not change a thing.
You may want to try a global optimizer. There is a toolbox for that. Or you may want to try a stochastic optimizer such as a genetic algorithm. Again, a toolbox for that. Or simulated annealing, or particle swarm tools, etc. Or just better starting values.
Walter Roberson
on 25 Oct 2016
Changing the maximum function evaluations can help find the local minima, in some cases where the function is complicated enough mathematically that a lot of evaluations are needed to predict the right directions to search, or if you want the position of the minima to high tolerance.
There are functions where relative movements on the order of 1E-10 or less make a big difference in the minima, when the local minima sits in a very narrow slot within a larger valley, so sometimes increasing the function evaluations can greatly affect the outcome.
Every once in a while the local minima turns out to be the global minima, but if you are searching in the wrong local minima, no matter how many function evaluations you permit, you are not going to find the global minima with fmincon. fmincon is mostly unable to escape from sufficiently deep local minima.
3 Comments
Fares Bettahar
on 11 Jan 2023
Edited: Walter Roberson
on 12 Jan 2023
hello sir ,can you help me please
I have this problem in Matlab
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 5.000000e+02.
X =
18.7410 6.6035 138.6942 16.4586 9.6161
FVAL =
16.1142 6.6468 5.1229 22.6175 -21.6852
also When used
f
un = @tp1000;
X0 = [11 5 135 13 10];
% MaxFunEvals=1000;0
% options = optimoptions('levenberg-marquardt');
% oldoptions = optimoptions(@lsqnonlin,'Algorithm','levenberg-marquardt',...
% 'MaxFunctionEvaluations',1000)
options = struct('MaxFunctionEvaluations',1000)
[X,FVAL]= fsolve(fun,X0)
i dont know how do "MaxFunctionEvaluations" =1000
Alan Weiss
on 11 Jan 2023
I suggest that you ask your question in a new question, not attached to one already answered.
Alan Weiss
MATLAB mathematical toolbox documentation
See Also
Categories
Find more on Surrogate Optimization 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!