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

6 views (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 22 Jan 2016
  2 Comments
Steven Hughes
Steven Hughes on 22 Jan 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.

Sign in to comment.

More Answers (3)

Yuqing Chen
Yuqing Chen on 5 May 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 on 22 Jan 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 Comment
Walter Roberson
Walter Roberson on 30 Mar 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.

Sign in to comment.


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

Community Treasure Hunt

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

Start Hunting!