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

📄 ga_ex37a.m

📁 书籍代码:遗传演算法原理与应用_活用MATLAB(Source Code)
💻 M
字号:
% GA_ex37a.m file
% Find scaling factors [Se Sde Su] of a delayed plant

% PenChen Chou, 7-15-2001

%**********************************************************/
%       User can modify the following in blocks
%**********************************************************/
global MIN_offset MUL_factor LOCUS x_data y_data Se Sde Su MDL
MIN_offset=1e5; LOCUS=0; x_data=[]; y_data=[];
MUL_factor=1;
MDL='ex37_2';
eval(MDL)
obj_fcn = 'GA_f37';	% Objective function
range =[ 3   0.05    0.02
    6       0.5      0.5];	% Range of the input variables
IC=[];elite=1;
gen_no=40;
popuSize=50;
ex37a_fis=readfis('ex37a_fis');
%************************************************************
% calling GA 
tic
% function [popu, popu_real, fcn_value, upper, average,...
%   lower, BEST_popu, popuSize, gen_no, para]=GA_genetic(obj_fcn,...
%   range, IC, elite, gen_no, popuSize, bit_n, xover_rate,...
%   mutate_rate);
[popu, popu_real, fcn_value, upper, average, lower, ...
    BEST_popu, popuSize, gen_no, para] = GA_genetic(obj_fcn,...
    range, IC, elite, gen_no, popuSize);
t=toc/60;

fprintf('==>  Computation time is (%.2f) minutes.\n',t);            
            
% Plot the final results
Se=para(1);
Sde=para(2);
Su=para(3);
[T, X, Y]=sim(MDL,[0 6]);
in=Y(:,1); y=Y(:,2); err=abs(in-y).^2;
err=sum(err);
PI=err;
PI=MIN_offset-PI;
fprintf('Se=%f;Sde=%f;Su=%f;PI=%f;\n',Se,Sde,Su,PI);

⌨️ 快捷键说明

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