MaxFunctionEvaluations not working in optimset() for fsolve()

조회 수: 6 (최근 30일)
Turing Machine
Turing Machine 2021년 7월 8일
편집: Torsten 2024년 4월 12일
I want to solve a 3x3 system numerically. Nevertheless at given initial guess values it prompts
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 3.000000e+02.
To assess whether it's unable to solve the system for lack of enough function evaluations or iterations, I tried to set:
options.MaxIterations = 1000;
options.MaxFunctionEvaluations = 4000;
Nonetheless, no matter what value I put, I always get
options.MaxFunctionEvaluations = 3.000000e+02.
I'd appreciate if you may help me in how to increase the number of function evaluations and maximum iterations.
PD: My code looks like this:
function F = three_by_three_system(x, params)
%some ;
end
x0 = [1 1 1];
options = optimset('Display', 'on', 'TolX', 1e-10, 'TolFun', 1e-10);
options.MaxIterations = 1000;
options.MaxFunctionEvaluations = 4000;
x1 = fsolve(@(x) three_by_three_system(x, params), x0,options);
and no matter what I put in lines 7 and 8, always get:
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 3.000000e+02.
Thanks!!
EDIT: Seems like MaxFunctionEvaluations is not an option for optimset(), but for optimoptions(), which only works for optimization but not for solving equations to zero. Besides, it's not completely clear what to do in order to increase the function evaluations for my optimization, what should I do?
  댓글 수: 2
Ram Iyer
Ram Iyer 2024년 4월 12일
편집: Torsten 2024년 4월 12일
I have tried both optimset and optimoptions with no effect. Below is the code with optimset
options = optimset('fsolve');
options.Algorithm = 'levenberg-marquardt';
options.MaxIterations = 1000; % Solver shows this value to be 400 no matter what.
options.MaxIter = 1000; % This field is shown in the structure for 'fsolve' with value 400.
options
options = struct with fields:
Display: 'final' MaxFunEvals: [] MaxIter: 1000 TolFun: 1.0000e-06 TolX: 1.0000e-06 FunValCheck: 'off' OutputFcn: [] PlotFcns: [] ActiveConstrTol: [] Algorithm: 'levenberg-marquardt' AlwaysHonorConstraints: [] DerivativeCheck: 'off' Diagnostics: 'off' DiffMaxChange: Inf DiffMinChange: 0 FinDiffRelStep: [] FinDiffType: 'forward' GoalsExactAchieve: [] GradConstr: [] GradObj: [] HessFcn: [] Hessian: [] HessMult: [] HessPattern: [] HessUpdate: [] InitBarrierParam: [] InitTrustRegionRadius: [] Jacobian: 'off' JacobMult: [] JacobPattern: 'sparse(ones(jrows,jcols))' LargeScale: [] MaxNodes: [] MaxPCGIter: 'max(1,floor(numberofvariables/2))' MaxProjCGIter: [] MaxSQPIter: [] MaxTime: [] MeritFunction: [] MinAbsMax: [] NoStopIfFlatInfeas: [] ObjectiveLimit: [] PhaseOneTotalScaling: [] Preconditioner: [] PrecondBandWidth: Inf RelLineSrchBnd: [] RelLineSrchBndDuration: [] ScaleProblem: 'none' SubproblemAlgorithm: [] TolCon: [] TolConSQP: [] TolGradCon: [] TolPCG: 0.1000 TolProjCG: [] TolProjCGAbs: [] TypicalX: 'ones(numberofvariables,1)' UseParallel: 0 MaxIterations: 1000
Solver stopped prematurely.
fsolve stopped because it exceeded the iteration limit,
options.MaxIterations = 4.000000e+02.
Torsten
Torsten 2024년 4월 12일
편집: Torsten 2024년 4월 12일
MaxIter is set to 1000 in the options structure (see above).
Did you include "options" in the call to "fsolve" :
x = fsolve(fun,x0,options)
?
Please show us the relevant part of your code so that we can reproduce the error message.

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

채택된 답변

Stephan
Stephan 2021년 7월 8일
See the documentation:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by