[R] solve_TSP ignores control data, or I'm reading the help doc incorrectly.

Steven Lembark lembark at wrkhors.com
Sun May 30 17:09:21 CEST 2010


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_TSP

    Description:

         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



More information about the R-help mailing list