Monday, June 19, 2017

Lin-Kernighan algorithm basics – part 6

proc Make_4opt_Move(c1, c2, c3, c4, c5, c6, c7, c8: City_Number;
                    tourOrder: int) =

  case tourOrder # all 20 cases of sequential 4-opt move

  of TO_12783465, TO_12786534:
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c1, c2, c8, c5)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_12873465, TO_12875634, TO_12438756, TO_12564387:
    ExchangeLinks(c1, c2, c8, c7)
    ExchangeLinks(c2, c7, c3, c4)
    ExchangeLinks(c4, c7, c5, c6)

  of TO_12563487:
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c8, c5)

  of TO_12568734, TO_12658743:
    ExchangeLinks(c1, c2, c8, c7)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_12653487:
    ExchangeLinks(c1, c2, c8, c7)
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_12657834:
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c1, c2, c8, c7)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_12437856:
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c1, c2, c8, c7)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_12784356, TO_12785643, TO_12657843:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c8, c7)
    ExchangeLinks(c4, c7, c5, c6)

  of TO_12874356, TO_12436587:
    ExchangeLinks(c1, c2, c8, c7)
    ExchangeLinks(c2, c7, c5, c6)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_12437865, TO_12874365, TO_12568743:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c6, c5)
    ExchangeLinks(c1, c6, c8, c7)

  else:
    echo "Unknown 4-opt move: ", tourOrder
    quit 1

Note that each of all possible sequential pure 4-opt moves is equivalent to a sequence of exactly three 2-opts. Even 12-56-34-87 which can be described as symmetric 3-opt (which is equal to three 2-opts) plus subsequent 2-opt. Moreover, these 4-opt moves together with symmetric 3-opt move make a set of all k-opt sequential moves that are equivalent to some sequence of exactly three 2-opts.

No comments:

Post a Comment