| ATSP {TSP} | R Documentation |
Constructor to create an instance of the asymmetric traveling salesperson problem (ATSP) and some auxiliary methods.
## constructor
ATSP(x, labels = NULL)
## coercion
as.ATSP(object)
## methods
## S3 method for class 'ATSP'
n_of_cities(x)
## S3 method for class 'ATSP'
image(x, order, col = gray.colors(64), ...)
## S3 method for class 'ATSP'
labels(object, ...)
## S3 method for class 'ATSP'
print(x, ...)
x, object |
an object (a square matrix)
to be converted into an |
labels |
optional city labels. If not given, labels are taken
from |
col |
color scheme for image. |
order |
order of cities as an integer vector or an object of class
|
... |
further arguments are passed on. |
Objects of class ATSP are internally represented by a matrix
(use as.matrix() to get just the matrix).
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.
TOUR,
insert_dummy,
tour_length,
solve_TSP.
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)
tour_length(atsp)
tour_length(atsp, tour)
image(atsp, tour)