matlab遗传算法程序解读?%GA(Generic Algorithm) Program to optimize PID Parametersclear all;close all;global rin yout timefSize=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*one
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 03:32:12
matlab遗传算法程序解读?%GA(Generic Algorithm) Program to optimize PID Parametersclear all;close all;global rin yout timefSize=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*one
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');
matlab遗传算法程序解读?%GA(Generic Algorithm) Program to optimize PID Parametersclear all;close all;global rin yout timefSize=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*one
遗传优化pid的吧 主要从复制交叉 变异三个方面考虑