✅作者简介:热爱科研的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电子书和数学建模资料