Code covered by the BSD License  

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

3.66667

3.7 | 3 ratings Rate this file 45 Downloads (last 30 days) File Size: 4.27 KB File ID: #21299
image thumbnail

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

by

 

02 Sep 2008 (Updated )

Finds a near-optimal solution to a variation of the M-TSP with fixed endpoints using a GA

| Watch this File

File Information
Description

MTSPF_GA Fixed Multiple Traveling Salesman 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
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/end 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
SHOWRESULT (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][1 4 2 8 10 1][1 3 7 1],
which designates the routes for the 3 salesmen as follows:
. Salesman 1 travels from city 1 to 5 to 6 to 9 and back to 1
. Salesman 2 travels from city 1 to 4 to 2 to 8 to 10 and back to 1
. Salesman 3 travels from city 1 to 3 to 7 and back to 1

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] = mtspf_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] = mtspf_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] = mtspf_ga(xyz,dmat,nSalesmen,minTour,popSize,numIter,1,1);

Acknowledgements

Multiple Traveling Salesmen Problem Genetic Algorithm inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
19 Feb 2014 Joseph Kirk

@sukanya, why don't you just download the file? And a rating of 1 when you apparently haven't even used the code seems a little premature, no?

19 Feb 2014 sukanya

i need coding for
Fixed Start/End Point Multiple Traveling Salesmen Problem - Genetic Algorithm

03 Jan 2014 Joseph Kirk

@Pedro, yes the notes are in error. They will be fixed shortly.

30 Dec 2013 Pedro p

Thanks Joseph for this submission, It works great for me, from what i understand of how the algorithm works where it says:

"""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][1 10 3 7 1]"""

Shouldn't it say brks = [3 6]?

11 May 2013 Albert

Could you please tell me how i
can edit the number of points that a salesman visits at MOST ? ( Because each salesman has a limit)

I mean, I want to add this input:

MAX_TOUR (scalar integer) is the maximum tour length for any of the
salesmen, NOT including the start/end point

MINTOUR constraint will remain and MAX_TOUR constraint will be added.
Thanks a lot in advance.

01 Oct 2008 The Author

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

15 Sep 2008 barki yak

Thanks alot, it works superb! but could you please tell me how i can edit the number of points that a salesman visit at least? its "2" in your work but i couldnt manage to increase that number

Updates
03 Sep 2008

updated description

08 Sep 2008

updated title

02 Jun 2009

Added 3D capability.

07 Nov 2011

Bug fix. Minor cosmetic updates.

03 Jan 2014

Corrected the route/break details in the comment section.

03 Jan 2014

Removed waitbar.

Contact us