Solver stopped prematurely, how to increase the function evaluation limit default
이전 댓글 표시
I am trying to solve a non-linear system of equations with 4 equations and 4 unknowns. However, I can't get a solution and I keep getting a message saying the solver stopped prematurely and "fsolve stopped because it exceeded the function evaluation limit, options.MaxFunEvals = 400 (the default value)."
Here is my code and the things I've tried:
function solveeqs()
guess=[3 3 3 3];
options=optimset('MaxFunEvals',100000);
options=optimset(options,'MaxIter',100000);
options=optimset('disp','iter','LargeScale','off','TolFun',.001);
[result,fval,exit,output]=fsolve(@eqns,guess,options);
result
fval
eqns(guess)
output
end
function [ fcns ] = eqns( z)
L=z(1);
O=z(2);
S=z(3);
H=z(4);
fcns(1)=L-O*(exp((8.17*S)/.25)-1)-((8.17*S)/H)-8.17;
fcns(2)=L-O*(exp(36.8/.25)-1)-(36.8/H);
fcns(3)=L-O*(exp((29.5+7.63*S)/.25)-1)-((29.5+7.63*S)/H)-7.63;
fcns(4)=7.63-29.5*(((-O/.25)*(exp((29.5+7.63*S)/.25))-(1/H))/(1+(O*S/.25)*exp((29.5+7.63*S)/.25)+(S/H)));
end
Any help on how to get this working would be greatly appreciated! Thank you
댓글 수: 1
abdul ali
2018년 9월 6일
I'm also facing the same problem. anybody, please help
답변 (3개)
Star Strider
2015년 2월 26일
You may be overwriting your options structure.
See if this improves things:
options=optimset('disp','iter','LargeScale','off','TolFun',.001,'MaxIter',100000,'MaxFunEvals',100000);
Use only one options declaration. Delete the others.
댓글 수: 3
desmond paramore
2015년 2월 26일
Star Strider
2015년 2월 26일
That occurs when the solver encounters a local minimum. The error (difference from zero) is greater than the solver believes is appropriate. The solution is to begin with different ‘guess’ values until you discover a set that leads to the solver finding a global minimum and a zero solution.
Walter Roberson
2018년 9월 7일
My tests suggest that there is no real-valued solution for this set of equations. You can reasonably solve the first three equations for z1, z2, z4, but the remaining equation does not cross zero at any real value.
Matt J
2015년 2월 26일
You must modify the 3rd optimset call so as not to overwrite your previous settings.
options=optimset(options, 'disp','iter','LargeScale','off','TolFun',.001);
kumar shantanu
2023년 7월 11일
편집: Walter Roberson
2023년 7월 11일
function s = powersch(pa)
c=[ 2.1 2.5 2.4 2.2 1.9 2.1 1.7 1.8 2 2.5 2.55 2.6 2.6 2.6 2.8 2.9 2.9 2.5 2.4 2.9 3.5 3.3 2.6 2.5] ;
a=(pa.*c);
x=sum(a);
s=sum(x)
end
this is my objective while excuting Solver stopped prematurely.
fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 3.000000e+03.
this error in coming
댓글 수: 1
Walter Roberson
2023년 7월 11일
In a way similar to the discussion above, you need to pass fmincon options that increase MaxFunctionEvaluation and probably MaxIterations as well. Try using
options = optimoptions('fmincon');
options.MaxFunctionEvaluation = 1e4;
options.MaxIterations = 1e4;
and then pass options to fmincon in the appropriate slot. (Note: when you pass options to fmincon, you must pass all previous parameters as well:
fmincon(OBJECTIVE_FUNCTION, X0, A, b, Aeq, beq, NONLCON_FUNCTION, options)
카테고리
도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!