【路径规划】基于狼群算法之三维路径规划matlab源码

218 阅读1分钟

1 基于狼群算法之三维路径规划模型

img

img

img

img

img

img

img

img

img

img

img

4 部分代码

%% 清空环境
clc
clear all
close all
%% 数据初始化%下载数据
load  HeightData
% HeightData=HeightData';
%网格划分
LevelGrid=10;
PortGrid=21;
​
%起点终点网格点
starty=6;starth=1;
endy=8;endh=21;
m=1;
%算法参数
PopNumber=10;         %种群个数
BestFitness=[];    %最佳个体
iter=100;
%初始信息素
pheromone=ones(21,21,21);
dim=PortGrid*2;
Max_iter=100;
ub=PortGrid;
lb=1;
% initialize alpha, beta, and delta_pos
Alpha_pos=zeros(1,dim);
Alpha_score=inf; %change this to -inf for maximization problems
Beta_pos=zeros(1,dim);
Beta_score=inf; %change this to -inf for maximization problems
Delta_pos=zeros(1,dim);
Delta_score=inf; %change this to -inf for maximization problems
%Initialize the path of search agents
Convergence_curve=zeros(1,Max_iter);
l=0;% Loop counter
%% 初始搜索路径
[path,pheromone]=searchpath(PopNumber,LevelGrid,PortGrid,pheromone, ...
   HeightData,starty,starth,endy,endh);
fitness=CacuFit(path);                          %适应度计算
[bestfitness,bestindex]=min(fitness);           %最佳适应度
bestpath=path(bestindex,:);                     %最佳路径
BestFitness=[BestFitness;bestfitness];          %适应度值记录
​
l=0;% Loop counter% Main loop
while l<Max_iter
   for i=1:size(path,1)
       
       % Return back the search agents that go beyond the boundaries of the search space
       Flag4ub=path(i,:)>ub;
       Flag4lb=path(i,:)<lb;
       path(i,:)=round((path(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb);
       
       % Calculate objective function for each search agent
       fitness=CacuFit(path(i,:));
       
       % Update Alpha, Beta, and Delta
       if fitness<Alpha_score
           Alpha_score=fitness; % Update alpha
           Alpha_pos=path(i,:);
       end
       
       if fitness>Alpha_score && fitness<Beta_score
           Beta_score=fitness; % Update beta
           Beta_pos=path(i,:);
       end
       
end

5 仿真结果

img

img

6 参考文献

[1]段海滨, 张岱峰, 范彦铭,等. 从狼群智能到无人机集群协同决策[J]. 中国科学F辑, 2019, 049(001):112-118.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。