matlab遗传算法程序解读?

问题描述:

matlab遗传算法程序解读?
%GA(Generic Algorithm) Program to optimize PID Parameters
clear all;
close all;
global rin yout timef
Size=30;
CodeL=3;
MinX(1)=zeros(1);
MaxX(1)=20*ones(1);
MinX(2)=zeros(1);
MaxX(2)=1.0*ones(1);
MinX(3)=zeros(1);
MaxX(3)=1.0*ones(1);
Kpid(:,1)=MinX(1)+(MaxX(1)-MinX(1))*rand(Size,1);
Kpid(:,2)=MinX(2)+(MaxX(2)-MinX(2))*rand(Size,1);
Kpid(:,3)=MinX(3)+(MaxX(3)-MinX(3))*rand(Size,1);
G=100;
BsJ=0;
%
Pm=0.10-[1:1:Size]*(0.01)/Size; %Bigger fi,smaller Pm
Pm_rand=rand(Size,CodeL);
Mean=(MaxX + MinX)/2;
Dif=(MaxX-MinX);
for i=1:1:Size
for j=1:1:CodeL
if Pm(i)>Pm_rand(i,j) %Mutation Condition
TempE(i,j)=Mean(j)+Dif(j)*(rand-0.5);
end
end
end
%Guarantee TempE(Size,:) belong to the best individual
TempE(Size,:)=BestS;
Kpid=TempE;
end
Bestfi
BestS
Best_J=BestJ(G)
figure(1);
plot(time,BestJ);
xlabel('Times');ylabel('Best J');
figure(2);
plot(timef,rin,'r',timef,yout,'b');
xlabel('Time(s)');ylabel('rin,yout');
1个回答 分类:综合 2014-11-27

问题解答:

我来补答
遗传优化pid的吧 主要从复制交叉 变异三个方面考虑
 
 
展开全文阅读
剩余:2000