MATLAB Answers

How to display fmincon output outside the command windows ? (Deported output)

7 views (last 30 days)
Hi,
I use Matlab fmincon opitmizer through matlab engine in an application developed in Qt.
I would like to know if there is a way to have the fmincon realtime output displayed outside the Matlab command Window ? Ideally deported in a Qt interface or at least on a maltab window that can be open by the run manager.
For all other displays it works already well but the fmincon output (and I assume that it is the same thing with other algorithm) is only displayed at the end of the whole optimization. In that way, user has no feedbak of the optimization process until its finished. It is disturbing when a processus can takes several hours !
Thanks a lot for your help !

  0 Comments

Sign in to comment.

Accepted Answer

Matt J
Matt J on 8 Jul 2020
Edited: Matt J on 8 Jul 2020
The way to gain access to status information during the execution of fmincon is by using the OutputFcn option,
From within the Ouput Function, you can plot anything you want, anywhere you want, and use the status to trigger your own stopping criteria if you wish.

  7 Comments

Show 4 older comments
Jérôme Vinçonneau
Jérôme Vinçonneau on 9 Jul 2020
yes but trying with the same synthax as the matlab example do not work too :
function stop = outfun(x,optimValues,state)
stop = false;
switch state
case 'init'
hold on
case 'iter'
% Concatenate current point and objective function
% value with history. x must be a row vector.
history.fval = [history.fval; optimValues.fval];
history.x = [history.x; x];
% Concatenate current search direction with
% searchdir.
searchdir = [searchdir;...
optimValues.searchdirection'];
plot(x(1),x(2),'o');
% Label points with iteration number.
% Add .15 to x(1) to separate label from plotted 'o'
text(x(1)+.15,x(2),num2str(optimValues.iteration));
case 'done'
hold off
otherwise
end
end
Jérôme Vinçonneau
Jérôme Vinçonneau on 9 Jul 2020
finally it was a mistake in the wording and even if x is not used it is mandatory !!
Thanks a lot for your help

Sign in to comment.

More Answers (0)