Thursday, March 23, 2017

Fixed radius search – general idea

The condition

Suppose that for some X1, X2, Y1, Y2 occurs:

Hence:

Therefore the inequity which a 2-opt move must meet to improve a tour::

holds if at least one of the two conditions is met:

or

Simple radius search with 2-opt

Note that for simplicity of the code below we do not change orientation and instead use both conditions.

proc LS_2_Opt_simpleRadius(tour: var Tour_Array) =
  var
    locallyOptimal: bool = false
    i, j: Tour_Index
    X1, X2, Y1, Y2: City_Number
    radius: Length

  while not locallyOptimal:
    locallyOptimal = true
    block two_loops:
      for counter_1 in 0 .. N-1:
        i  = counter_1
        X1 = tour[i]
        X2 = tour[(i+1) mod N]
        radius = distance(X1, X2)

        for counter_2 in 0 .. N-1:
          j = counter_2
          Y1 = tour[j]
          Y2 = tour[(j+1) mod N]
          if (X1 == Y1) or (X2 == Y1) or (Y2 == X1):
            continue

          if distance(X2, Y2) > radius:
            if distance(X1, Y1) > radius:
              continue

          if Gain_From_2_Opt(X1, X2, Y1, Y2) > 0:
            Make_2_Opt_Move(tour, i, j)
            locallyOptimal = false
            break two_loops

Some simple statistics

Relative time, best length, average length and worst length for all tours created by NN heuristic and improved by 2-opt and 2-opt with simple radius search algorithms. Random planar problems, N=100.
Problem # Method Time Best Avg Worst
1NN100100.00107.63117.95
NN + 2opt94086.9589.1894.09
NN + 2opt-simpleR72685.3788.8693.34
2NN100100.00107.02114.02
NN + 2opt78187.5290.9298.22
NN + 2opt-simpleR58787.9090.6495.50
3NN100100.00108.09121.54
NN + 2opt97487.5390.6796.83
NN + 2opt-simpleR58787.5391.0597.84
4NN100100.00109.31118.36
NN + 2opt87486.4791.6096.67
NN + 2opt-simpleR49386.8590.8897.71
5NN100100.00108.73120.07
NN + 2opt83385.7789.4496.25
NN + 2opt-simpleR62686.1289.3493.99
6NN100100.00106.37114.14
NN + 2opt83388.8391.2795.10
NN + 2opt-simpleR52687.2890.6795.23
7NN100100.00108.36116.70
NN + 2opt107482.5186.7391.88
NN + 2opt-simpleR68182.8186.5391.64
8NN100100.00109.35120.17
NN + 2opt68195.2097.46103.04
NN + 2opt-simpleR48794.3297.70102.40
9NN100100.00112.93125.15
NN + 2opt97590.5194.84100.73
NN + 2opt-simpleR58790.9795.1499.15
10NN100100.00110.36125.80
NN + 2opt83387.3892.3397.47
NN + 2opt-simpleR62687.8092.0297.50

3 comments:

  1. Is it possible for radius version to be better than regular version ? (Problem #1 Best value). I thought that radius is to speed up algorithm ?

    ReplyDelete
  2. Yes, radius is to speed up searching for an improving move and it itself should produce the same tours.

    Note that unfortunatelly 'NN + 2opt' used in stats here is not exactly the same as verson obtained by removing "if distance(X2, Y2) > radius..." and then may consider links in different order.

    ReplyDelete