fmincon does not respect MaxIter
이전 댓글 표시
Hello,
I do not understand why fmincon does not respect the maximum number of iteration I specify and does whatever it
l;ikes to do. My cod is very long to show you but I show the main part which I believe is enough:
Max_iter=solver{2};
par0=lb+(ub-lb).*rand(1,dim);
options=optimoptions('fmincon','MaxFunEvals',realmax,'MaxIterations',Max_iter,'OutputFcn',@(x,A,state)myoutput_fmincon_Spline(x,A,state));
problem = createOptimProblem('fmincon','objective',cost,'x0',par0,'lb',lb,'ub',ub,'options',options);
ms=MultiStart('UseParallel',UseParallel);
myCluster=parcluster('local');NumWorkers=myCluster.NumWorkers;
[EstimatedNoise_par, f_best]=run(ms,problem,NumWorkers);
I try Max_tier = 1 and I expect the code to stop fast but fminbcon ignore it.
Any idea?
Thanks in advance,
Babak
댓글 수: 8
Walter Roberson
2023년 11월 18일
Note that the initial iteration requires evaluating the objective function (dim+1) times.
Mohammad Shojaei Arani
2023년 11월 18일
Walter Roberson
2023년 11월 18일
My dim is 8. So, it means that even if I set MaxIter=1 fmincon still considers 9 iterations.
Not exactly. For iteration 0, fmincon would evaluate the function 8+1 = 9 times, in order to establish initial values to estimate the jacobian.
The iteration counts you are observing, are for each time fmincon() starts. You are using MultiStart, which runs several independent fmincon() from different starting points.
Mohammad Shojaei Arani
2023년 11월 18일
이동: Torsten
2023년 11월 18일
Mohammad Shojaei Arani
2023년 11월 18일
이동: Torsten
2023년 11월 18일
Mohammad Shojaei Arani
2023년 11월 18일
Walter Roberson
2023년 11월 18일
outputfcn returns a value. That value can directly signal stop (that is, it is a fundamental part of the design, easily done, not something obscure)
So your outputfcn could evaluate the solution at hand and somehow decide that it is good enough.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!