matlab解决多旅游商问题,MATLAB:多个旅行商问题MTSP算法 (1)

该MATLAB函数通过遗传算法寻找多个旅行商从起始位置到各城市并返回的最短路线。每个旅行商从第一个点开始,结束于第一个点,但途中访问一组独特的城市,除了第一个点外,每个城市只被一个旅行商访问。函数接受城市位置、距离矩阵、旅行商数量、最小旅行距离等参数,并输出最佳路线、路线断点和总旅行距离。
摘要由CSDN通过智能技术生成

Fixed Start/End Point Multiple Traveling Salesmen Problem - Genetic Algorithm

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

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

%   Finds a (near) optimal solution to a variation of the 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 individual cities

%   and back to the original starting place)

%

% Summary:

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

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

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

%

% Note: The Fixed Start/End location is taken to be the first 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/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 10 3 7], brks = [3 7]

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值