Learn R Programming

tspmeta (version 1.2)

run_solver: Runs a solver on a TSP instance.

Description

Currently the following solvers are supported: nearest_insertion: See solve_TSP. farthest_insertion : See solve_TSP. cheapest_insertion : See solve_TSP. arbitrary_insertion: See solve_TSP. nn: See solve_TSP. repetitive_nn: See solve_TSP. concorde: See solve_TSP.

Usage

run_solver(x, method, ...)

Arguments

x
[tsp_instance] TSP instance.
method
[character(1)] Solver to use on TSP instance. To use concorde and/or linkern it is necessary to specify the path to the concorde/linkern executable with concorde_path.
...
[any] Control parameters for solver.

Value

[TOUR] TOUR object from package TSP, containing order of cities, tour length and method name that generated this solution.

Examples

Run this code
x = random_instance(10)
tours = sapply(c("nn", "cheapest_insertion", "arbitrary_insertion"), function(solver) {
  list(solver = run_solver(x, method = solver))
})
## Not run: 
#   concorde_path(path = "/absolute/path/to/concorde/executable")
#   concorde_tour = run_solver(x, method = "concorde")
#   concorde_tour = run_solver(x, method = "linkern")
# ## End(Not run)

Run the code above in your browser using DataLab