Basic infrastructure and some algorithms for the traveling
salesperson problem (also traveling salesman problem; TSP).
The package provides some simple algorithms and
an interface to the Concorde TSP solver and its implementation of the
Chained-Lin-Kernighan heuristic. The code for Concorde
itself is not included in the package and has to be obtained separately.
Hahsler and Hornik (2007)
This package provides the basic infrastructure and some algorithms for the traveling salesman problems (symmetric, asymmetric and Euclidean TSPs). The package provides some simple algorithms and an interface to the Concorde TSP solver and its implementation of the Chained-Lin-Kernighan heuristic.
Stable CRAN version: install from within R with
Current development version: Download package from AppVeyor or install from GitHub (needs devtools).
Load a data set with 312 cities (USA and Canada) and create a TSP object.
R> library("TSP")R> data("USCA312")R> tsp <- TSP(USCA312)R> tsp
object of class 'TSP' 312 cities (distance 'euclidean')
Find a tour using the default heuristic.
tour <- solve_TSP(tsp)tour
object of class 'TOUR' result of method 'arbitrary_insertion+two_opt' for 312 cities tour length: 40621
An online example application of TSP can be found on shinyapps.