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

60 ビュー (過去 30 日間)
Pavol Namer
Pavol Namer 2014 年 8 月 7 日
コメント済み: mura0087 2021 年 1 月 20 日
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.
mura0087
mura0087 2021 年 1 月 20 日
awesome, thank you!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by