資源簡介
pso算法路徑的規劃問題,主要是在有障礙的情況下從一點到達另一點的路徑規劃。

代碼片段和文件信息
clear?all
clc
%?????for?o=1:4
????????tic
%?????????for?u=1:50
??????????%%?設置各參數值
????????????????startX=0;startY=0;????????????????????????????%起開始坐標??????????????????????????
????????????????endX=700;endY=700;????????????????????????????%結束坐標
????????????????c1=2;
????????????????c2=2;?????????????????????%學習因子
????????????????w=0.7;????????????????%慣性權數
????????????????pop=20;???????????????%粒子數
????????????????N_gen=500;
????????????????popmax=700;
????????????????popmin=0;??????????????%位置范圍,根據測試函數而定
????????????????Vmax=20;
????????????????Vmin=-20;?????????????????%速度范圍,根據測試函數而定
????????????????gridCount=30;
????????????????%%?生成山峰
??????????threat=[304?400?0;404?320?0;440?500?0;279?310?0;560?220?0;172?527?0;....
????????????????194?220?0;272?522?0;350?200?0;....
?????????????????650?400?0;740?250?0;540?375?0;510?600?0];
????????????r=[45?50?55?10?70?65?55?25?50?30?40?40?35];
????????for?i=1:length(r)
??????????????figure(1)
??????????????[xyz]=sphere;
??????????????mesh(threat(i1)+r(i)*xthreat(i2)+r(i)*yabs(threat(i3)+r(i)*z));
??????????????hold?on
????????end
????????view([-30-3070])
???????????%%?初始化粒子
????????????????????for?i=1:pop
????????????????????????for?j=1:gridCount
????????????????????????????????X(ij)=startX+j*(endX-startX)/(gridCount+1);
????????????????????????????????Y(ij)=startY+rand()*(endY-startY);
????????????????????????????????path(i2*j-1)=X(ij);
????????????????????????????????path(i2*j)=Y(ij);
????????????????????????end
????????????????????end
?????????????????????for?i=1:pop
?????????????????????????[distancepathpointpositionPoint]=verify(path(i:)threat....
?????????????????????????????????????????rstartXstartYendXendYgridCount);
????????????????????????fitness(i)=distance;
????????????????????????????V(i:)=5*rands(1gridCount*2);??%分布在速度范圍內
????????????????????end
????????????????????[bestFitnessbestindex]=min(fitness);
????????????????????bestpath=path(bestindex:);
????????????????????pbest=path;??
????????????????????T=std(fitness);?
????????????????????BestFitness=Inf;
????????????????????globalFitness=Inf;
????????????????????pathRecord=zeros(1gridCount+1);?bestRecord=zeros(1gridCount+1);
????????????????????position=zeros(gridCount+12);
????????????????%%?迭代取優
????????????????for?i=1:N_gen
????????????????????for?j=1:pop
????????????????????????V(j:)=w*V(j:)+c1*rand*(pbest(j:)-path(j:))+c2*rand*(bestpath-path(j:));??%根據公式更新速度
????????????????????????V(jfind(V(j:)>Vmax))=Vmax;??%限制速度大小
????????????????????????V(jfind(V(j:)
????????????????????????path(j:)=path(j:)+V(j:);??%根據公式更新位置
????????????????????????path(jfind(path(j:)>popmax))=popmax;??%限制位置大小
????????????????????????path(jfind(path(j:) ???????????????????????????[distancepathpointpositionPoint]=verify(path(j:)threat....
?????????????????????????????????rstartXstartYendXendYgridCount);
?????????????????????????????fmin=distance;
????????????????????????if?fmin<
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4812??2018-10-10?17:56??PSO_mountain-master\pso_mountain.m
?????文件?????????67??2018-09-21?09:22??PSO_mountain-master\README.md
?????文件???????2639??2018-09-21?09:22??PSO_mountain-master\verify.m
?????目錄??????????0??2018-10-10?10:07??PSO_mountain-master
-----------?---------??----------?-----??----
?????????????????7518????????????????????4
- 上一篇:武漢理工大學考研資料.txt
- 下一篇:有關樹莓派的應用設計報告
評論
共有 條評論