フィルターのクリア

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

4 ビュー (過去 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 Center および File ExchangeSolver 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