local
This commit is contained in:
parent
c43f9c3b9a
commit
e21034d9ca
1 changed files with 2 additions and 24 deletions
|
@ -11,13 +11,6 @@ class TwoOpt:
|
|||
|
||||
@staticmethod
|
||||
def step2opt(solution, matrix_dist, distance):
|
||||
"""
|
||||
One step of 2opt, one double loop and return first improved sequence
|
||||
@param solution:
|
||||
@param matrix_dist:
|
||||
@param distance:
|
||||
@return:
|
||||
"""
|
||||
seq_length = len(solution) - 1
|
||||
tsp_sequence = np.array(solution)
|
||||
uncrosses = 0
|
||||
|
@ -46,15 +39,7 @@ class TwoOpt:
|
|||
return - old_link_len + changed_links_len
|
||||
|
||||
@staticmethod
|
||||
def loop2opt(solution, instance,
|
||||
max_num_of_uncrosses=10000): # Iterate step2opt max_iter times (2-opt local search)
|
||||
"""
|
||||
|
||||
@param solution:
|
||||
@param instance:
|
||||
@param max_num_of_uncrosses:
|
||||
@return:
|
||||
"""
|
||||
def loop2opt(solution, instance, max_num_of_uncrosses=10000):
|
||||
matrix_dist = instance.dist_matrix
|
||||
new_len = compute_lenght(solution, matrix_dist)
|
||||
new_tsp_sequence = np.copy(np.array(solution))
|
||||
|
@ -75,13 +60,6 @@ class TwoDotFiveOpt:
|
|||
|
||||
@staticmethod
|
||||
def step2dot5opt(solution, matrix_dist, distance):
|
||||
"""
|
||||
One step of 2opt, one double loop and return first improved sequence
|
||||
@param solution:
|
||||
@param matrix_dist:
|
||||
@param distance:
|
||||
@return:
|
||||
"""
|
||||
seq_length = len(solution) - 2
|
||||
tsp_sequence = np.array(solution)
|
||||
uncrosses = 0
|
||||
|
|
Reference in a new issue