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

📄 ga_ex622.m

📁 书籍代码:遗传演算法原理与应用_活用MATLAB(Source Code)
💻 M
字号:
% GA_ex622.m file
% Find scaling factors of a Fuzzy control system by using GA

% PenChen Chou, 7-30-2001

%**********************************************************/
%       User can modify the following in blocks
%**********************************************************/
global MIN_offset MUL_factor LOCUS x_data y_data 
global Emin MDL Init_P Init_V FT Se Sde Su ex621f

ex621f=readfis('ex621f');
MDL='IPa_control'; eval(MDL); FT=2; 
MIN_offset=6e5; LOCUS=0; x_data=[]; y_data=[];
MUL_factor=5;
Emin=MIN_offset;
obj_fcn = 'GA_f622';	% Objective function
UB=15*ones(1,3); LB=0.01*ones(1,3);
range = [LB;UB];
IC=[];elite=1;
gen_no=30;  popuSize=40;
gen_no=20;  popuSize=20;
bit_n=40; xover_rate=1; mutate_rate=0.05;
%************************************************************
% 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, bit_n, xover_rate,...
    mutate_rate);
t=toc/60;

fprintf('==>  Computation time is (%.2f) minutes.\n',t);            
            
% Show the result using parameters found by GA
Se=para(1);
Sde=para(2);
Su=para(3);
[t, X, Y]=sim(MDL,[0 6]);
in=Y(:,2); x1=Y(:,3); x2=Y(:,4);
figure(2);subplot(211);plot(t,[in x1]);
title('Pendulum angle command and output responses(deg.)');
figure(2);subplot(212);plot(t,[x2]);
title('Pendulum angle velocity output response(deg./s)');
xlabel('Time(s)');

⌨️ 快捷键说明

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