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

📄 ga_ex614.m

📁 其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載
💻 M
字号:
% GA_ex614.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

%MDL='negf_nn'; eval(MDL); FT=5; Mode=0;
MDL='negfa_nn'; eval(MDL); FT=7.5; Mode=1;
MIN_offset=6e5; LOCUS=0; x_data=[]; y_data=[];
MUL_factor=5;
Emin=MIN_offset;
obj_fcn = 'GA_f614';	% Objective function
UB=25*ones(1,9); LB=-UB;
range = [LB;UB];
IC=[];elite=1;
gen_no=105;  popuSize=60;
gen_no=25;  popuSize=40;
bit_n=40; xover_rate=1; mutate_rate=0.05;
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
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 + -