TSP - Traveling Salesperson Problem - R package
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.
Installation
- Stable CRAN version: install from within R.
- Current development version: Download package from AppVeyor or install via
intall_github("mhahsler/TSP")
(requires R packagedevtools
)
Example
This example loads a data set with 312 cities (USA and Canada) and
## load library and read data
R> library("TSP")
R> data("USCA312")
## create a TSP object from the data
R> tsp <- TSP(USCA312)
R> tsp
object of class 'TSP'
312 cities (distance 'euclidean')
## find a tour using the default heuristic
R> tour <- solve_TSP(tsp)
R> 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.
Further Information
- Michael Hahsler and Kurt Hornik, TSP - Infrastructure for the Traveling Salesperson Problem, Journal of Statistical Software, 22(2), 2007.
- TSP package vignette with complete examples.
- Reference manual
- Concorde TSP solver home page