www.gusucode.com > sloptim工具箱matlab源码程序 > sloptim/sloptim/@sroengine/@fminsearch/showIter.m
function showIter(this,type,hText,varargin) % Iteration display. % Copyright 1986-2012 The MathWorks, Inc. persistent Algorithm DisplayLevel = this.Options.Display; switch type case 'init' Algorithm = varargin{1}; if strcmp(DisplayLevel,'iter') if isempty(hText) %Command line display switch Algorithm case 1 % fminbnd header = getString(message('Sloptim:engine:msgHeader_fminbnd')); case 2 % fminsearch header = getString(message('Sloptim:engine:msgHeader_fminbnd')); end else %GUI display header = sprintf('%s<BR>', getString(message('Sloptim:engine:msgOptimizationStarted',datestr(now)))); end this.postMessage(header,hText) end case 'iter' if strcmp(DisplayLevel,'iter') state = varargin{1}; if isempty(hText) %Command line display switch Algorithm case 1 formatstr = ' %5.0f %5.0f %12.6g %12.6g %s'; msg = sprintf(formatstr,state.simcount,state.lincount,varargin{2},state.fval,state.procedure); case 2 formatstr = ' %5.0f %5.0f %5.0f %12.6g %s'; msg = sprintf(formatstr,state.iteration,state.simcount,state.lincount,state.fval,state.procedure); end else %GUI display switch Algorithm case 1 msg = {... sprintf('%5.0f', 0), ... sprintf('%5.0f', state.simcount+state.lincount), ... sprintf('%12.6g', state.fval), ... sprintf('%s', 'na'), ... sprintf('%s', 'na'), ... sprintf('%s', state.procedure)}; case 2 msg = {... sprintf('%5.0f', state.iteration), ... sprintf('%5.0f', state.simcount+state.lincount), ... sprintf('%s', 'na'), ... sprintf('%12.6g', state.fval), ... sprintf('%s', 'na'), ... sprintf('%s', state.procedure)}; end end this.postMessage(msg,hText) end case 'done' if ~strcmp(DisplayLevel,'off') if isempty(hText) %Command line display msg = ''; linesep = '\n'; else %GUI display msg = getString(message('Sloptim:engine:msgOptimizationFinished',datestr(now))); linesep = '<BR>'; end switch varargin{1} % exitflag case {1,2} msg = sprintf('%s%s%s%s%s', ... msg, ... linesep, ... getString(message('Sloptim:engine:msgSuccessfulTermination')), ... linesep, ... getString(message('Sloptim:engine:msgSuccessfulTermination_detail'))); case 0 msg = sprintf('%s%s%s%s%s',... msg, ... linesep, ... getString(message('Sloptim:engine:msgMaxIterExceeded')), ... linesep, ... getString(message('Sloptim:engine:msgMaxIterExceeded_detail'))); case -1 msg = sprintf('%s%s%s', ... msg, ... linesep, ... getString(message('Sloptim:engine:msgUserAbortedOptimization'))); case -2 msg = sprintf('%s%s%s%s%s',... msg, ... linesep, ... getString(message('Sloptim:engine:msgNoFeasibleSolution')), ... linesep, ... getString(message('Sloptim:engine:msgNoFeasibleSolution_detail'))); end this.postMessage(msg,hText) end end