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

조회 수: 165 (최근 30일)
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

답변 (2개)

Matt J
Matt J 2014년 8월 7일
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
Pavol Namer
Pavol Namer 2014년 8월 7일
편집: Matt J 2014년 8월 7일
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 2014년 8월 7일
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

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


mura0087
mura0087 2021년 1월 20일
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
Walter Roberson
Walter Roberson 2021년 1월 20일
In the File Exchange, John D'Errico has a bounded version of fminsearch.

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

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by