Friday, July 21, 2017

Extending LK: 5-opt move, part 2/3

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

  case tourOrder  # all 148 cases of sequential 5-opt move

  of TO_129A347856, TO_12569A3478, TO_129A785634, TO_12569A7834:
    ExchangeLinks(c1, c2, c9, c10)
    ExchangeLinks(c1, c9, c7, c8)
    ExchangeLinks(c1, c7, c5, c6)
    ExchangeLinks(c1, c5, c3, c4)
    ExchangeLinks(c1, c3, c10, c2)

  of TO_12A9347856, TO_129A563487, TO_12A9784356, TO_129A874356:
    ExchangeLinks(c8, c7, c9, c10)
    ExchangeLinks(c1, c2, c10, c7)
    ExchangeLinks(c2, c7, c5, c6)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_129A348756, TO_129A346587, TO_129A873465, TO_129A875634,
     TO_1243A97856, TO_12439A8756, TO_1256439A87:
    ExchangeLinks(c8, c7, c9, c10)
    ExchangeLinks(c1, c2, c10, c7)
    ExchangeLinks(c2, c7, c3, c4)
    ExchangeLinks(c4, c7, c5, c6)

  of TO_12A9348756, TO_12A9346587, TO_1278A93465, TO_12A9783465,
     TO_12A9657834, TO_1243A96578:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c3, c4)
    ExchangeLinks(c4, c9, c7, c8)
    ExchangeLinks(c4, c7, c5, c6)

  of TO_1278349A56:
    ExchangeLinks(c1, c2, c9, c10)
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c1, c9, c7, c8)
    ExchangeLinks(c1, c7, c3, c6)
    ExchangeLinks(c1, c3, c10, c2)

  of TO_127834A956, TO_12A9784365:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c2, c9, c3, c4)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_1287349A56:
    ExchangeLinks(c7, c8, c10, c9)
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c1, c2, c10, c7)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_128734A956, TO_12657834A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c2, c9, c7, c8)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_129A347865:
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c8, c7, c9, c10)
    ExchangeLinks(c1, c2, c10, c7)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_12A9347865, TO_12A9785634, TO_125643A978, TO_12568743A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c3, c4)
    ExchangeLinks(c4, c9, c5, c6)
    ExchangeLinks(c6, c9, c7, c8)

  of TO_12783465A9, TO_12438756A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c2, c9, c5, c8)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_1278349A65:
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c8, c5)
    ExchangeLinks(c1, c8, c10, c9)

  of TO_12873465A9, TO_127856A934, TO_12437856A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c3, c6, c8, c7)
    ExchangeLinks(c2, c9, c3, c8)

  of TO_1287349A65:
    ExchangeLinks(c7, c8, c10, c9)
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c6, c5)
    ExchangeLinks(c1, c6, c10, c7)

  of TO_12879A3465, TO_12879A6534:
    ExchangeLinks(c7, c8, c10, c9)
    ExchangeLinks(c6, c5, c7, c10)
    ExchangeLinks(c1, c2, c10, c5)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_1256349A78:
    ExchangeLinks(c1, c2, c9, c10)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c9, c5, c8)
    ExchangeLinks(c1, c5, c3, c4)
    ExchangeLinks(c1, c3, c10, c2)

  of TO_125634A978, TO_1256A93478, TO_12875634A9, TO_12874356A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c3, c4, c8, c5)
    ExchangeLinks(c2, c9, c3, c8)

  of TO_129A563478:
    ExchangeLinks(c1, c2, c9, c10)
    ExchangeLinks(c2, c10, c3, c4)
    ExchangeLinks(c1, c9, c7, c8)
    ExchangeLinks(c1, c7, c5, c6)
    ExchangeLinks(c1, c5, c10, c4)

  of TO_12A9563478, TO_12A9653487, TO_12784356A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c3, c4)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_12563487A9, TO_12569A3487, TO_12659A3478, TO_12659A7834,
     TO_1243A95687, TO_1243659A78, TO_12657843A9:
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c3, c4)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_1256349A87, TO_125687A943, TO_126578A943:
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c8, c5)
    ExchangeLinks(c1, c8, c10, c9)

  of TO_1278569A34:
    ExchangeLinks(c1, c2, c9, c10)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c1, c9, c7, c8)
    ExchangeLinks(c1, c7, c3, c6)
    ExchangeLinks(c1, c3, c10, c2)

  of TO_1287569A34:
    ExchangeLinks(c7, c8, c10, c9)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c1, c2, c10, c7)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_1287A95634, TO_12A9568734, TO_128743A956, TO_127843A965:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c3, c4)
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_1256A97834, TO_127865A943:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c2, c9, c3, c6)
    ExchangeLinks(c6, c9, c7, c8)

  of TO_12568734A9, TO_12658743A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c7, c8)
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_125687A934, TO_126578A934:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c4, c3, c5, c8)
    ExchangeLinks(c2, c9, c3, c8)

  of TO_12569A8734:
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c4, c3, c5, c8)
    ExchangeLinks(c2, c9, c3, c8)

  of TO_1265349A78, TO_12A9435687, TO_12A9436578:
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c5, c8)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_126534A978, TO_1265879A34, TO_12786534A9, TO_1278659A34,
     TO_12785643A9:
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c3, c6)
    ExchangeLinks(c6, c9, c7, c8)

  of TO_1265A93478, TO_1256A94378:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c7, c8)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_129A653478:
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c10, c9)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_12A9653478, TO_12653487A9, TO_126587A934, TO_12436587A9:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c7, c8)
    ExchangeLinks(c2, c7, c5, c6)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_1265349A87, TO_1278A96534, TO_1278569A43, TO_1278A95643:
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c1, c2, c6, c3)
    ExchangeLinks(c1, c6, c8, c7)
    ExchangeLinks(c1, c8, c10, c9)

  of TO_1265A93487, TO_128756A943:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c4, c3, c5, c8)
    ExchangeLinks(c2, c9, c3, c8)

  of TO_129A658734:
    ExchangeLinks(c8, c7, c9, c10)
    ExchangeLinks(c1, c2, c10, c7)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_12A9658734, TO_12A9564378:
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c7, c8)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_129A786534:
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c8, c5, c9, c10)
    ExchangeLinks(c1, c2, c10, c5)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_1287A96534, TO_124378A956, TO_1278A94356, TO_124387A965:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c2, c9, c5, c8)
    ExchangeLinks(c2, c5, c3, c4)

  of TO_12439A5687:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c8, c7, c9, c10)
    ExchangeLinks(c1, c4, c10, c7)
    ExchangeLinks(c4, c7, c5, c6)

  of TO_129A435687, TO_129A437856, TO_12879A4356, TO_124365A978,
     TO_12437865A9, TO_12874365A9, TO_129A564378, TO_129A568743,
     TO_12879A5643, TO_12659A4387, TO_1265879A43, TO_1278659A43:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c10, c9)
    ExchangeLinks(c4, c9, c5, c6)
    ExchangeLinks(c6, c9, c7, c8)

  of TO_1243879A56, TO_1278439A56:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c1, c4, c10, c9)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_12A9438756:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c2, c9, c3, c6)
    ExchangeLinks(c6, c9, c7, c8)

  of TO_12439A6578, TO_12439A7865, TO_1243879A65, TO_1278439A65:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c6, c5)
    ExchangeLinks(c1, c6, c10, c9)
    ExchangeLinks(c6, c9, c7, c8)

  of TO_129A436578, TO_12569A4378, TO_129A785643, TO_1287569A43:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c10, c9)
    ExchangeLinks(c4, c9, c7, c8)
    ExchangeLinks(c4, c7, c5, c6)

  of TO_1243659A87, TO_129A436587, TO_124378A965, TO_129A874365,
     TO_12569A4387, TO_12569A8743:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c6, c5)
    ExchangeLinks(c1, c6, c8, c7)
    ExchangeLinks(c1, c8, c10, c9)

  of TO_1243A96587, TO_128743A965:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c3, c4, c6, c5)
    ExchangeLinks(c3, c6, c8, c7)
    ExchangeLinks(c2, c9, c3, c8)

  of TO_12A9437865, TO_12564387A9, TO_1287A95643:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c2, c9, c7, c8)
    ExchangeLinks(c2, c7, c3, c4)
    ExchangeLinks(c4, c7, c5, c6)

  of TO_129A784365, TO_12569A7843, TO_12659A8743:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c10, c9)
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_1287A94365:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c6, c5, c7, c8)
    ExchangeLinks(c3, c4, c8, c5)
    ExchangeLinks(c2, c9, c3, c8)

  of TO_1256439A78:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c1, c4, c10, c9)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_12A9564387:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c2, c9, c3, c4)
    ExchangeLinks(c4, c9, c5, c8)

  of TO_1256A97843, TO_129A658743:
    ExchangeLinks(c8, c7, c9, c10)
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c6, c5)
    ExchangeLinks(c1, c6, c10, c7)

  of TO_1265A94387, TO_1265A97843:
    ExchangeLinks(c1, c2, c10, c9)
    ExchangeLinks(c4, c3, c5, c6)
    ExchangeLinks(c2, c9, c7, c8)
    ExchangeLinks(c2, c7, c3, c6)

  of TO_129A657843:
    ExchangeLinks(c1, c2, c4, c3)
    ExchangeLinks(c1, c4, c10, c9)
    ExchangeLinks(c5, c6, c8, c7)
    ExchangeLinks(c4, c9, c5, c8)

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

Some simple statistics

Relative time, best length, average length and worst length for all tours created by NN heuristic and improved by 3-opt and simple Lin-Kernighan algorithm implementation with sequential 5-opt starting move. Neighbor lists size=24, LK breadth=(5, 5, 5, 5, 3, 3), LK depth=55. Random planar problems, N=100.
Problem # Method Time Best Avg Worst
1NN100100.00104.58111.49
3opt-ND(24)498182.1084.0787.66
LK 5+2468781.8982.5184.62
2NN100100.00105.94113.41
3opt-ND(24)586288.0589.3091.10
LK 5+2526887.8788.3289.12
3NN100100.00110.21118.39
3opt-ND(24)586288.6989.2292.23
LK 5+2302588.6988.7490.17
4NN100100.00110.71121.43
3opt-ND(24)498188.4990.3694.79
LK 5+2517488.2288.9491.08
5NN100100.00106.48112.81
3opt-ND(24)624983.9186.8891.43
LK 5+21151883.3683.9685.16
6NN100100.00107.73119.37
3opt-ND(24)663789.2990.9394.26
LK 5+2390689.2989.6691.21
7NN100100.00111.26124.70
3opt-ND(24)527594.9297.82103.58
LK 5+2302594.9295.4798.97
9NN100100.00106.52117.51
3opt-ND(24)566287.4289.3091.69
LK 5+2683787.3388.4390.56
9NN100100.00105.63112.79
3opt-ND(24)536885.5787.7290.64
LK 5+2537485.5786.0487.80
10NN100100.00107.49119.01
3opt-ND(24)468791.0492.8994.33
LK 5+2400690.7991.5093.80

No comments:

Post a Comment