Be the first to rate this file! 39 downloads (last 30 days) File Size: 3.16 KB File ID: #21197

Fixed Endpoints Open Traveling Salesman Problem - Genetic Algorithm

by Joseph Kirk

 

23 Aug 2008 (Updated 02 Jun 2009)

Code covered by the BSD License  

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

Download Now | Watch this File

File Information
Description

TSPOF_GA Fixed Open Traveling Salesman Problem (TSP) Genetic Algorithm (GA)
Finds a (near) optimal solution to a variation of the TSP by setting up a GA to search for the shortest route (least distance for the salesman to travel from a FIXED START to a FIXED END while visiting the other cities exactly once)

Summary:
1. A single salesman starts at the first point, ends at the last point, and travels to each of the remaining cities in between, but does not close the loop by returning to the city he started from
2. Each city is visited by the salesman exactly once

Note: The Fixed Start is taken to be the first XY point, and the Fixed End is taken to be the last XY point

Input:
XY (float) is an Nx2 (or Nx3) matrix of cities
DMAT (float) is an NxN matrix of point to point distances/costs
POP_SIZE (scalar integer) is the size of the population (should be divisible by 4)
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
MIN_DIST (scalar float) is the cost of the best route

Example:
n = 50;
xy = 10*rand(n,2);
a = meshgrid(1:n);
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);
pop_size = 60;
num_iter = 1e4;
show_prog = 1;
show_res = 1;
[opt_rte,min_dist] = tspof_ga(xy,dmat,pop_size,num_iter,show_prog,show_res);

Acknowledgements

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

MATLAB release MATLAB 7.6 (R2008a)
Zip File Content  
Other Files license.txt,
tspof_ga.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
02 Sep 2008

updated help notes, description

02 Jun 2009

Added 3D capability.

Tag Activity for this File
Tag Applied By Date/Time
optimization Joseph Kirk 22 Oct 2008 10:15:47
traveling salesman problem Joseph Kirk 22 Oct 2008 10:15:47
tsp Joseph Kirk 22 Oct 2008 10:15:47
open variation Joseph Kirk 22 Oct 2008 10:15:47
fixed endpoints Joseph Kirk 22 Oct 2008 10:15:47
 

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