2024新算法角蜥优化算法(HLOA)和经典灰狼优化器(GWO)进行无人机三维路径规划设计实验

发布于:2024-04-24 ⋅ 阅读:(26) ⋅ 点赞:(0)

简介:

2024新算法角蜥优化算法(HLOA)和经典灰狼优化器(GWO)进行无人机三维路径规划设计实验。

    无人机三维路径规划的重要意义在于确保飞行安全、优化飞行路线以节省时间和能源消耗,并使无人机能够适应复杂环境,实现特定任务。群体智能优化算法在无人机三维路径规划中扮演关键角色,其全局搜索能力允许同时考虑多个解决方案,避障优化确保路径安全,自适应性适应不同飞行任务需求,并行搜索加快最优解寻找速度。

    灰狼优化器(GWO)作为非常经典实用的群智能算法,在这里我们将其与2024年最新提出的角蜥优化算法(HLOA)进行无人机三维路径规划比较,运行结果包括最优路径和收敛曲线的比较。并附带代码,供大家学习参考!

实验结果如下:

部分主函数代码如下:

clc;
clear;
close all;
%% 创建地图
%地图的大小200*200
MapSizeX = 200 ; 
MapSizeY = 200;
%% 地形地图创建,地图详细参数,请去MapValueFunction.m里面设置
x = 1:1:MapSizeX;
y = 1:1:MapSizeY;
for i = 1:MapSizeX
    for j = 1:MapSizeY
        Map(i,j) = MapValueFunction(i,j);
    end
end
global NodesNumber
global startPoint
global endPoint
global ThreatAreaPostion
global ThreatAreaRadius

%% 威胁区域绘制
%威胁区域中心坐标
ThreatAreaPostion = [50,140];
%威胁区域半径
ThreatAreaRadius = 30;
%将威胁区域叠加到图上
figure
mesh(Map);
hold on;
for i= 1:size(ThreatAreaRadius)
    [X,Y,Z] = cylinder(ThreatAreaRadius(i),50);
    X = X + ThreatAreaPostion(i,1);
    Y = Y + ThreatAreaPostion(i,2);
    Z(2,:) = Z(2,:) + 50;%威胁区域高度
    mesh(X,Y,Z)
end
%% 设置起始点
startPoint = [0,0,20];
endPoint = [200,200,20];
plot3(startPoint(1),startPoint(2),startPoint(3),'ro');
text(startPoint(1),startPoint(2),startPoint(3),'起点','Color','k','FontSize',15)
plot3(endPoint(1),endPoint(2),endPoint(3),'r*');
text(endPoint(1),endPoint(2),endPoint(3),'终点','Color','k','FontSize',15)
title('地图信息')
%% 灰狼优化参数设置
NodesNumber = 2;%起点与终点之间节点的个数
dim = 2*NodesNumber; %维度,一组坐标点为[x,y,z]3个值,,其中X等间隔分布,所以总的数据个数为2*NodesNumber
lb = [20.*ones(1,NodesNumber),0.*ones(1,NodesNumber)];%x,y,z的下限[20,20,0]
ub = [180.*ones(1,NodesNumber),50.*ones(1,NodesNumber)];%x,y,z的上限[200,200,50]
fobj = @(x)fun(x,NodesNumber,startPoint,endPoint,ThreatAreaPostion,ThreatAreaRadius);%适应度函数
SearchAgents_no=70; % 种群数量
Max_iteration=50; % 设定最大迭代次数

[Best_pos_GWO,Best_score_GWO,GWO_curve]=GWO(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
[Best_pos_HLOA,Best_score_HLOA,HLOA_curve]=HLOA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
%根据寻优获得的节点,获取插值后的路径
[X_seq_HLOA,Y_seq_HLOA,Z_seq_HLOA,x_seq_HLOA,y_seq_HLOA,z_seq_HLOA] = GetThePathLine(Best_pos_HLOA,NodesNumber,startPoint,endPoint);
[X_seq_GWO,Y_seq_GWO,Z_seq_GWO,x_seq_GWO,y_seq_GWO,z_seq_GWO] = GetThePathLine(Best_pos_GWO,NodesNumber,startPoint,endPoint);

代码获取点击:

点击获取代码