ATSP

0th

Percentile

Class ATSP -- Asymmetric traveling salesperson problem

Constructor to create an instance of the asymmetric traveling salesperson problem (ATSP) and some auxiliary methods.

Keywords
classes
Usage
## constructor ATSP(x, labels = NULL)
## coercion as.ATSP(x)
## methods "n_of_cities"(x) "image"(x, order, col = gray.colors(64), ...) "labels"(object, ...) "print"(x, ...)
Arguments
x, object
an object (a square matrix) to be converted into an ATSP or, for the methods, an object of class ATSP.
labels
optional city labels. If not given, labels are taken from x.
col
color scheme for image.
order
order of cities as an integer vector or an object of class TOUR.
...
further arguments are passed on.
Details

Objects of class ATSP are internally represented by a matrix (use as.matrix() to get just the matrix).

ATSPs can be transformed into (larger) symmetric TSPs using reformulate_ATSP_as_TSP().

Value

ATSP() returns x as an object of class ATSP.n_of_cities() returns the number of cities in x.labels() returns a vector with the names of the cities in x.

See Also

TOUR, insert_dummy, tour_length, reformulate_ATSP_as_TSP, solve_TSP.

Aliases
  • ATSP
  • as.ATSP
  • as.ATSP.dist
  • as.ATSP.matrix
  • n_of_cities.ATSP
  • print.ATSP
  • labels.ATSP
  • image.ATSP
  • as.matrix
  • as.matrix.ATSP
Examples
data <- matrix(runif(10^2), ncol = 10, dimnames = list(1:10, 1:10))

atsp <- ATSP(data)
atsp

## use some methods
n_of_cities(atsp)
labels(atsp)

## calculate a tour
tour <- solve_TSP(atsp, method = "nn")
tour
  
tour_length(tour)

image(atsp, tour)
Documentation reproduced from package TSP, version 1.1-4, License: GPL-3

Community examples

Looks like there are no examples yet.