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

답변 (3개)

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

I replaced the options declarations with what you suggested and I get "No solution found."
"fsolve stopped because the relative size of the current step is less than the default value of the step size tolerance squared, but the vector of function values is not near zero as measured by the selected value of the function tolerance."
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.
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.

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

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
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

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에 대해 자세히 알아보기

질문:

2015년 2월 26일

댓글:

2023년 7월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by