📄 ga_ex614a.m
字号:
% GA_ex614a.m file
% Find weights and bias of a NN control system by using GA
% PenChen Chou, 7-29-2001
%**********************************************************/
% User can modify the following in blocks
%**********************************************************/
clear all
ans=1;
who
fprintf('>>>Start this program now. Please wait!\n');
pause(1)
global MIN_offset MUL_factor LOCUS x_data y_data
global Emin MDL r_deg Init_P Init_V FT Mode
global V11 V12 V21 V22 W11 W12 b11 b21 c11 K a1 a2
%MDL='negf_nn'; eval(MDL); FT=5; Mode=0;
MDL='negfb_nn'; %eval(MDL);
FT=7.5; Mode=1;
FT=18;
MIN_offset=3e4; LOCUS=0; x_data=[]; y_data=[];
MUL_factor=1;
Emin=MIN_offset;
obj_fcn = 'GA_f614a'; % Objective function
UB=5.5*ones(1,9); LB=-UB;
range = [LB;UB];
IC=[];elite=1;
gen_no=105; popuSize=60;
gen_no=25; popuSize=30;
bit_n=35; xover_rate=0.7; mutate_rate=0.06;
% This is the NN net we can use in this program. Don't change it.
net = newff([0 1;0 1],[2 1],{'tansig' 'purelin'});
%************************************************************
% 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
K=10; a1=2; a2=3;
V11=para(1);
V12=para(2);
V21=para(3);
V22=para(4);
b11=para(5);
b21=para(6);
W11=para(7);
W12=para(8);
c11=para(9);
if Mode==0
Ftime=5;
else
Ftime=18;
end;
[t, X, Y]=sim(MDL,[0:0.05:Ftime]);
in=Y(:,2); x1=Y(:,3); x2=Y(:,4);
figure(2);subplot(211);plot(t,[in x1]);
title('Antenna angle command and output responses(deg.)');
figure(2);subplot(212);plot(t,[x2]);
title('Antenna angle velocity output response(deg./s)');
xlabel('Time(s)');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -