Learn R Programming

⚠️There's a newer version (1.2-4) of this package.Take me there.

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 with

install.packages("TSP")

Current development version: Download package from AppVeyor or install from GitHub (needs devtools).

library("devtools")
install_github("mhahsler/TSP")

Usage

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.

References

Copy Link

Version

Install

install.packages('TSP')

Monthly Downloads

26,867

Version

1.1-10

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Michael Hahsler

Last Published

April 17th, 2020

Functions in TSP (1.1-10)

reformulate_ATSP_as_TSP

Reformulate a ATSP as a symmetric TSP
TOUR

Class TOUR -- Solution to a traveling salesperson problem
Concorde

Using the Concorde TSP Solver
TSP

Class TSP -- Symmetric traveling salesperson problem
TSPLIB

Read and write TSPLIB files
solve_TSP

TSP solver interface
tour_length

Calculate the length of a tour
ETSP

Class ETSP -- Euclidean traveling salesperson problem
ATSP

Class ATSP -- Asymmetric traveling salesperson problem
insert_dummy

Insert dummy cities into a distance matrix
USCA

USCA312/USCA50 -- 312/50 cities in the US and Canada
cut_tour

Cut a tour to form a path