一、烟花优化算法
参考文献:
Tan, Y. and Y. Zhu. Fireworks Algorithm for Optimization. in Advances in Swarm Intelligence. 2010. Berlin, Heidelberg: Springer Berlin Heidelberg.
二、烟花算法求解城市无人机路径规划部分代码
close all clear clc rng('default'); %% 载入数据 data.S=[50,950,12]; %起点位置 横坐标与纵坐标需为50的倍数 data.E=[950,50,1]; %终点点位置 横坐标与纵坐标需为50的倍数 data.Obstacle=xlsread('data1.xls'); data.numObstacles=length(data.Obstacle(:,1)); %% 画图 figure hold on plot(curve,'r','LineWidth',2) xlabel('迭代次数') ylabel('路径长度') legend(str); [~,result]=fobj(Best_pos); drawPc(result,option,data,str) result.path(:,1)=result.path(:,1).*data.unit(1); result.path(:,2)=result.path(:,2).*data.unit(2); result.path(:,3)=result.path(:,3).*data.unit(3); %% 显示路径信息 fprintf("路径坐标:\n"); display(result.path) fprintf("路径长度:%f\n",result.fit);
三、部分结果
路径坐标:
50 950 12
100 950 13
150 900 14
150 850 13
200 800 13
200 800 14
250 800 13
300 800 12
350 800 12
400 750 12
400 700 11
450 650 12
450 600 12
450 550 12
450 550 11
500 500 10
450 450 10
450 400 9
500 350 8
500 400 7
450 400 6
500 350 6
550 300 5
550 300 6
550 250 6
550 200 7
550 150 6
500 100 6
550 50 6
500 100 5
550 150 4
550 200 4
550 200 3
550 150 3
600 100 3
650 50 4
700 100 3
750 100 2
800 50 3
850 100 2
900 100 3
900 50 2
950 50 2
1000 100 2
1000 100 1
950 100 1
950 50 1
路径长度:2448.710649
四、完整MATLAB代码
v