Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

benchmarkGeneratorTSP

Create (Asymmetric) Travelling Salesperson Problem (TSP) Benchmark


Description

Creates a benchmark function for the (Asymmetric) Travelling Salesperson Problem. Path (Do not return to start of tour. Start and end of tour not fixed.) or Cycle (Return to start of tour). Symmetry depends on supplied distance matrix.

Usage

benchmarkGeneratorTSP(distanceMatrix, type = "Cycle")

Arguments

distanceMatrix

Matrix that collects the distances between travelled locations.

type

Can be "Cycle" (return to start, default) or "Path" (no return to start).

Value

the function of type cost=f(permutation)

See Also

Examples

set.seed(1)
#create 5 random locations to be part of a tour
n=5
cities <- matrix(runif(2*n),,2)
#calculate distances between cities
cdist <- as.matrix(dist(cities))
#create objective functions (for path or cycle)
fun1 <- benchmarkGeneratorTSP(cdist, "Path") 
fun2 <- benchmarkGeneratorTSP(cdist, "Cycle") 
#evaluate
fun1(1:n)
fun1(n:1)
fun2(n:1)
fun2(1:n)

CEGO

Combinatorial Efficient Global Optimization

v2.4.0
GPL (>= 3)
Authors
Martin Zaefferer <mzaefferer@gmail.com>
Initial release
2019-12-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.