Maximum number of function evaluations has been exceeded - increase MaxFunEvals option.

210 views (last 30 days)
Dear Matlab users: I've got a following problem: I try to find parameters of this function:
by simplex method (see the following code)
format compact
format long
xdata = [0.000,0.200,0.400,0.600,0.800,1.000,1.200,1.400,1.600,1.800,2.000,2.200,2.400,2.600,2.800,3.000,3.200,3.400,3.600,3.800,4.000,4.200,4.400,4.600,4.800,5.000];
ydata = [0.007,0.041,0.165,0.449,0.816,0.982,0.741,0.212,-0.362,-0.808,-0.975,-0.774,-0.290,0.290,0.775,0.982,0.849,0.527,0.237,0.077,0.018,0.003,0.000,0.000,0.000,0.000];
%Function to calculate the sum of residuals for our a given parameters
fun= @(p) sum(ydata - (-1*(p(1)-p(2)*(((xdata)-p(3))).^4).*(exp(-1*p(4)*((xdata)-p(3)).^2))).^2);
%starting guess for our parameters
%starting guess
pguess = [1.0,12.0,1.0,2.0];
%optimise
[p,fminres] = fminsearch(fun,pguess)
Unfortunately it doesn't work very well because this type of message appears:
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -Inf
I know that parameters, should be cca a= 1.0; b=12; c=2.4 and r=1.02 (in code, abcr parameters are p(1)...(p4)).
I need to use simplex method for iteration, so I try to fix this problem, but I am totaly newbie in matlab and don't know how to fix it.
Does anybody have any suggestion??
Thanks
Paul

Answers (2)

Matt J
Matt J on 7 Aug 2014
Using the optimset command you can change MaxFunEvals and other algorithm parameters of fminsearch. You can also use optimoptions if you have the Optimization Toolbox.
  2 Comments
Pavol Namer
Pavol Namer on 7 Aug 2014
Edited: Matt J on 7 Aug 2014
Thank you for your answer,
So you mean:
[p,fminres] = fminsearch(fun,pguess,optimset'MaxFunEvals',1000)
And for
optimoptions,
which method for simplex algoritm do I need to use? Thank you
Alan Weiss
Alan Weiss on 7 Aug 2014
You cannot use optimoptions for fminsearch, you have to use optimset. For example,
options = optimset('MaxFunEvals',1000);
[p,fminres] = fminsearch(fun,pguess,options)
For more information, consult the documentation on setting options.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.


mura0087
mura0087 on 20 Jan 2021
I have this same problem! Even if I change MaxFunEvals to a very high number (1e30) I still get an Inf value out of fminsearch.
  4 Comments

Sign in to comment.

Categories

Find more on Optimization in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!