資源簡介
AGA自適應(yīng)加速遺傳算法,適用于機(jī)器學(xué)習(xí)算法中AGA自適應(yīng)加速遺傳算法,適用于機(jī)器學(xué)習(xí)算法AGA自適應(yīng)加速遺傳算法,適用于機(jī)器學(xué)習(xí)算法
代碼片段和文件信息
clc;
clear;
figure(8);
par=zeros(1100);
par2=zeros(1100);
time=zeros(1100);
sstep=zeros(1100);
for?j=1:1
????disp(‘------------------------------------------------------------------‘);
????episodes=100;??
????theta=zeros(541);
????distance=0;
????v=zeros(271);
????gamma=0.9;
????lambda=0.5;
????epsilon=10^(-20);
%???F=400*eye(10);
????pend_actions=2;
????for?r=1:episodes
????????disp(‘%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%‘);
????????noise=(2*rand(13)‘-1).*[2;2;0];%初始化狀態(tài)
????????state=[140;0;0]+0*noise;??
????????z=zeros(271);
????????step=0;
????????signal=0;
????????endsim=0;
????????mytime=cputime;
????????
????????while??endsim==0
????????????step=step+1;
????????????phi=computphi(state);
????????????phi_sa=zeros(542);
????????????for?i=1:pend_actions
????????????????phi_sa(:i)=[phi.*(i==1);phi.*(i==2)];
????????????end
????????????pi=computpi(phi_satheta);
????????????psi=computpsi(phi_sapi);
????????????action=select(pi);%take?an?action
????????????disp(‘the?action?is‘);
????????????disp(action);
%???????????disp(pi0);
%???????????disp(‘a(chǎn)ction=‘)
%???????????disp(action);
????????????[nexts?reward?endsim]?=?simulator(stateaction);
%?????????????disp(‘nexts=‘);
%?????????????disp(nexts);
%?????????????disp(‘reward=‘);
%?????????????disp(reward);
%?????????????disp(‘endsim=‘);
%?????????????disp(endsim);
????????????plot(nexts(31)nexts(11)‘o‘);
????????????hold?on;
????????????phi2=computphi(nexts);
????????????state=nexts;
????????????
????????????z=gamma*lambda*z+phi;?%更新適合度軌跡
%?????
%???????????K=F*z/(1+(phi‘-gamma*phi2‘)*F*z);
%???????????v=v+K*(reward-(phi‘-gamma*phi2‘)*v);
%???????????F=F-F*z*(phi‘-gamma*phi2‘)*F/(1+(phi‘-gamma*phi2‘)*F*z);
????????????alpha=0.5;
????????????beta=0.2;
%?????????????alpha=20/(50+step);
%?????????????beta=1/(25+step);
????????????delta=reward+gamma*phi2‘*v-phi‘*v;
????????????v=v+alpha*delta*z;
????????????theta2=theta+beta*delta*psi(:action);
????
????????????t=theta2-theta;
????????????theta=theta2;
????????????distance=norm(t2);
????????????if?distance>0&&distance %?????????????????signal=1;
????????????????break;
????????????end
????
%?????????????if?j>0||step>1000
%?????????????????signal=1;
%?????????????end
????????????
????????end
????????time(jr)=(cputime-mytime)/step;
????????sstep(jr)=step;
%?????????disp(‘episode=‘);
%?????????disp(r);
%?????????disp(‘endsim=‘);
%?????????disp(endsim);
????????disp(‘step=‘);
????????disp(step);
????????
????????
????????%?[sterew]=evaluate(theta);
????????%?par(jr)=ste;
????????%?disp(‘step2=‘);
????????%?disp(ste);
????end
????[steprew]=evaluate(theta);
end
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2765??2014-04-26?19:48??example\AC.asv
?????文件???????2776??2014-04-27?20:36??example\AC.m
?????文件????????414??2014-04-25?11:11??example\computphi.asv
?????文件????????420??2014-04-26?16:11??example\computphi.m
?????文件????????214??2014-04-25?17:38??example\computpi.m
?????文件????????214??2014-04-18?16:32??example\computpsi.m
?????文件????????691??2014-04-26?20:00??example\evaluate.m
?????文件????????140??2014-04-25?23:05??example\select.m
?????文件????????512??2014-04-26?00:11??example\simulator.asv
?????文件????????517??2014-04-27?20:51??example\simulator.m
?????目錄??????????0??2014-04-26?22:20??example
-----------?---------??----------?-----??----
?????????????????8663????????????????????11
評論
共有 條評論