Solver stopped prematurely, how to increase the function evaluation limit default
Mostrar comentarios más antiguos
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 comentario
abdul ali
el 6 de Sept. de 2018
I'm also facing the same problem. anybody, please help
Respuestas (3)
Star Strider
el 26 de Feb. de 2015
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 comentarios
desmond paramore
el 26 de Feb. de 2015
Star Strider
el 26 de Feb. de 2015
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
el 7 de Sept. de 2018
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
el 26 de Feb. de 2015
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
el 11 de Jul. de 2023
Editada: Walter Roberson
el 11 de Jul. de 2023
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 comentario
Walter Roberson
el 11 de Jul. de 2023
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)
Categorías
Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!