• 大小: 3KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: 其他
  • 标签: MATLAB  

资源简介

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


评论

共有 条评论