Fmincon tries the same values for manipulated variables for three iterations
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Hello, I have a simulink model that I control and minimize one of its outputs with fmincon. My problem is that fmincon tries two values for the two manipulated variables for three iterations before changing to another guess. The optimization in other words is three times slower. I've tried to change the Algorithm with no result. How can I fix this?
Here is my code:
options=optimset('Algorithm','sqp','TolX',0.01,'TolFun',0.001);
x=fmincon(@obj,xo,A,B,[],[],xmin,xmax,[],options);
function q = obj(z)
cr=z(1);
tr=z(2);
sopt = simset('solver','ode3','SrcWorkspace','base','DstWorkspace','base','SaveFormat','Array');
[~,~,yo]= sim('sgs2.slx',[0 1], sopt);
q=abs(yo(end,1)-yo(end,2));
end
Antworten (2)
John D'Errico
am 18 Jan. 2015
Bearbeitet: John D'Errico
am 18 Jan. 2015
0 Stimmen
Are they really IDENTICAL? Somehow I doubt it. Look more carefully. Perhaps you need to write out the parameters with more precision.
Fmincon must compute a gradient. So this means it must make a tiny adjustment to each parameter, to then compute an approximate derivative. Once it gets an estimate of the local gradient, it can then take an actual step. At some point, it will then decide it need to know the gradient again. So it does so.
You cannot magically make it run more quickly. Knowledge of the gradient allows it to make an INTELLIGENT choice for the next place to look. For example, you might use fminsearch instead, a solver that does not need to compute a gradient. But that lack of information costs you greatly, so it will converge more slowly and less reliably.
Stefanos Kalandaridis
am 19 Jan. 2015
0 Stimmen
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!