【路径规划】基于遗传算法求解固定的开放式多旅行推销员问题(M-TSP)附matlab代码

时间:2022-11-12 13:56:27

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进。

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

????个人信条:格物致知。

更多Matlab仿真内容点击????

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

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

⛄ 内容介绍

旅行商问题是一个经典的NP完全问题,多人旅行商问题的求解则更具挑战性.以往对求解多人旅行商问题的研究局限于以所有成员路径总和最小为优化标准,而对以所有成员路径最大值最小为优化标准的另一类多人旅行商问题却未加注意.文章给出了这两类多人旅行商问题的形式化描述,探讨了利用遗传算法求解这固定的开放式多旅行推销员问题(M-TSP)的基本思想和具体方案,进行了仿真实验验证.仿真实验数据表明,这是一种高效而且适应性强的多入旅行商问题求解方法.

⛄ 部分代码

function varargout = mtspof_ga(xy,dmat,salesmen,min_tour,pop_size,num_iter,show_prog,show_res)

% MTSPOF_GA Fixed Open Multiple Traveling Salesmen Problem (M-TSP) Genetic Algorithm (GA)

%   Finds a (near) optimal solution to a variation of the "open" M-TSP by

%   setting up a GA to search for the shortest route (least distance needed

%   for each salesman to travel from the start location to unique

%   individual cities and finally to the end location)

%

% Summary:

%     1. Each salesman starts at the first point, and ends at the last

%        point, but travels to a unique set of cities in between (none of

%        them close their loops by returning to their starting points)

%     2. Except for the first and last, each city is visited by exactly one salesman

%

% Note: The Fixed Start is taken to be the first XY point and the Fixed End

%     is taken to be the last XY point

%

% Input:

%     XY (float) is an Nx2 matrix of city locations, where N is the number of cities

%     DMAT (float) is an NxN matrix of city-to-city distances or costs

%     SALESMEN (scalar integer) is the number of salesmen to visit the cities

%     MIN_TOUR (scalar integer) is the minimum tour length for any of the

%         salesmen, NOT including the start point or end point

%     POP_SIZE (scalar integer) is the size of the population (should be divisible by 8)

%     NUM_ITER (scalar integer) is the number of desired iterations for the algorithm to run

%     SHOW_PROG (scalar logical) shows the GA progress if true

%     SHOW_RES (scalar logical) shows the GA results if true

%

% Output:

%     OPT_RTE (integer array) is the best route found by the algorithm

%     OPT_BRK (integer array) is the list of route break points (these specify the indices

%         into the route used to obtain the individual salesman routes)

%     MIN_DIST (scalar float) is the total distance traveled by the salesmen

%

% Route/Breakpoint Details:

%     If there are 10 cities and 3 salesmen, a possible route/break

%     combination might be: rte = [5 6 9 4 2 8 3 7], brks = [3 7]

%     Taken together, these represent the solution [1 5 6 9 10][1 4 2 8 10][1 3 7 10],

%     which designates the routes for the 3 salesmen as follows:

%         . Salesman 1 travels from city 1 to 5 to 6 to 9 to 10

%         . Salesman 2 travels from city 1 to 4 to 2 to 8 to 10

%         . Salesman 3 travels from city 1 to 3 to 7 to 10

%

% 2D Example:

%     n = 35;

%     xy = 10*rand(n,2);

%     salesmen = 5;

%     min_tour = 3;

%     pop_size = 80;

%     num_iter = 5e3;

%     a = meshgrid(1:n);

%     dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);

%     [opt_rte,opt_brk,min_dist] = mtspof_ga(xy,dmat,salesmen,min_tour, ...

%         pop_size,num_iter,1,1);

%

% 3D Example:

%     n = 35;

%     xyz = 10*rand(n,3);

%     salesmen = 5;

%     min_tour = 3;

%     pop_size = 80;

%     num_iter = 5e3;

%     a = meshgrid(1:n);

%     dmat = reshape(sqrt(sum((xyz(a,:)-xyz(a',:)).^2,2)),n,n);

%     [opt_rte,opt_brk,min_dist] = mtspof_ga(xyz,dmat,salesmen,min_tour, ...

%         pop_size,num_iter,1,1);

%

% See also: mtsp_ga, mtspf_ga, mtspo_ga, mtspofs_ga, mtspv_ga, distmat


⛄ 运行结果

【路径规划】基于遗传算法求解固定的开放式多旅行推销员问题(M-TSP)附matlab代码

【路径规划】基于遗传算法求解固定的开放式多旅行推销员问题(M-TSP)附matlab代码

⛄ 参考文献

[1]代坤, 鲁士文, 蒋祥刚. 基于遗传算法的多人旅行商问题求解[J]. 计算机工程, 2004, 30(16):3.

[2]温清芳. 遗传算法求解TSP问题的MATLAB实现[J]. 韶关学院学报, 2007, 28(6):5.

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