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

조회 수: 6 (최근 30일)
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?

채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 22일
  댓글 수: 2
Steven Hughes
Steven Hughes 2016년 1월 22일
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 2016년 1월 23일
"cntrl-C does not work the same but cntrl-C works around that issue as well"?? I am confused.

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Yuqing Chen
Yuqing Chen 2017년 5월 5일
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 2016년 1월 22일
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
Walter Roberson
Walter Roberson 2016년 3월 30일
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.

댓글을 달려면 로그인하십시오.


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

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by