How to manually change MaxFunctionEvaluations in fmincon

27 visualizaciones (últimos 30 días)
sycXZOR
sycXZOR el 24 de Oct. de 2016
Editada: Walter Roberson el 12 de En. de 2023
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:)

Respuesta aceptada

Alan Weiss
Alan Weiss el 26 de Oct. de 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

Más respuestas (2)

John D'Errico
John D'Errico el 25 de Oct. de 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.
  1 comentario
sycXZOR
sycXZOR el 26 de Oct. de 2016
I am not so sure in your answer. For instance if I put in random x0 vector as starting point for fmincon, I get, afet 3000 evaluations the vector x that I was searching and fval, which is current value of function:
[x,fval] = fmincon(fun,x0,...);
However, if I use the calculated x vector as new starting point:
x0 = x;
and repeat the algorithm for new starting point I get improved new fval and therefore improved new vector x and improved local minimum of the function. If I loop this until the absolute value of difference between new and old fval is let's say bigger than 0.0001 I get into ACTUAL local minimum. Not global minimum probably, but waaay improved local minimum. So yes, the number of evaluations should play some kind of a role or is my theory wrong?

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 25 de Oct. de 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 comentarios
Fares Bettahar
Fares Bettahar el 11 de En. de 2023
Editada: Walter Roberson el 12 de En. de 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
Alan Weiss el 11 de En. de 2023
I suggest that you ask your question in a new question, not attached to one already answered.
But if you want to see how to create and use options, see Set Options.
Alan Weiss
MATLAB mathematical toolbox documentation

Iniciar sesión para comentar.

Categorías

Más información sobre Surrogate Optimization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by