【无人机】基于混合粒子群算法求解无人机航迹规划问题附Matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

个人主页:Matlab科研工作室

个人信条:格物致知。

⛄ 内容介绍

文章首先将无人机航迹问题转换 为多目标的TSP问题数学模型,建立了航迹规划问题的数学模型.然后将轨迹规划问题转换成一个求最短路径的单目标的有约束的优化问题,针对这类问题的求 解,采用了一种新的粒子群算法并利用软件编程求解.最后验证了结果的可行性,同时讨论了结果的稳定性和收敛性.

⛄ 部分代码

% The dodes for the paper "Cost-sensitive feature selection using

% two-archive multi-objective artificial bee colony algorithm"

% The program was completed by Yong Zhang. If you any questions, please call email:[email protected]

% The parameter X is the selected dataset

% D-1 is the size of features

% cost is the cost vector of all the orignal features

%%%%% the optional data sets are as follows:

% 1 promoters

% 2 MUSK

% 3 WPBC

% 4 ZOO

% 5. Lsvt

% 6-URBAN

% 7 sonar

% 8 ionosphere

clear

clc

global X D cost

cost1=[4,1,4,1,7,7,8,9,2,5,4,10,2,9,6,1,7,4,4,9,4,10,6,9,6,10,5,1,9,1,9,3,3,7,8,6,1,1,6,4,10,8,3,3,9,10,9,5,2,4,6,2,2,6,2,10,9,3,9,9,1,5,7,10,7,5,1,6,10,9,3,1,9,8,2,4,4,2,10,5,4,3,9,3,9,2,10,10,9,8,8,8,8,8,7,10,4,9,3,10,4,1,4,3,2,6,1,7,2,4,4,1,5,1,10,5,8,7,7,7,9,3,4,1,10,1,2,7,5,2,5,8,7,7,2,2,5,5,6,2,6,7,5,3,5,1,5,7,9,4,5,3,1,2,4,1,9,10,1,8,3,10,9,5,5,9,8,8,2,8,5,4,10,9,4,9,5,6,7,10,1,8,6,4,1,10,6,4,4,5,5,2,6,3,2,9,1,9,8,7,5,7,1,2,4,3,7,10,7,6,3,1,2,5,6,6,10,3,9,9,4,9,1,5,4,10,9,8,4,5,7,4,8,5,2,4,9,6,5,8,5,9,7,8,10,3,9,5,5,3,1,1,8,3,4,4,4,3,4,1,3,7,6,5,7,5,5,6,2,2,6,9,6,5,10,4,9,7,8,2,4,3,3,3,2,2,1,7,6,5,10,5,4,3,8,6,6,1,1,6,7,2,3,7,7,2,1,10,9,5];

cost=cost1;

%-----select the test data set-------------------------

fly=8;               % select the test data set        

X=data_t(fly);         % load the selected dataset

D=size(X,2);%/*The number of parameters of the problem to be optimized*/

%----------------------------------------------------------

%/* Control Parameters of ABC algorithm--------------------------------------

NP=30; %/* The number of colony size (employed bees+onlooker bees)*/

FoodNumber=NP/2; %/*The number of food sources equals the half of the colony size*/

maxCycle=100; %/*The number of cycles for foraging {a stopping criteria}*/

limit=5; %/*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/

M=2;

arch_size=30; % the archive size

%-------------------------------------------------------

%------------set the upper and lower bounds of the varaible 

ub(1:D)=1;    %/*upper bounds 

lb(1:D)=0;    %/*lower bound 

%-------------------------------------------------- 

%---the initialization of food sources

Range = repmat((ub-lb),[FoodNumber 1]);

Lower = repmat(lb, [FoodNumber 1]);

Foods = rand(FoodNumber,D) .* Range + Lower;

foodval=evaluation(Foods);

trial=zeros(1,FoodNumber);

%--------------------------------------------

%/*Initialize the elements of the archives*/

[AC1,gbest]=up_vac1(foodval,foodval,arch_size,FoodNumber,M,D);   % update the leader archive 

AC=sel_pareto(foodval,M,D);

AC2=up_vac2(AC,AC,arch_size,FoodNumber,M,D);             %update the external archive

%--------------------------------------------------

iter=1;          % iter is the iteration times;     maxCycle is the maximal iterations

while ((iter <= maxCycle)),

    %%%%%%%%% EMPLOYED BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%

    sol=[];

    for i=1:(FoodNumber)

        sol(i,:)=Foods(i,:);

        c1=rand;

        c2=1-c1;

        for j=1:D

            if(rand<0.6)

                a=(c1*sol(i,j)+c2*gbest(i,j));

                b=abs(sol(i,j)-gbest(i,j));

                sol(i,j)= a + b*randn;

            else

                sol(i,j)= gbest(i,j);

            end

            if sol(i,j)>=1

                sol(i,j)=1;

            elseif sol(i,j)<=0

                sol(i,j)=0;

            end

        end

    end

    

    solval=evaluation(sol); %evaluate new solution

    [AC1,gbest]=up_vac1(solval,AC1,arch_size,FoodNumber,M,D);   %Update the leader archives

    AC2=up_vac2(solval,AC2,arch_size,FoodNumber,M,D);

   

    for i=1:FoodNumber

        cc=0;

        for(jj=1:M)

            if(solval(i,D+jj)

                cc=cc+1;

            end

        end

        if(cc==2)

            Foods(i,:)=sol(i,:);

            foodval(i,:)=solval(i,:);

            trial(i)=0;

        else

            trial(i)=trial(i)+1;

        end

    end

    

    %%%%%%%%%%%%%%%%%%%%%%%% CalculateProbabilities %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if size(AC2,1)<=3 & rand>0.5

        t=0;

        sol=[];

        while(t

            t=t+1;

            k1=ceil(rand*size(AC1,1));

            sol(t,:)=AC1(k1,1:D);

            for jj=1:D

                if rand<0.1

                    sol(t,jj)=1-sol(t,jj);

                end

            end

        end

    else

        BEST=AC2;

        crowd_value=calcul_crowd1(BEST,M,D);

        prob=crowd_value./max(crowd_value);

        

        %%%%%%%%%%%%%%%%%%%%%%%% ONLOOKER BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        i=1;

        t=0;

        sc=size(BEST,1);

        sol=[];

        while(t

            if(rand

                t=t+1;

                sol(t,:)=BEST(i,1:D);

                h1=ceil(rand*size(AC2,1));

                h2=ceil(rand*size(AC2,1));

                [ref1,ref2]=select_ref(Foods,AC2,sol(t,:),D);

                ss=sum(abs(ref1(1,1:D)-ref2(1,1:D)));

                for jj=1:D

                    sol(t,jj)=sol(t,jj)+rand*(ref1(1,jj)-ref2(1,jj));

                    if sol(t,jj)>=1

                        sol(t,jj)=1;

                    elseif sol(t,jj)<=0

                        sol(t,jj)=0;

                    end

                end

                e1=[];

                for jj=1:D

                    if sol(t,jj)>0.5

                        e1(jj)=1;

                    elseif sol(t,jj)<=0.5

                        e1(jj)=0;

                    end

                end

                ss1=sum(abs(e1-BEST(i,1:D)));

                if ss1==0

                    h1=ceil(rand*D);

                    sol(t,h1)=1-sol(t,h1);

                end

            end

            i=i+1;

            if (i==sc+1)

                i=1;

            end;

        end

    end

    

    solval=evaluation(sol);  

    [AC1,gbest]=up_vac1(solval,AC1,arch_size,FoodNumber,M,D);   % update the leader archive 

     AC2=up_vac2(solval,AC2,arch_size,FoodNumber,M,D);             %update the external archive

    

    %%%%%%%%%%%% SCOUT BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    sol=[];

    ind=find(trial==max(trial));

    ind=ind(end);

    prob1=1-0.9*iter/maxCycle;

    if (trial(ind)>limit)

        trial(ind)=0;

        s1=ceil(rand*size(AC1,1));

        sol=AC1(s1,1:D);

        for jj=1:D

            if rand

                sol(jj)=rand;

            end

        end

        solval=evaluation(sol);

        Foods(ind,:)=sol(1,:);

        foodval(ind,:)=solval(1,:);

        [AC1,gbest]=up_vac1(solval,AC1,arch_size,FoodNumber,M,D);   % update the leader archive 

        AC2=up_vac2(solval,AC2,arch_size,FoodNumber,M,D);             %update the external archive

        

    end

    

    iter=iter+1  

end % End of ABC

output=AC2;    %output the optimal feature subsets 

plot(AC2(:,D+1),AC2(:,D+2),'R*')

save all

⛄ 运行结果

【无人机】基于混合粒子群算法求解无人机航迹规划问题附Matlab代码_第1张图片

⛄ 参考文献

[1]彭文敏, 胡书, 张莉,等. 基于粒子群算法的无人机航迹规划问题[J]. 中国高新技术企业, 2010(3):2.

⛄ 完整代码

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

 

你可能感兴趣的:(优化求解,无人机,算法,matlab)