Command window not dynamically displaying data in R2015b, waits till end of run to display everything

2 visualizaciones (últimos 30 días)
I use a mex file interface to the optimizer SNOPT. That optimizer writes optimization iteration to the command window if requested.
In R2015a, the iteration information is displayed in the command window after each iteration so it is possible to watch optimization progress. In R2015b (change nothing related to my code or SNOPT), the data sent to the command window is all displayed after the call to SNOPT is complete (i.e. after optimization is done), making it impossible to watch optimization progress and intervene when something is going wrong.
For plotting, the "draw now" command avoids this issue. Is there a similar command or workaround to force update of data sent to the command window for display?

Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de En. de 2016
  2 comentarios
Steven Hughes
Steven Hughes el 22 de En. de 2016
Thanks, I discovered this workaround a few days ago but forgot to post it here. Using a pause command (with a really short time interval) forces a refresh. In noticed that cntrl-C to break out doesn't work the same as in previous versions when running with mex files but cntrl-C works around that issue as well.
Walter Roberson
Walter Roberson el 23 de En. de 2016
"cntrl-C does not work the same but cntrl-C works around that issue as well"?? I am confused.

Iniciar sesión para comentar.

Más respuestas (3)

Yuqing Chen
Yuqing Chen el 5 de Mayo de 2017
I had the same problem but solved with an easier way. SNOPT now has a function 'snscreen' to control the command window output, so to enable the output, simply add
snscreen on
before you execute snopt function.
Moreover, you could add
snprint('on')
to get a file including all information of snopt.

Pavel Dey
Pavel Dey el 22 de En. de 2016
I am not sure how you constructed your code. However, you may follow the steps below or check if you have followed this while implementing
1) Set the 'Output Function' up. You specify the output function in options, such as
>> options = optimoptions(@fmincon,'OutputFcn',@outfun);
2) Write your own 'outfun' function. For an example on how to do this, please refer to the following link: http://www.mathworks.com/help/optim/ug/output-functions.html
3) Use the 'disp' command to display the objective function's value which is stored in 'optimValues.fval'. Alternatively, you can access this data directly in 'history.fval'.
OR you may also set the display option from 'optimoptions' function in the following way.
options = optimoptions(@fminunc,'Display','iter','Algorithm','quasi-newton');
Please note the above one is simply an example of optimization. You have to select 'Display' as 'iter' or 'iter-detailed'. Follow the doc link below for details
Hope that helps.
  1 comentario
Walter Roberson
Walter Roberson el 30 de Mzo. de 2016
The poster mentioned SNOPT, which is possibly http://tomopt.com/tomlab/products/snopt/ and is third party in any case. It would not use optimoptions and might not use an OutputFcn at all.
The difficulty has to do with ways that mex code can flush the output buffer to the command line.

Iniciar sesión para comentar.


Jan
Jan el 30 de Mzo. de 2016
A workaround is calling an M-helper function: http://www.mathworks.com/matlabcentral/answers/255615#answer_215636

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by