Code covered by the BSD License  

Highlights from
Fixed Start Open Multiple Traveling Salesmen Problem - Genetic Algorithm

5.0

5.0 | 1 rating Rate this file 30 Downloads (last 30 days) File Size: 4.28 KB File ID: #21302
image thumbnail

Fixed Start Open Multiple Traveling Salesmen Problem - Genetic Algorithm

by Joseph Kirk

 

02 Sep 2008 (Updated 07 Nov 2011)

Finds a near-optimal solution to a "open" variation of the M-TSP with fixed start points using a GA

| Watch this File

File Information
Description

MTSPOFS_GA Fixed Start Open Multiple Traveling Salesman 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 without returning to the starting location)

Summary:
1. Each salesman starts at the first point, but travels to a unique
set of cities after that (and none of them close their loops by
returning to their starting points)
2. Except for the first, each city is visited by exactly one salesman

Note: The Fixed Start 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
NSALESMEN (scalar integer) is the number of salesmen to visit the cities
MINTOUR (scalar integer) is the minimum tour length for any of the
salesmen, NOT including the start point
POPSIZE (scalar integer) is the size of the population (should be divisible by 8)
NUMITER (scalar integer) is the number of desired iterations for the algorithm to run
SHOWPROG (scalar logical) shows the GA progress if true
SHOWRES (scalar logical) shows the GA results if true

Output:
OPTRTE (integer array) is the best route found by the algorithm
OPTBRK (integer array) is the list of route break points (these specify the indices
into the route used to obtain the individual salesman routes)
MINDIST (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 4 2 8][1 10 3 7],
which designates the routes for the 3 salesmen as follows:
. Salesman 1 travels from city 1 to 5 to 6 to 9
. Salesman 2 travels from city 1 to 4 to 2 to 8
. Salesman 3 travels from city 1 to 10 to 3 to 7

Example:
n = 35;
xy = 10*rand(n,2);
nSalesmen = 5;
minTour = 3;
popSize = 80;
numIter = 5e3;
a = meshgrid(1:n);
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);
[optRoute,optBreak,minDist] = mtspofs_ga(xy,dmat,nSalesmen,minTour,popSize,numIter,1,1);

Example:
n = 50;
phi = (sqrt(5)-1)/2;
theta = 2*pi*phi*(0:n-1);
rho = (1:n).^phi;
[x,y] = pol2cart(theta(:),rho(:));
xy = 10*([x y]-min([x;y]))/(max([x;y])-min([x;y]));
nSalesmen = 5;
minTour = 3;
popSize = 80;
numIter = 1e4;
a = meshgrid(1:n);
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);
[optRoute,optBreak,minDist] = mtspofs_ga(xy,dmat,nSalesmen,minTour,popSize,numIter,1,1);

Example:
n = 35;
xyz = 10*rand(n,3);
nSalesmen = 5;
minTour = 3;
popSize = 80;
numIter = 5e3;
a = meshgrid(1:n);
dmat = reshape(sqrt(sum((xyz(a,:)-xyz(a',:)).^2,2)),n,n);
[optRoute,optBreak,minDist] = mtspofs_ga(xyz,dmat,nSalesmen,minTour,popSize,numIter,1,1);

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Multiple Traveling Salesmen Problem - Genetic Algorithm

Required Products MATLAB
MATLAB release MATLAB 7.13 (2011b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
01 Oct 2008 The Author

Update: The SINGLES parameter has been replaced with a more generalized MIN_TOUR.

16 Nov 2011 Iain

Joseph,

This is excellent and very close to the exact problem I would like to solve. My problem involves cable laying and cable routes I wanted to ask how hard / how would you implement the following two things?
1. In my problem the routes cannot cross paths. Each route must start from one city and go to the other cities but must not cross the path of any other route.
2. In my problem the cost of each leg of the route is slightly different. So for example the first leg of the route may cost 100% of the value in dmax but the second costs 125% and the third 150% etc. I don’t think I can implement this into the dmax input as I don’t know which distance / cost will be the first / second leg.

Any feedback on this would be much appreciated!

Thanks

Iain

Please login to add a comment or rating.
Updates
30 Sep 2008

Removed the SINGLES parameter and replaced it with a more generalized MIN_TOUR

02 Jun 2009

Added 3D capability.

07 Nov 2011

Bug fix. Minor cosmetic updates.

Tag Activity for this File
Tag Applied By Date/Time
optimization Joseph Kirk 22 Oct 2008 10:17:09
multiple traveling salesmen problem Joseph Kirk 22 Oct 2008 10:17:09
open variation Joseph Kirk 22 Oct 2008 10:17:09
fixed start Joseph Kirk 22 Oct 2008 10:17:09
fixed start Stu Monteleone 04 Jan 2011 19:03:57
multiple traveling salesmen problem Stu Monteleone 04 Jan 2011 19:04:03
open variation Stu Monteleone 04 Jan 2011 19:04:05

Contact us at files@mathworks.com