gaplotchange.m

来自「有限差分法(crank_nicholson finite difference 」· M 代码 · 共 24 行

M
24
字号
function state = gaplotchange(options, state, flag)
% GAPLOTCHANGE Plots the logarithmic change in the best score from the 
% previous generation.
%   
persistent last_best % Best score in the previous generation

if(strcmp(flag,'init')) % Set up the plot
    set(gca,'xlim',[1,options.Generations],'Yscale','log');
    hold on;
    xlabel Generation
    ylabel Log
    title('Change in Best Fitness Value')
end

best = min(state.Score); % Best score in the current generation
if state.Generation == 0 % Set last_best to best.
    last_best = best;
else
 change = last_best - best; % Change in best score 
 last_best=best;

 plot(state.Generation, change, '.r');
 title(['Change in Best Fitness Value'])
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?