TSP Info
TSP Info
Gerhard Reinelt
Universitat Heidelberg
Institut fur Angewandte Mathematik
Im Neuenheimer Feld 294
D-69120 Heidelberg
[email protected]
TSPLIB is a library of sample instances for the TSP (and related problems) from various
sources and of various types. Instances of the following problem classes are available.
Symmetric traveling salesman problem (TSP)
Given a set of n nodes and distances for each pair of nodes, find a roundtrip of minimal
total length visiting each node exactly once. The distance from node i to node j is the
same as from node j to node i.
Hamiltonian cycle problem (HCP)
Given a graph, test if the graph contains a Hamiltonian cycle or not.
Asymmetric traveling salesman problem (ATSP)
Given a set of n nodes and distances for each pair of nodes, find a roundtrip of minimal
total length visiting each node exactly once. In this case, the distance from node i to node
j and the distance from node j to node i may be different.
Sequential ordering problem (SOP)
This problem is an asymmetric traveling salesman problem with additional constraints.
Given a set of n nodes and distances for each pair of nodes, find a Hamiltonian path from
node 1 to node n of minimal length which takes given precedence constraints into account.
Each precedence constraint requires that some node i has to be visited before some other
node j.
Capacitated vehicle routing problem (CVRP)
We are given n 1 nodes, one depot and distances from the nodes to the depot, as well as
between nodes. All nodes have demands which can be satisfied by the depot. For delivery
to the nodes, trucks with identical capacities are available. The problem is to find tours for
the trucks of minimal total length that satisfy the node demands without violating truck
capacity constraint. The number of trucks is not specified. Each tour visits a subset of the
nodes and starts and terminates at the depot. (Remark: In some data files a collection of
alternate depots is given. A CVRP is then given by selecting one of these depots.)
Except, for the Hamiltonian cycle problems, all problems are defined on a complete graph
and, at present, all distances are integer numbers. There is a possibility to require that
certain edges appear in the solution of a problem.
1
1. The file format
Each file consists of a specification part and of a data part. The specification part
contains information on the file format and on its contents. The data part contains explicit
data.
All entries in this section are of the form <keyword> : <value>, where <keyword> de-
notes an alphanumerical keyword and <value> denotes alphanumerical or numerical data.
The terms <string>, <integer> and <real> denote character string, integer or real data,
respectively. The order of specification of the keywords in the data file is arbitrary (in
principle), but must be consistent, i.e., whenever a keyword is specified, all necessary in-
formation for the correct interpretation of the keyword has to be known. Below we give a
list of all available keywords.
1.1.1 NAME : <string>
Identifies the data file.
1.1.2 TYPE : <string>
Specifies the type of the data. Possible types are
TSP Data for a symmetric traveling salesman problem
ATSP Data for an asymmetric traveling salesman problem
SOP Data for a sequential ordering problem
HCP Hamiltonian cycle problem data
CVRP Capacitated vehicle routing problem data
TOUR A collection of tours
1.1.3 COMMENT : <string>
Additional comments (usually the name of the contributor or creator of the problem in-
stance is given here).
1.1.4 DIMENSION : <integer>
For a TSP or ATSP, the dimension is the number of its nodes. For a CVRP, it is the total
number of nodes and depots. For a TOUR file it is the dimension of the corresponding
problem.
1.1.5 CAPACITY : <integer>
Specifies the truck capacity in a CVRP.
1.1.6 EDGE WEIGHT TYPE : <string>
Specifies how the edge weights (or distances) are given. The values are
EXPLICIT Weights are listed explicitly in the corresponding section
EUC 2D Weights are Euclidean distances in 2-D
EUC 3D Weights are Euclidean distances in 3-D
2
MAX 2D Weights are maximum distances in 2-D
MAX 3D Weights are maximum distances in 3-D
MAN 2D Weights are Manhattan distances in 2-D
MAN 3D Weights are Manhattan distances in 3-D
CEIL 2D Weights are Euclidean distances in 2-D rounded up
GEO Weights are geographical distances
ATT Special distance function for problems att48 and att532
XRAY1 Special distance function for crystallography problems (Version 1)
XRAY2 Special distance function for crystallography problems (Version 2)
SPECIAL There is a special distance function documented elsewhere
1.1.7 EDGE WEIGHT FORMAT : <string>
Describes the format of the edge weights if they are given explicitly. The values are
FUNCTION Weights are given by a function (see above)
FULL MATRIX Weights are given by a full matrix
UPPER ROW Upper triangular matrix (row-wise without diagonal entries)
LOWER ROW Lower triangular matrix (row-wise without diagonal entries)
UPPER DIAG ROW Upper triangular matrix (row-wise including diagonal entries)
LOWER DIAG ROW Lower triangular matrix (row-wise including diagonal entries)
UPPER COL Upper triangular matrix (column-wise without diagonal entries)
LOWER COL Lower triangular matrix (column-wise without diagonal entries)
UPPER DIAG COL Upper triangular matrix (column-wise including diagonal entries)
LOWER DIAG COL Lower triangular matrix (column-wise including diagonal entries)
1.1.7 EDGE DATA FORMAT : <string>
Describes the format in which the edges of a graph are given, if the graph is not complete.
The values are
EDGE LIST The graph is given by an edge list
ADJ LIST The graph is given as an adjacency list
1.1.9 NODE COORD TYPE : <string>
Specifies whether coordinates are associated with each node (which, for example may be
used for either graphical display or distance computations). The values are
TWOD COORDS Nodes are specified by coordinates in 2-D
THREED COORDS Nodes are specified by coordinates in 3-D
NO COORDS The nodes do not have associated coordinates
The default value is NO COORDS.
1.1.10 DISPLAY DATA TYPE : <string>
Specifies how a graphical display of the nodes can be obtained. The values are
COORD DISPLAY Display is generated from the node coordinates
TWOD DISPLAY Explicit coordinates in 2-D are given
NO DISPLAY No graphical display is possible
The default value is COORD DISPLAY if node coordinates are specified and NO DISPLAY
otherwise.
3
1.1.11 EOF :
Depending on the choice of specifications some additional data may be required. These
data are given in corresponding data sections following the specification part. Each data
section begins with the corresponding keyword. The length of the section is either implicitly
known from the format specification, or the section is terminated by an appropriate end-
of-section identifier.
1.2.1 NODE COORD SECTION :
Node coordinates are given in this section. Each line is of the form
<integer> <real> <real>
if NODE COORD TYPE is TWOD COORDS, or
<integer> <real> <real> <real>
if NODE COORD TYPE is THREED COORDS. The integers give the number of the respective
nodes. The real numbers give the associated coordinates.
1.2.2 DEPOT SECTION :
The demands of all nodes of a CVRP are given in the form (per line)
<integer> <integer>
The first integer specifies a node number, the second its demand. The depot nodes must
also occur in this section. Their demands are 0.
1.2.4 EDGE DATA SECTION :
Edges of a graph are specified in either of the two formats allowed in the EDGE DATA FORMAT
entry. If the type is EDGE LIST, then the edges are given as a sequence of lines of the form
<integer> <integer>
each entry giving the terminal nodes of some edge. The list is terminated by a 1.
If the type is ADJ LIST, the section consists of a list of adjacency lists for nodes. The
adjacency list of a node x is specified as
<integer> <integer> . . . <integer> 1
where the first integer gives the number of node x and the following integers (terminated
by 1 ) the numbers of nodes adjacent to x. The list of adjacency lists is terminated by
an additional 1.
4
1.2.5 FIXED EDGES SECTION :
In this section, edges are listed that are required to appear in each solution to the problem.
The edges to be fixed are given in the form (per line)
<integer> <integer>
meaning that the edge (arc) from the first node to the second node has to be contained in
a solution. This section is terminated by a 1.
1.2.6 DISPLAY DATA SECTION :
If DISPLAY DATA TYPE is TWOD DISPLAY, the 2-dimensional coordinates from which a display
can be generated are given in the form (per line)
<integer> <real> <real>
The integers specify the respective nodes and the real numbers give the associated coordi-
nates.
1.2.7 TOUR SECTION :
A collection of tours is specified in this section. Each tour is given by a list of integers giving
the sequence in which the nodes are visited in this tour. Every such tour is terminated by
a 1. An additional 1 terminates this section.
1.2.8 EDGE WEIGHT SECTION :
The edge weights are given in the format specified by the EDGE WEIGHT FORMAT entry. At
present, all explicit data is integral and is given in one of the (self-explanatory) matrix
formats. with implicitly known lengths.
5
2. The distance functions
For the various choices of EGDE WEIGHT TYPE, we now describe the computations of the rep-
sective distances. In each case we give a (simplified) C-implementation for computing the
distances from the input coordinates. All computations involving floating-point numbers
are carried out in double precision arithmetic. The integers are assumed to be represented
in 32-bit words. Since distances are required to be integral, we round to the nearest inte-
ger (in most cases). Below we have used the rounding function nint (nint(x) can be
replaced by (int) (x+0.5)).
For edge weight type EUC 2D and EUC 3D, floating point coordinates must be specified for
each node. Let x[i], y[i], and z[i] be the coordinates of node i.
In the 2-dimensional case the distance between two points i and j is computed as follows:
xd = x[i] - x[j];
yd = y[i] - y[j];
dij = nint( sqrt( xd*xd + yd*yd) );
In the 3-dimensional case we have:
xd = x[i] - x[j];
yd = y[i] - y[j];
zd = z[i] - z[j];
dij = nint( sqrt( xd*xd + yd*yd + zd*zd) );
where sqrt is the C square root function.
Distances are given as Manhattan distances if the edge weight type is MAN 2D or MAN 3D.
They are computed as follows.
2-dimensional case:
xd = abs( x[i] - x[j] );
yd = abs( y[i] - y[j] );
dij = nint( xd + yd );
3-dimensional case:
xd = abs( x[i] - x[j] );
yd = abs( y[i] - y[j] );
zd = abs( z[i] - z[j] );
dij = nint( xd + yd + zd );
Maximum distances are computed if the edge weight type is MAX 2D or MAX 3D.
2-dimensional case:
xd = abs( x[i] - x[j] );
yd = abs( y[i] - y[j] );
dij = max( nint( xd ), nint( yd ) ) );
6
3-dimensional case:
xd = abs( x[i] - x[j] );
yd = abs( y[i] - y[j] );
zd = abs( z[i] - z[j] );
dij = max( nint( xd ), nint( yd ), nint( zd ) );
7
2.6 Ceiling of the Euclidean distance
The edge weight type CEIL 2D requires that the 2-dimensional Euclidean distances is
rounded up to the next integer.
We have included into TSPLIB the crystallography problems as described in [1]. These
problems are not explicitly given but subroutines are provided to generate the 12 problems
mentioned in this reference and subproblems thereof (see section 3.2).
To compute distances for these problems the movement of three motors has to be taken into
consideration. There are two types of distance functions: one that assumes equal speed
of the motors (XRAY1) and one that uses different speeds (XRAY2). The corresponding
distance functions are given as FORTRAN implementations (files deq.f, resp. duneq.f) in
the distribution file.
For obtaining integer distances, we propose to multiply the distances computed by the
original subroutines by 100.0 and round to the nearest integer.
We list our modified distance function for the case of equal motor speeds in the FORTRAN
version below.
INTEGER FUNCTION ICOST(V,W)
INTEGER V,W
DOUBLE PRECISION DMIN1,DMAX1,DABS
DOUBLE PRECISION DISTP,DISTC,DISTT,COST
DISTP=DMIN1(DABS(PHI(V)-PHI(W)),DABS(DABS(PHI(V)-PHI(W))-360.0E+0))
DISTC=DABS(CHI(V)-CHI(W))
DISTT=DABS(TWOTH(V)-TWOTH(W))
COST=DMAX1(DISTP/1.00E+0,DISTC/1.0E+0,DISTT/1.00E+0)
C *** Make integral distances ***
ICOST=AINT(100.0E+0*COST+0.5E+0)
RETURN
END
The numbers PHI(), CHI(), and TWOTH() are the respective x-, y-, and z-coordinates of
the points in the generated traveling salesman problems. Note, that TSPLIB95 contains
only the original distance computation without the above modification.
2.7 Verification
To verify correctness of the distance function implementations we give the length of some
canonical tours 1, 2, 3, . . . , n.
The canonical tours for pcb442, gr666, and att532 have lengths 221 440, 423 710, and
309 636, respectively.
The canonical tour for the problem xray14012 (the 8th problem considered in [21]) with
distance XRAY1 has length 15 429 219. With distance XRAY2 it has the length 12 943 294.
8
3. Description of the library files
In this section we give a list of all problem instances that are currently available together
with information on the length of optimal tours or lower and upper bounds for this length
(if available).
9
Name #cities Type Bounds
fl417 417 EUC 2D 11861
fl1400 1400 EUC 2D 20127
fl1577 1577 EUC 2D [22204,22249]
fl3795 3795 EUC 2D [28723,28772]
fnl4461 4461 EUC 2D 182566
fri26 26 MATRIX 937
gil262 262 EUC 2D 2378
gr17 17 MATRIX 2085
gr21 21 MATRIX 2707
gr24 24 MATRIX 1272
gr48 48 MATRIX 5046
gr96 96 GEO 55209
gr120 120 MATRIX 6942
gr137 137 GEO 69853
gr202 202 GEO 40160
gr229 229 GEO 134602
gr431 431 GEO 171414
gr666 666 GEO 294358
hk48 48 MATRIX 11461
kroA100 100 EUC 2D 21282
kroB100 100 EUC 2D 22141
kroC100 100 EUC 2D 20749
kroD100 100 EUC 2D 21294
kroE100 100 EUC 2D 22068
kroA150 150 EUC 2D 26524
kroB150 150 EUC 2D 26130
kroA200 200 EUC 2D 29368
kroB200 200 EUC 2D 29437
lin105 105 EUC 2D 14379
lin318 318 EUC 2D 42029
linhp318 318 EUC 2D 41345
nrw1379 1379 EUC 2D 56638
p654 654 EUC 2D 34643
pa561 561 MATRIX 2763
pcb442 442 EUC 2D 50778
pcb1173 1173 EUC 2D 56892
pcb3038 3038 EUC 2D 137694
pla7397 7397 CEIL 2D 23260728
pla33810 33810 CEIL 2D [65913275,66116530]
pla85900 85900 CEIL 2D [141904862,142487006]
10
Name #cities Type Bounds
pr76 76 EUC 2D 108159
pr107 107 EUC 2D 44303
pr124 124 EUC 2D 59030
pr136 136 EUC 2D 96772
pr144 144 EUC 2D 58537
pr152 152 EUC 2D 73682
pr226 226 EUC 2D 80369
pr264 264 EUC 2D 49135
pr299 299 EUC 2D 48191
pr439 439 EUC 2D 107217
pr1002 1002 EUC 2D 259045
pr2392 2392 EUC 2D 378032
rat99 99 EUC 2D 1211
rat195 195 EUC 2D 2323
rat575 575 EUC 2D 6773
rat783 783 EUC 2D 8806
rd100 100 EUC 2D 7910
rd400 400 EUC 2D 15281
rl1304 1304 EUC 2D 252948
rl1323 1323 EUC 2D 270199
rl1889 1889 EUC 2D 316536
rl5915 5915 EUC 2D [565040,565530]
rl5934 5934 EUC 2D [554070,556045]
rl11849 11849 EUC 2D [920847,923368]
si175 175 MATRIX 21407
si535 535 MATRIX 48450
si1032 1032 MATRIX 92650
st70 70 EUC 2D 675
swiss42 42 MATRIX 1273
ts225 225 EUC 2D 126643
tsp225 225 EUC 2D 3919
u159 159 EUC 2D 42080
u574 574 EUC 2D 36905
u724 724 EUC 2D 41910
u1060 1060 EUC 2D 224094
u1432 1432 EUC 2D 152970
u1817 1817 EUC 2D 57201
u2152 2152 EUC 2D 64253
u2319 2319 EUC 2D 234256
ulysses16 16 GEO 6859
ulysses22 22 GEO 7013
usa13509 13509 EUC 2D [19947008,19982889]
vm1084 1084 EUC 2D 239297
vm1748 1748 EUC 2D 336556
11
Crystallography problems
In the file xray.problems in directory tsp we distribute the routines written by Bland
and Shallcross and the necessary data to generate the crystallography problems discussed
in [1]. The file xray.problems is one file into which the single files mentioned in the sequel
have been merged. These single files have to be extracted from xray.problems using an
editor. The following original files are provided
read.me deq.f duneq.f daux.f gentsp.f
a.data b.data d.data e.data f.data
In addition we have included specially prepared data files to generate the 12 problems
mentioned in [1]. The files have the names xray1.data through xray12.data.
Using these data files 12 symmetric TSPs can be generated using the program gentsp.f.
We propose to name the respective problem instances xray4472, xray2950, xray7008,
xray2762, xray6922, xray9070, xray5888, xray14012, xray5520, xray13804, xray14464,
and xray13590.
To verify the correct use of the generating routines we list part of the file xray14012.tsp.
NAME : xray14012
COMMENT : Crystallography problem 8 (Bland/Shallcross)
TYPE : TSP
DIMENSION : 14012
EDGE WEIGHT TYPE : XRAY2
NODE COORD SECTION
Every instance contains a Hamiltonian cycle which is given in the corresponding .opt.tour
file. In problem instance alb4000 two edges are fixed.
In addition to these files, the directory contains the C-program tspleap.c by M. Junger
and G. Rinaldi. This program can be used to generate TSP instances (in TSPLIB format)
12
originating from the problem of deciding whether an (r,s)-leaper on a mxn chess board can
start at some square of the board, visit each square exactly once, and return to its starting
square. A detailed documentation is given in the file tspleap.c.
13
it is implied that i has to precede k and, therefore, also Cki has to be set to 1. Because
we require, that node 1 is the first node and node n is the last node in each feasible path,
a SOP problem instance always has Ci1 = 1, for all i = 2, . . . , n, and Cnj = 1, for all
j = 1, . . . , n 1. The entry C1n is set to infinity. All other entries of C are nonnegative
integer values.
14
Table 3 lists the SOP instances (in directory sop) together with their known lower and
upper bounds for the optimal path length. The names of the corresponding data files are
obtained by appending the suffix .sop to the problem name.
Various problems can be defined on these data sets, e.g., depending on whether the number
of vehicles is fixed, so we do not list optimal solutions here. Some values are given in the
data files themselves.
4. Remarks
1. The problem lin318 is originally a Hamiltonian path problem. One obtains this prob-
lem by adding the additional requirement that the edge from 1 to 214 is contained in
the tour. The data is given in linhp318.tsp.
2. Some data sets are referred to by different names in the literature. Below we give the
corresponding names used in [3] and [2].
TSPLIB [3] [2] TSPLIB [3] [2]
att48 ATT048 - att532 ATT532 -
dantzig42 - 42 eil101 EIL10 -
eil51 EIL08 - eil76 EIL09 -
gil262 GIL249 - gr120 - 120
gr137 GH137 137 gr202 GH202 202
gr229 GH229 229 gr431 GH431 431
gr666 GH666 666 gr96 GH096 96
hk48 - 48H kroA100 KRO124 100A
kroB100 KRO125 100B kroC100 KRO126 100C
kroD100 KRO127 100D kroE100 KRO128 100E
15
kroA150 KRO30 - kroB150 KRO31 -
kroA200 KRO32 - kroB200 KRO33 -
lin105 LK105 - lin318 LK318 -
linhp318 LK318P - pr1002 TK1002 -
pr107 TK107 - pr124 TK124 -
pr136 TK136 - pr144 TK144 -
pr152 TK152 - pr226 TK226 -
pr2392 TK2392 - pr264 TK264 -
pr299 TK299 - pr439 TK439 -
pr76 TK076 - st70 KRO070 70
3. Some vehicle routing problems are also available in a TSP version. Here the depots are
just treated as normal nodes. The problem gil262 originally contained two identical
nodes, of which one was eliminated.
4. Potential contributors to this library should provide their data files in appropriate
format and contact
Gerhard Reinelt
Institut fur Angewandte Mathematik, Universitat Heidelberg
Im Neuenheimer Feld 294, D-69120 Heidelberg
Germany
Tel (6221) 56 3171
Fax (6221) 56 5634
E-Mail [email protected]
5.Informations on new bounds or optimal solutions for library problems as well as ref-
erences to computational studies (to be included in the list of references) are also
appreciated.
5. Access
TSPLIB is available at
http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/
References
1. R.E. Bland & D.F. Shallcross (1989). Large Traveling Salesman Problems Arising
from Experiments in X-ray Crystallography: A Preliminary Report on Computation,
Operations Research Letters 8, 125128.
2. M. Grotschel & O. Holland (1991). Solution of Large-Scale Symmetric Travelling
Salesman Problems, Mathematical Programming 51, 141202.
3. M.W. Padberg & G. Rinaldi (1991). A Branch & Cut Algorithm for the Resolution
of Large-scale Symmetric Traveling Salesman Problems, SIAM Review 33, 60100.
16