Steven Lembark
2010-May-30 15:09 UTC
[R] solve_TSP ignores control data, or I'm reading the help doc incorrectly.
I read the documentation below to mean that: solve_TSP( tsp_input, '2-opt', rep=99 ) will use the 2-opt method on the tsp_input variable 99 times. Catch: I get an "unused input" error. Q: Am I reading the docs (Item 1, below) correctly or is this a problem with solve_TSP ignoring its inputs (Item 2, below). Item 1: solve_TSP doc:> library(TSP) > ?sove_TSPDescription: Common interface to all TSP solvers in this package. Usage: solve_TSP(x, method, control) Arguments: x: the TSP given as an object of class 'TSP' or 'ATSP'. method: method to solve the TSP (default: nearest insertion algorithm; see details). control: a list of arguments passed on to the TSP solver selected by 'method'. <snip> '"2-opt"' Two edge exchange improvement procedure (Croes 1958). This procedure systematically exchanges two edges in the graph represented by the distance matrix till no improvements are possible. Exchanging two edges is equal to reversing part of the tour. The resulting tour is called _2-optimal._ By default, improvement starts with a random tour. Additional control options: 'tour' an existing tour which should be improved. If no tour is given, a random tour is used. 'rep' number of times to try 2-opt with a different initial random tour (default: 1). Item 2: Failed execution > solve_TSP(tsp, method = '2-opt' ) object of class 'TOUR' result of method '2-opt' for 56 cities tour length: 5.681276 > solve_TSP(tsp, method = '2-opt', rep=56 ) Error in solve_TSP(tsp, method = "2-opt", rep = 56) : unused argument(s) (rep = 56) this isn't an artifact of the debugger since I get the same result without debug() setups. -- Steven Lembark 85-09 90th St. Workhorse Computing Woodhaven, NY, 11421 lembark at wrkhors.com +1 888 359 3508
Michael Hahsler
2010-May-31 20:32 UTC
[R] solve_TSP ignores control data, or I'm reading the help doc incorrectly.
the correct way to do it is solve_TSP(tsp, "2-opt", control=list(rep=56)) -Michael -- Dr. Michael Hahsler, Visiting Assistant Professor Department of Computer Science and Engineering Lyle School of Engineering Southern Methodist University, Dallas, Texas (214) 768-8878 * mhahsler at lyle.smu.edu * http://lyle.smu.edu/~mhahsler