solve_TSP {tsp} | R Documentation |
Common interface to all symmetric TSP solvers in this package.
solve_TSP(x, method, options, ...)
x |
the TSP given as an object of class TSP . |
method |
method to solve the TSP (default: farthest insertion algorithm; see details). |
options |
a list of arguments passed on to the TSP solver
selected by method . |
... |
further arguments (currently unused). |
Currently the following methods are available:
"nearest_insertion", "farthest_insertion"
The two algorithms are variants of the minimum spanning tree algorithm for obtaining solutions to the traveling salesperson problem. The distances between cities are stored in a distance matrix D with elements d(i,j).
The nearest insertion algorithm starts with a partial tour consisting of a single, arbitrarily chosen city. As long as not all cities are on the tour, find the city k which is nearest to a city on the tour. Next insert city k into the tour between two consecutive cities i and j, such that d(i,k) + d(k,j) - d(i,j) is minimized. Repeat till all cities are on the tour.
The farthest insertion algorithm used the farthest instead of the nearest city. The idea behind this choice is to link cities far away into the tour fist to establish an outline of the whole tour early.
Additional options: start
index of the first city
(default: random city)
"greedy"
The algorithm starts with a tour containing a random city. Then the algorithm always adds to last city in the tour the nearest not yet visited city. The algorithm stops when all cities are on the tour.
Additional options: start
index of the first city
(default: random city)
"concorde"
Concorde is an advanced TSP solver. The program is not included in
this package and has to be obtained and installed separately (see
tsp_concorde_help
).
Additional options:
exe
character string containing the path to the executable
(see tsp_concorde_help
)
clo
character string containing command line options for
Concorde, e.g., options = list(clo = "-B -v")
. See
tsp_concorde_help
on how to obtain a complete list of available
command line options.
precision
an integer which controls the number of
decimal places used for the internal representation of distances in Concorde.
The values given in x
are multiplied by 10^{precision} before
being passed on to Concorde. Note that therefore the results produced by
Concorde (especially lower and upper bounds) need to be divided by
10^{precision} (i.e., the decimal point has to be shifted
precision
placed to the left). Note also, that Concorde cannot handle
Inf
which is therefore replaced by 2 times the maximum value in x
(ignoring the infinity entries). The interface to Concorde uses
write_TSPLIB
(see there for more information).
An object of class TOUR
.
Concorde home page http://www.tsp.gatech.edu/concorde/
David Appletgate, Robert Bixby, Vasek Chvatal, William Cook (2001): TSP cuts which do not conform to the template paradigm, Computational Combinatorial Optimization, M. Junger and D. Naddef (editors), Springer.
D. S. Johnson, C. H. Papadimitriou (1985): Performance guarantees for heuristics (chapter 5). In: E. L. Lawler, J. K. Lenstra, A.H.G. Rinnooy Kan, D. B. Shmoys (eds.) The traveling salesman problem - A guided tour of combinatorial optimization, Wiley & Sons.
TOUR
,
TSP
,
write_TSPLIB
,
tsp_concorde_help
.
data("iris") ## create TSP tsp <- TSP(dist(iris[1:4])) ## reorder tour1 <- solve_TSP(tsp) tour2 <- solve_TSP(tsp, method = "nearest_insertion") tour3 <- solve_TSP(tsp, method = "greedy", options = list(start = 1)) tour1 tour2 tour3 ## use the external solver which has to be installed separately ## Not run: tour4 <- solve_TSP(tsp, method = "concorde") tour4 ## End(Not run)