【无人机】基于遗传算法的卡车结合两架无人机求解旅行推销员问题(D2TSP)附Matlab代码

简介: 【无人机】基于遗传算法的卡车结合两架无人机求解旅行推销员问题(D2TSP)附Matlab代码

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

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测雷达通信 无线传感器

信号处理图像处理路径规划元胞自动机无人机 电力系统

⛄ 内容介绍

城市配送中,"最后一公里"配送成本是物流企业经营成本的主要组成部分,随着无人机技术的发展,无人机飞行能力和运输成本愈加优化,无人机配送作为城市配送领域的重要发展方向,受到越来越多的物流企业和研究人员的关注.由Amazon公司首先提出了并联式配送模式,即采用无人机由配送中心出发直接前往需求点完成配送后返回配送中心的配送方式,以实现无人机的"最后一公里"配送.然而研究人员指出,并联式配送模式由于对配送中心选址,需求点降落平台的要求较高,造成物流网络建设成本大幅增加,并不适用于城市配送中的"最后一公里"问题.因此,提出了串联式配送模式,即由卡车装载无人机进行配送,卡车即可作为无人机的起飞降落平台,也可作为移动仓库,这一模式有利于将配送中心建设在用地成本较低的区域,并提高了无人机的服务能力.本文主要研究城市配送中卡车和无人机串联式配送模式.当前国内外关于卡车和无人机协同配送问题的研究,主要集中在串联式配送模式中无人机的飞行约束方向,对于城市配送中卡车和无人机协同配送的可行性尚无研究,且对于带无人机的车辆路径问题算法多采用基于贪心选择的启发式算法,易陷入局部最优解.

⛄ 部分代码

% D2TSP_GA Truck and 2 drones Tream  Traveling Salesmen Problem

%%

%   Truck and two Drones Traveling Salesman Problem:

%   (D2-TSP) To run default values, just press the run button!

%  

%   The idea is to use a truck and two drones in tandem to deliver

%   small parcels to randomly distributed customers such that

%   all stops are delivered to by a truck or a drone

%   exactly once then return to starting location (depot). Both drones

%   are constrained by range and capacity.  Each drone must rendezvous

%   back with the truck at a downtream stop to swap out drone battery.

%   Each drone may visit 1 to 3 stops based on capacity before returning

%   to the truck.  The central idea is found in literature under the key

%   word (last mile, drone delivery, drone TSP, two drone TSP).  

%  

%   Algorithm highlights:  Genetic Algorithm (GA).  Finds a (near) optimal

%   solution to the d2-TSP (D2TSP or d2TSP) by setting up a GA to search

%   for the shortest timed route - least time needed for the in-tandem team

%   to travel and deliver to all stops (i.e. UPS/FedEx) and then return to

%   their starting locations-depots.  For each operation launch-deliver-

%   rendezvous, the max time of the truck or either drone is used to

%   calculate the time for the route.  The objective of the algorithm is to

%   minimize total time for team, return the route for truck, 2 drones, and

%   to denote where the operations take place.

%

% Summary:

%     1. Each truck drone team travels to a their own stops and then

%        rendezvous at an operation start/end for recharging the drones.

%     2. Each stop is visited by a truck, a drone, or both (rendezvous op).

%     3. Drone are constrained by capacity and range and must return to

%        truck at the end of range and to pick up another parcel to

%        deliver.

%     4. Energy is also calculated as this is becoming a more interesting

%        topic for drone deliveries.

%     5.

% Input:

%     USERCONFIG (structure) with zero or more of the following fields:


% Input variables as a structure: example and description

%     defaultConfig.nCities     = 50;(integer) number of stops or deliveries

%     defaultConfig.capacity    = 3; (integer) for drone capacity (1,2,3)

%     defaultConfig.range       = 10;(real)  drone range (10, 15, 20)

%     defaultConfig.speed       = 2; (integer)drone speed as factor of

%                                             truck speed at 35km/hr.

%     defaultConfig.energy      = 5e4; (real) drone energy J/km

%     defaultConfig.energyP     = 5e4; (real) drone energy J/parcel-km

%     defaultConfig.energyT     = 8.08e6; (real) truck energy J/km

%     defaultConfig.energyTP    = 4.04e4; (real) truck J/parcel-km

%     defaultConfig.cost        = .04; (real) drone cost/km

%     defaultConfig.costT       = .70; (real) truck cost/km

%     defaultConfig.xy          = 10*rand(defaultConfig.nCities,2);

%                                 randomly generated coordinates of stops

%     defaultConfig.dmat        = [];   (real) distance matrix

%     defaultConfig.popSize     = 200;  (integer) population size

%     defaultConfig.numIter     = 2.5e2; (integer) number of iterations

%     defaultConfig.showProg    = true; (boolean) show progress of route

%     defaultConfig.showResult  = true; (boolean) show results-output

%     defaultConfig.showWaitbar = false; (boolean) show wait bar

% Input Notes:

%    1. Rather than passing in a structure containing these fields, any of

%       these inputs can be passed in as parameter/value pairs in any order.

%    2. Field/parameter names are case insensitive.

%

% Output: The results are displayed in the command prompt upon completion.

%     The the inputs above as well as note below on outputs for

%     for descriptions on each field.

%      RESULTSTRUCT (structure) with comprised of various fields:

%             'xy',          xy, ...

%             'dmat',        dmat, ...

%             'popSize',     popSize, ...

%             'numIter',     numIter, ...

%             'showProg',    showProg, ...

%             'showResult',  showResult, ...

%             'showWaitbar', showWaitbar, ...

%             'optRoute',    optRoute, ...

%             'opOps',       opOps, ...

%             'opTrk',       opTrk, ...

%             'opDrn',       opDrn, ...

%             'opDrn2',      opDrn2, ...

%             'nCities',     nCities, ...

%             'cap',         cap, ...

%             'range',       range, ...

%             'speed',       speed, ...

%             'cost',        cost, ...

%             'costT',       costT, ...

%             'energy',      energy, ...

%             'energyT',     energyT, ...

%             'energyP',     energyP, ...

%             'energyTP',    energyTP, ...

%             'minEnergy',   minEnergy, ...

%             'minEnergyP',  minEnergyP, ...

%             'minCost',     minCost, ...

%             'minTime',     minTime, ...

%             'minDist',     minDist);

%

% Route/Operations Details:

%     There is one truck and two drones in this scenario (d2TSP).

%     Therefore a possible truck rout      rte  = [5  6  9 1 4 2 8 10 3 7]

%     possible capacity(2) drone rout of 2 rte2 = [5 10 11 9 12 14 8 15 7]

%     possible operations                  ops  = [5       9      8     7]

%     These are found by taking the binary routes (trk, drn, ops) and

%     multiplying by the opt route (working generic route)

%     Once multiled, remove zeros and these denote the truck route

%     solution, drone route solution as well as the rendezvous operations

%     where the truck swaps out a battery for the drone.  As such:

%       . Truck 1:     travels stops 5, 6, 9, 1, 4, 8, 10, 3, 7 then 5

%       . Drone 1:     travels from stop 5, 10, 11, 9, 12, 14, 8, 15, 7,5

%       . Operations:  team rendezvous at 5, 9, 8, 7

%

% Usage:

%     dtsp_ga

%       -or-

%     dtsp_ga(userConfig)

%       -or-

%     resultStruct = dtsp_ga;

%       -or-

%     resultStruct = dtsp_ga(userConfig);

%       -or-

%     [...] = dtsp_ga('Param1',Value1,'Param2',Value2, ...);

%

% Examples (function only):

%     dtsp_ga; % function call

%     resultStruct = dtsp_ga; % function call with results

%

% Examples (pass in simple stuctures values directly

%     userConfig = struct('xy',10*rand(35,2));

%     resultStruct = dtsp_ga(userConfig);

%

%     % Change the defaults for GA population size and number of iterations

%     userConfig = struct('popSize',200,'numIter',1e4);

%     resultStruct = dtsp_ga(userConfig);

%

%     % Turn off the plots but show a waitbar

%     userConfig = struct('showProg',false,'showResult',false,'showWaitbar',true);

%     resultStruct = dtsp_ga(userConfig);

%

% Acknowledgement/Attribution: based in part on the principles of

% genetic algorithms for sequencing (mutations) as depicted by

% by Joseph Kirk - author/contributor to MATLAB, 2010-2016.

%

% keywords also: tsp_ga,dtsp_ga, d2tsp_ga, mtsp_ga, genetic algorithms


function [varargout ] = d2tsp_ga(varargin)


% Initialize default configuration

   defaultConfig.nCities     = 30;     %number stops

   defaultConfig.capacity    = 3;      %drone capacity (1,2,3)

   defaultConfig.range       = 10;     %(10, 15, 20)

   defaultConfig.speed       = 2;      %drone speed factor of truck =1

   defaultConfig.energy      = 5e4;    %(drone 5e4, 1e5, 2e5)

   defaultConfig.energyP     = 5e4;    %(drone 5e4, 1e5, 1.3e4)

   defaultConfig.energyT     = 8.08e6; %(truck 8.08e6, 6.0e6)

   defaultConfig.energyTP    = 4.04e4; %(truck , 4.04e4, 1.2e5)

   defaultConfig.cost        = .04;    % $0.04, $0.08, $0.20

   defaultConfig.costT       = .70;    % $0.70, $0.40

   defaultConfig.xy          = 10*rand(defaultConfig.nCities,2);

   defaultConfig.dmat        = [];     %dist matrix

   defaultConfig.popSize     = 200;    %population size

   defaultConfig.numIter     = 2.5e2;  %1.25e3; %iterations

   defaultConfig.showProg    = true;   %show progress of route

   defaultConfig.showResult  = true;   %show results on completion

   defaultConfig.showWaitbar = false;  %show wait bar

 

   % output (inputs) nCities, cacity, range, speed, cost-d, cost-t, energy-d, energy-t, energyP-d, energyP-t, cost, costT

   % output (results) minTime, minEnergy, minEnergyP, minCost,

 

% Subfunction to override the default configuration with user inputs

function config = get_config(defaultConfig,userConfig)

   

   % Initialize the configuration structure as the default

   config = defaultConfig;

   

   % Extract the field names of the default configuration structure

   defaultFields = fieldnames(defaultConfig);

   

   % Extract the field names of the user configuration structure

   userFields = fieldnames(userConfig);

   nUserFields = length(userFields);

   

   % Override any default configuration fields with user values

   for i = 1:nUserFields

       userField = userFields{i};

       isField = strcmpi(defaultFields,userField);

       if nnz(isField) == 1

           thisField = defaultFields{isField};

           config.(thisField) = userConfig.(userField);

       end

   end

   

end

end % end function

⛄ 运行结果

⛄ 参考文献

[1]方伟王玉佳闫文君. 基于双变异遗传算法的无人机对海侦察航路规划[J]. 中国电子科学研究院学报, 2021, 16(8):772-782.

⛄ Matlab代码关注

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料



相关文章
|
SQL 算法 Java
Mybatis-plus超详细讲解(2022)
MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 我们的愿景是成为 MyBatis 最好的搭档,就像 魂斗罗 中的 1P、2P,基友搭配,效率翻倍。
4202 1
|
XML 机器学习/深度学习 数据格式
YOLOv8训练自己的数据集+常用传参说明
YOLOv8训练自己的数据集+常用传参说明
19802 1
|
人工智能 算法 新能源
【2023高教社杯】A题 定日镜场的优化设计 问题分析及数学模型
本文介绍了2023年高教社杯数学建模竞赛A题的定日镜场优化设计问题,涉及问题分析和数学模型构建,旨在提高太阳能光热发电效率并实现电力系统的新能源转型。
345 1
【2023高教社杯】A题 定日镜场的优化设计 问题分析及数学模型
|
12月前
|
算法 决策智能
基于GA-PSO遗传粒子群混合优化算法的TSP问题求解matlab仿真
本文介绍了基于GA-PSO遗传粒子群混合优化算法解决旅行商问题(TSP)的方法。TSP旨在寻找访问一系列城市并返回起点的最短路径,属于NP难问题。文中详细阐述了遗传算法(GA)和粒子群优化算法(PSO)的基本原理及其在TSP中的应用,展示了如何通过编码、选择、交叉、变异及速度和位置更新等操作优化路径。算法在MATLAB2022a上实现,实验结果表明该方法能有效提高求解效率和解的质量。
|
安全 测试技术 Swift
Llama 3开源,魔搭社区手把手带你推理,部署,微调和评估
Meta发布了 Meta Llama 3系列,是LLama系列开源大型语言模型的下一代。在接下来的几个月,Meta预计将推出新功能、更长的上下文窗口、额外的模型大小和增强的性能,并会分享 Llama 3 研究论文。
Llama 3开源,魔搭社区手把手带你推理,部署,微调和评估
|
边缘计算 计算机视觉 异构计算
【YOLOv8改进 - 特征融合NECK】Slim-neck:目标检测新范式,既轻量又涨点
YOLO目标检测专栏探讨了模型优化,提出GSConv和Slim-Neck设计,以实现轻量级模型的高效检测。GSConv减小计算复杂度,保持准确性,适合实时任务。Slim-Neck结合GSConv优化架构,提高计算成本效益。在Tesla T4上,改进后的检测器以100FPS处理SODA10M数据集,mAP0.5达70.9%。论文和代码可在提供的链接中获取。文章还介绍了YOLOv8中GSConv的实现细节。更多配置信息见相关链接。
基于改进遗传算法的卡车和两架无人机旅行推销员问题(D2TSP)(Matlab代码实现)
基于改进遗传算法的卡车和两架无人机旅行推销员问题(D2TSP)(Matlab代码实现)
200 0
|
机器学习/深度学习 传感器 算法
【卡车无人机协同】基于遗传算法卡车和两架无人机配送路径规划附matlab代码
【卡车无人机协同】基于遗传算法卡车和两架无人机配送路径规划附matlab代码
|
域名解析 Ubuntu Perl
Ubuntu 快速更换阿里源
本文主要给大家讲解如何为Ubuntu更换阿里源,通过以下四个步骤即可快速实现换源。
60575 3
Ubuntu 快速更换阿里源
|
机器学习/深度学习 传感器 算法
【无人机编队】基于一阶一致性实现有领导多无人机协同编队控制附matlab仿真
【无人机编队】基于一阶一致性实现有领导多无人机协同编队控制附matlab仿真