91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

使用MATLAB軟件中的simulink模塊,進(jìn)行遺傳算法PID控制仿真,實(shí)測(cè)成功!!

資源截圖

代碼片段和文件信息

%Generic?Algorithm?for?function?f(x1x2)?optimum
clear?all;
close?all;

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);

E(:1)=MinX(1)+(MaxX(1)-MinX(1))*rand(Size1);
E(:2)=MinX(2)+(MaxX(2)-MinX(2))*rand(Size1);
E(:3)=MinX(3)+(MaxX(3)-MinX(3))*rand(Size1);

G=100;%迭代次數(shù)
BsJ=0;

%***************?Start?Running?***************
for?kg=1:1:G
time(kg)=kg;

%******?Step?1?:?Evaluate?BestJ?******
for?i=1:1:Size
x=E(i:);

[xBsJ]=GA_PID_Simulink_fitness(xBsJ);

BsJi(i)=BsJ;

end
?
[OderJiIndexJi]=sort(BsJi);
BestJ(kg)=OderJi(1);
BJ=BestJ(kg);
Ji=BsJi+1e-10;????%Avoiding?deviding?zero

fi=1./Ji;
???
???[OderfiIndexfi]=sort(fi);????%Arranging?fi?small?to?bigger
???Bestfi=Oderfi(Size);??????????%Let?Bestfi=max(fi)
???BestS=E(Indexfi(Size):);??%Let?BestS=E(m)?m?is?the?Indexfi?belong?to?max(fi)
???
???bfi(kg)=Bestfi;

???kg???
???x
???BJ
%******?Step?2?:?Select?and?Reproduct?Operation******
???fi_sum=sum(fi);
???fi_Size=(Oderfi/fi_sum)*Size;
???
???fi_S=floor(fi_Size);????????????????????%?Selecting?Bigger?fi?value
???r=Size-sum(fi_S);
???
???Rest=fi_Size-fi_S;
???[RestValueIndex]=sort(Rest);
???
???for?i=Size:-1:Size-r+1
??????fi_S(Index(i))=fi_S(Index(i))+1;?????%?Adding?rest?to?equal?Size
???end

???k=1;
???for?i=Size:-1:1???????%?Select?the?Sizeth?and?Reproduce?firstly??
??????for?j=1:1:fi_S(i)??
???????TempE(k:)=E(Indexfi(i):);??????%?Select?and?Reproduce?
?????????k=k+1;????????????????????????????%?k?is?used?to?reproduce
??????end
???end
???
%************?Step?3?:?Crossover?Operation?************
????Pc=0.90;
????for?i=1:2:(Size-1)
??????????temp=rand;
??????if?Pc>temp??????????????????????%Crossover?Condition
??????????alfa=rand;
??????????TempE(i:)=alfa*E(i+1:)+(1-alfa)*E(i:);??
??????????TempE(i+1:)=alfa*E(i:)+(1-alfa)*E(i+1:);
??????end
????end
????TempE(Size:)=BestS;
????E=TempE;
????
%************?Step?4:?Mutation?Operation?**************
Pm=0.10-[1:1:Size]*(0.01)/Size;???????%Bigger?fismaller?Pm
Pm_rand=rand(SizeCodeL);
Mean=(MaxX?+?MinX)/2;?
Dif=(MaxX-MinX);

???for?i=1:1:Size
??????for?j=1:1:CodeL
?????????if?Pm(i)>Pm_rand(ij)????????%Mutation?Condition
????????????TempE(ij)=Mean(j)+Dif(j)*(rand-0.5);
?????????end
??????end
???end
%Guarantee?TempE(Size:)?belong?to?the?best?individual
???TempE(Size:)=BestS;??????
???E=TempE;
end
BestS
Bestfi
fi
x
Best_J=BestJ(G)
figure(1);
plot(timeBestJ);
xlabel(‘Times‘);ylabel(‘Best?J‘);
save?pfile?x;

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2017-03-03?16:03??遺傳算法優(yōu)化simulink中PID參數(shù)\
?????文件????????2608??2017-03-03?11:09??遺傳算法優(yōu)化simulink中PID參數(shù)\GA_PID_Simulink.m
?????文件?????????235??2017-03-03?12:52??遺傳算法優(yōu)化simulink中PID參數(shù)\GA_PID_Simulink_fitness.m
?????文件???????16722??2017-03-03?10:27??遺傳算法優(yōu)化simulink中PID參數(shù)\myPID.slx
?????文件???????20243??2017-03-03?15:55??遺傳算法優(yōu)化simulink中PID參數(shù)\tlbo_pid.slx

評(píng)論

共有 條評(píng)論