欢迎您的到来
博客主页:博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
目录
1 概述
2 运行结果
⛳️3 参考文献
4 Matlab代码实现
本文为解决卡车和两个无人机旅行推销员的问题,表示为串联团队,无人机提供最后一英里的努力。使用遗传算法(路由突变)来解决问题。该问题可以解决随机生成坐标的100个城市的D2TSP。该解决方案基于最小化时间而不是距离。最短时间计算基于卡车或无人机在操作中交付的最长时间。操作表示为无人机(或两者)发射、发送交付然后在会合位置恢复的节点或停靠点。每架无人机都受到航程和容量的限制。因此,操作中的停靠范围和停靠次数受到无人机约束的限制。
部分代码:
% Sanity Checks
popSize = max(12,12*ceil(popSize(1)/12));
numIter = max(1,round(real(numIter(1))));
showProg = logical(showProg(1));
showResult = logical(showResult(1));
showWaitbar = logical(showWaitbar(1));
% Initialize the Populations
popRoute = zeros(popSize,n); %routes
popTrk = zeros(popSize,n); %truck route
popDrn = zeros(popSize,n); %drone route
popDrn2 = zeros(popSize,n); %drone 2 route
popOps = zeros(popSize,n); %operations drone 1
popRoute(1,:) = (1:n);
rp =popRoute(1,:);
%[rp, optr, oppr, opdr] = map_cir2(rp) ;
[rp, optr, oppr, opdr, opdr2] = map_cir2(rp);
popRoute(1,:) = map_cir( rp);
popTrk(1,:) = optr;
popDrn(1,:) = opdr;
popDrn2(1,:) = opdr2;
popOps(1,:) = oppr;
for k = 2:popSize
[op, tr, dr, dr2] = rand_ops_d_o();
% op=oppr; tr=optr; dr=opdr; dr2=opdr2;
popRoute(k,:) = randperm(n);
if mod(k,2)==0 % swap
r = sort([randi(n) randi(n)]);
r1=r(1); r2=r(2);
popRoute(k,:)= popRoute(1,:);
popRoute(k,[r1 r2]) = popRoute(k,[r2 r1]);
elseif mod(k,3)==0 % flip
r = sort([randi(n) randi(n)]);
r1=r(1); r2=r(2);
popRoute(k,:)= popRoute(1,:);
popRoute(k,r1:r2) = popRoute(k,r2:-1:r1);
elseif mod(k,4)==0% swap, flip
r = sort([randi(n) randi(n)]);
r1=r(1); r2=r(2);
popRoute(k,:)= popRoute(1,:);
popRoute(k,[r1 r2]) = popRoute(k,[r2 r1]);
popRoute(k,r1:r2) = popRoute(k,r2:-1:r1);
else
r = sort([randi(n) randi(n)]);
r1=r(1); r2=r(2);
popRoute(k,:)= popRoute(1,:);
popRoute(k,[r1 r2]) = popRoute(k,[r2 r1]);
% popRoute(k,r1:r2) = popRoute(k,r2:-1:r1);
end
popTrk(k,:) = tr;
popOps(k,:) = op;
popDrn(k,:) = dr;
popDrn2(k,:) = dr2;
end
% Run the GA
globalMin = Inf;
totalDist = zeros(1,popSize);
totalTime = zeros(1,popSize); % total time for route
totalEnergy = zeros(1,popSize); % total energy for route
totalCost = zeros(1,popSize); % cost of route
totalCostkm = zeros(1,popSize);
totalCosthr = zeros(1,popSize);
totalEnergyP = zeros(1,popSize);
distHistory = zeros(1,numIter);
timeHistory = zeros(1,numIter);
energyHistory= zeros(1,numIter);
costHistory = zeros(1,numIter);
costkmHistory= zeros(1,numIter);
costhrHistory= zeros(1,numIter);
tmpPopRoute = zeros(12,n);
tmpPopTrks = zeros(12,n);
tmpPopOps = zeros(12,n);
tmpPopDrns = zeros(12,n);
tmpPopDrns2 = zeros(12,n);
newPopRoute = zeros(popSize,n);
newPopTrks = zeros(popSize,n);
newPopOps = zeros(popSize,n);
newPopDrns = zeros(popSize,n);
newPopDrns2 = zeros(popSize,n);
[1]黄书召,田军委,乔路,王沁,苏宇.基于改进遗传算法的无人机路径规划[J.计算机应用,2021,41(02):390-397.