4.25

4.2 | 8 ratings Rate this file 340 downloads (last 30 days) File Size: 3.96 KB File ID: #19049

Multiple Traveling Salesmen Problem - Genetic Algorithm

by Joseph Kirk

 

04 Mar 2008 (Updated 02 Jun 2009)

Code covered by BSD License  

Finds a near-optimal solution to a M-TSP using a GA

Download Now | Watch this File

File Information
Description

MTSP_GA Multiple Traveling Salesman Problem (M-TSP) Genetic Algorithm (GA)
Finds a (near) optimal solution to the M-TSP 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 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
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 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);
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] = mtsp_ga(xy,dmat,salesmen,min_tour,pop_size,num_iter,1,1);

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Traveling Salesman Problem - Genetic Algorithm
This submission has inspired the following:
Multiple Variable Traveling Salesmen Problem - Genetic Algorithm, Fixed Start Open Multiple Traveling Salesmen Problem - Genetic Algorithm, Fixed Endpoints Open Multiple Traveling Salesmen Problem - Genetic Algorithm, Open Multiple Traveling Salesmen Problem - Genetic Algorithm, Fixed Start/End Point Multiple Traveling Salesmen Problem - Genetic Algorithm

MATLAB release MATLAB 7.3 (R2006b)
Zip File Content  
Other Files license.txt,
mtsp_ga.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
05 Mar 2008 John D'Errico

These are the submissions that I enjoy finding on the file exchange. This one does what it says it will do, and does it well. Good help. Good example.

There was only one irrelevant glitch - the waitbar on my machine was the wrong size. The end of the waitbar was cut off for some reason.

Despite that - well done.

13 Mar 2008 The Author

The waitbar glitch should be fixed.

23 Apr 2008 Ronald Halim

What a great calculation engine, really appreciate your work. I am one of Evolutionary Approach Fans too.

04 May 2008 wayne wang

nice ,great!

23 Jun 2008 Stefan Simon  
18 Aug 2008 Sumana Srinivasan

Neat tool. Easy to use.

24 Sep 2008 Erick Rojas

good tool but very simple and dont new approach

25 Sep 2008 João Silva

As far as I know, this is not a GA, at least not a classical one. But it is very useful as a trying tool with an evolutionary algorithm.

25 Sep 2008 The Author

João, I'm not using a binary string/word to represent the various possible solutions, if that's what you mean, but that doesn't exclude it from being a GA. GAs can take many forms, but they have (1) an abstract way of representing possible solutions (2) a method for evaluating the fitness or cost of a candidate solution (3) a population of candidate solutions (4) and a method of propagating good solutions while forming new (potentially better) solutions. This file has all of those.

01 Oct 2008 The Author

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

03 Oct 2008 venugopal rachakonda

good

Please login to add a comment or rating.
Updates
07 Mar 2008

Fixed waitbar issues.

02 Sep 2008

updated help notes, description

30 Sep 2008

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

02 Jun 2009

Added 3D capability.

Tag Activity for this File
Tag Applied By Date/Time
multiple traveling salesmen problem Joseph Kirk 22 Oct 2008 09:51:37
mtsp Joseph Kirk 22 Oct 2008 09:51:37
tsp Joseph Kirk 22 Oct 2008 09:51:37
genetic algorithm Joseph Kirk 01 Dec 2008 09:25:42
ga Joseph Kirk 01 Dec 2008 09:25:42
optimization Joseph Kirk 01 Dec 2008 09:25:42
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com