Code covered by the BSD License  

Highlights from
Multiple Variable Traveling Salesmen Problem - Genetic Algorithm

Be the first to rate this file! 44 Downloads (last 30 days) File Size: 4 KB File ID: #21298
image thumbnail

Multiple Variable Traveling Salesmen Problem - Genetic Algorithm

by

 

02 Sep 2008 (Updated )

Finds a near-optimal solution to a variation of the MTSP with variable number of salesmen using a GA

| Watch this File

File Information
Description

MTSPV_GA Variable Multiple Traveling Salesman Problem (M-TSP) Genetic Algorithm (GA)
Finds a (near) optimal solution to a variation of the M-TSP (that has a
variable number of salesmen) by setting up a GA to search for the
shortest route (least distance needed for the salesmen to travel to
each city exactly once and return to their starting locations)

Summary:
1. Each salesman travels to a unique set of cities and completes the
route by returning to the city he started from
2. Each city is visited by exactly one salesman

Input:
XY (float) is an Nx2 matrix of city locations, where N is the number of cities
DMAT (float) is an NxN matrix of point to point distances or costs
MINTOUR (scalar integer) is the minimum tour length for any of the salesmen
POPSIZE (scalar integer) is the size of the population (should be divisible by 4)
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 1 4 2 8 10 3 7], brks = [3 7]
Taken together, these represent the solution [5 6 9][1 4 2 8][10 3 7],
which designates the routes for the 3 salesmen as follows:
. Salesman 1 travels from city 5 to 6 to 9 and back to 5
. Salesman 2 travels from city 1 to 4 to 2 to 8 and back to 1
. Salesman 3 travels from city 10 to 3 to 7 and back to 10

Example:
n = 35;
xy = 10*rand(n,2);
minTour = 3;
popSize = 40;
numIter = 5e3;
a = meshgrid(1:n);
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);
[optRoute,optBreak,minDist] = mtspv_ga(xy,dmat,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]));
minTour = 3;
popSize = 40;
numIter = 1e4;
a = meshgrid(1:n);
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);
[optRoute,optBreak,minDist] = mtspv_ga(xy,dmat,minTour,popSize,numIter,1,1);

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

Acknowledgements

Multiple Traveling Salesmen Problem Genetic Algorithm inspired this file.

This file inspired Mdmtspv Ga Multiple Depot Multiple Traveling Salesmen Problem Solved By Genetic Algorithm.

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 (3)
24 Nov 2012 Bharath

Could someone tell me where can I get the code for solving the same MTSP using ACO in MATLAB?

22 Oct 2012 Emmanuel Luevano

Hello, really great job!!!

Could you help me to change this example into simulink, please!

01 Oct 2008 The Author

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

Updates
02 Jun 2009

Added 3D capability.

07 Nov 2011

Minor cosmetic updates.

Contact us