⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ga_print.m

📁 书籍代码:遗传演算法原理与应用_活用MATLAB(Source Code)
💻 M
字号:
function GA_print(gen_no, gen_last, var_n, popu, ...
                   popu_real, fcn_val, STEPS)
global LOCUS x_data y_data
%=====================================================
% GA_print.m
% function GA_print(gen_no, gen_last, var_n, popu, ...
%                   popu_real, fcn_val, STEPS)
% global LOCUS x_data y_data
%=====================================================
% Print intermediate results like the following
% [Generation #500], ===>Best_FIT= 51.00000000
%    parameter( 1)=  -5.01609163
%    parameter( 2)=  -5.06722401
%    parameter( 3)=  -5.11193552
%    parameter( 4)=  -5.01528481
%    parameter( 5)=  -5.02855515
%
% If LOCUS is not zero, collect parameter(1) to
% x_data and parameter(2) to y_data for plotting
% Only for the 3-dim plot
% LOCUS, x_data, y_data must be defined in MAIN program

% PenChen Chou, 7-1-2001

% Make sure to get the best of fitness function
[Y, I]=max(fcn_val);
%
BEST=popu_real(I,:);
BEST_bit=popu(I,:);
BEST_fit =Y;
if mod(gen_no,STEPS)==0 | gen_no==1 | gen_no==gen_last
   fprintf('\n[Generation #%i], ===>Best_FIT= %.8f\n',...
                gen_no, Y);
   for I=1:var_n
       fprintf('    parameter(%2i)=%13.8f\n',...
                                       I, BEST(I));
   end;
else
   fprintf('\n');
end;

% If LOCUS is not zero, plot the best parameters on 3-dim
% contour in figure 2. So, collect the data first.
if LOCUS>0
    x_data=[x_data BEST(1)];
    y_data=[y_data BEST(2)];
end;

⌨️ 快捷键说明

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