custom stopping criteria when using fmincon
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Does anybody know a way to define "custom stopping criteria" when using fmincon? What I want to do is to stop fmincon when the "optimal" or the funciton value becomes NaN. For example:
Iter F-count f(x)
0 4 0.239457
1 8 0.192672
2 12 0.0374073
3 16 0.0374069
4 20 0.0355964
5 24 0.0349293
6 28 0.0347082
7 32 0.0347077
8 37 0.034304
9 41 0.0341285
10 45 0.0339353
11 49 NaN
12 53 NaN
...
I am interested in a way to stop fmicon at the 10-th iteration.
Many thanks
0 Commenti
Risposte (1)
Sarah Wait Zaranek
il 1 Apr 2011
You can set the stop flag as part of the output function. It is described in the documentation here:
Edited to add an example:
I am stopping using x values but you can get function values from the optimValues structure.
function testerMain
x0 = [10;10;10]; % Starting guess at the solution
A = [-1 -2 -2; ... 1 2 2];
b = [0;72];
options=optimset('Algorithm','interior-point','Display','iter','OutputFcn',@outfun);
[x,fval] = fmincon(@myTestfun,x0,A,b,[],[],[],[],[],options);
disp(x)
end
function f = myTestfun(x)
f = -x(1) * x(2) * x(3);
end
function stop = outfun(x,optimValues,state)
stop = false;
if x(1) > 11
stop = true;
disp('Stopping, x > 11')
end
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Nonlinear Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!