solve_TSP                package:TSP                R Documentation

_T_S_P _s_o_l_v_e_r _i_n_t_e_r_f_a_c_e

_D_e_s_c_r_i_p_t_i_o_n:

     Common interface to all TSP solvers in this package.

_U_s_a_g_e:

     solve_TSP(x, method, control)

_A_r_g_u_m_e_n_t_s:

       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'.

_D_e_t_a_i_l_s:

     Currently the following methods are available: 

     '"_n_e_a_r_e_s_t__i_n_s_e_r_t_i_o_n"',  '"_f_a_r_t_h_e_s_t__i_n_s_e_r_t_i_o_n"', '"_c_h_e_a_p_e_s_t__i_n_s_e_r_t_i_o_n"',  '"_a_r_b_i_t_r_a_r_y__i_n_s_e_r_t_i_o_n"'  
          Nearest, farthest, cheapest and arbitrary insertion
          algorithms for a symmetric and asymmetric TSP (Rosenkrantz et
          al. 1977).  

          The distances between cities are stored in a distance matrix
          D with elements d(i,j).  All insertion algorithms start with
          a tour consisting of an arbitrary city and choose in each
          step a city k not yet on the tour. This city is inserted into
          the existing tour between two consecutive cities i and j,
          such that 

                       d(i,k) + d(k,j) - d(i,j)

          is minimized. The algorithms stops when all cities are on the
          tour.

          The nearest insertion algorithm chooses city k in each step
          as the city which is _nearest_ to a city on the tour.  

          For farthest insertion, the city k is chosen in each step as
          the city which is _farthest_ to any city on the tour.  

          Cheapest insertion chooses the city k such that the cost of
          inserting the new city (i.e., the increase in the tour's
          length) is minimal.  

          Arbitrary insertion chooses the city k randomly from all
          cities not yet on the tour.

          Nearest and cheapest insertion tries to build the tour using
          cities which fit well into the partial tour constructed so
          far.  The idea behind behind farthest insertion is to link
          cities far away into the tour fist to establish an outline of
          the whole tour early.

          Additional control options:  .in +5

     '_s_t_a_r_t' index of the first city (default: random city).


'"_n_n", "_r_e_p_e_t_i_t_i_v_e__n_n"' Nearest neighbor and repetitive nearest
     neighbor algorithms for symmetric and asymmetric TSPs (Rosenkrantz
     et al. 1977).

     The algorithm starts with a tour containing a random city. Then
     the algorithm always adds to the last city on the tour the nearest
     not yet visited city. The algorithm stops when all cities are on
     the tour. 

     Repetitive nearest neighbor constructs a nearest neighbor tour for
     each city as the starting point and returns the shortest tour
     found.

     Additional control options:  .in +5

'_s_t_a_r_t' index of the first city (default: random city). 


'"_2-_o_p_t"' 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: 

'_t_o_u_r' an existing tour which should be improved. If no tour is given,
     a random tour is used. 

'_r_e_p' number of times to try 2-opt with a different initial random tour
     (default: 1). 


'"_c_o_n_c_o_r_d_e"' Concorde algorithm (Applegate et al. 2001).

Concorde is an advanced exact TSP solver for _only symmetric_ TSPs
based on branch-and-cut.  The program is not included in this package
and has to be obtained and installed separately (see 'Concorde').

Additional control options: 

'_e_x_e' a character string containing the path to the executable  (see
     'Concorde').

'_c_l_o' a character string containing command line options for Concorde,
     e.g., 'control = list(clo = "-B -v")'. See 'concorde_help' on how
     to obtain a complete list of available command line options. 

'_p_r_e_c_i_s_i_o_n' an integer which controls the number of decimal places used
     for the internal representation of distances in Concorde. The
     values given in 'x' are multiplied by 10^{precision} before being
     passed on to Concorde. Note that therefore the results produced by
     Concorde (especially lower and upper bounds) need to be divided by
     10^{precision} (i.e., the decimal point has to be shifted
     'precision' placed to the left). Note also, that Concorde cannot
     handle 'Inf' which is therefore replaced by 2 times the maximum
     value in 'x' (ignoring the infinity entries). The interface to
     Concorde uses 'write_TSPLIB' (see there for more information).


'"_l_i_n_k_e_r_n"' Concorde's Chained Lin-Kernighan heuristic  (Applegate et
al. 2003).

The Lin-Kernighan (Lin and Kernighan 1973)  heuristic uses variable k
edge exchanges to improve an initial tour.  The program is not included
in this package and has to be obtained and installed separately (see
'Concorde').

Additional control options: see Concorde above. 


_V_a_l_u_e:

     An object of class 'TOUR'.

_R_e_f_e_r_e_n_c_e_s:

     Concorde home page, <URL: http://www.tsp.gatech.edu/concorde/>

     David Appletgate, Robert Bixby, Vasek Chvatal, William Cook
     (2001): TSP cuts which do not conform to the template paradigm,
     Computational Combinatorial Optimization, M. Junger and D. Naddef
     (editors), Springer.

     D. Applegate, W. Cook and A. Rohe (2003): Chained Lin-Kernighan
     for Large Traveling Salesman Problems.  _INFORMS Journal on
     Computing, 15(1):82-92._

     G.A. Croes (1958): A method for solving traveling-salesman
     problems. _Operations Research, 6(6):791-812._

     S. Lin and B. Kernighan (1973): An effective heuristic algorithm
     for the traveling-salesman problem. _Operations Research, 21(2):
     498-516._

     L.S. Pitsoulis and M.G.C. Resende (2001): Greedy randomized
     adaptive search procedures.  In P.M. Pardalos and M.G.C. Resende,
     editors, Handbook of Applied Optimization, pp. 168-181.

     D.J. Rosenkrantz, R. E. Stearns, and Philip M. Lewis II (1977): An
     analysis of several heuristics for the traveling salesman problem.
      _SIAM Journal on Computing, 6(3):563-581._

_S_e_e _A_l_s_o:

     'TOUR', 'TSP', 'ATSP', 'write_TSPLIB', 'Concorde'.

_E_x_a_m_p_l_e_s:

     data("USCA50")

     ## create TSP
     tsp <- USCA50

     ## methods
     methods <- c("nearest_insertion", "cheapest_insertion", "farthest_insertion", 
         "arbitrary_insertion", "nn", "repetitive_nn", "2-opt")

     ## calculate tours
     tours <- lapply(methods, FUN = function(m) solve_TSP(tsp, method = m))
     names(tours) <- methods

     ## use the external solver which has to be installed separately
     ## Not run: 
     tours$concorde  <- solve_TSP(tsp, method = "concorde")
     tours$linkern  <- solve_TSP(tsp, method = "linkern")
     ## End(Not run)

     ## show first tour
     tours[[1]]

     ## compare tour lengths
     opt <- 14497 # optained by concorde
     tour_lengths <- c(sapply(tours, FUN = attr, "tour_length"), optimal = opt) 
     dotchart(tour_lengths/opt*100-100, xlab = "percent excess over optimum")

