From 9024e5d574b238aa12f6cd907cddca5d83b7bfd7 Mon Sep 17 00:00:00 2001 From: UmbertoJr Date: Mon, 18 Nov 2019 11:51:20 +0100 Subject: [PATCH] local --- src/local_search.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/local_search.py b/src/local_search.py index b0a175d..62be9a9 100644 --- a/src/local_search.py +++ b/src/local_search.py @@ -93,10 +93,12 @@ class TwoDotFiveOpt: @staticmethod def shift_gain1(i, j, tsp_sequence, matrix_dist): - old_link_len = (matrix_dist[tsp_sequence[i], tsp_sequence[i - 1]] + matrix_dist[ - tsp_s equence[i], tsp_sequence[i + 1]] + matrix_dist[tsp_sequence[j], tsp_sequence[j + 1]]) - changed_links_len = (matrix_dist[tsp_sequence[i - 1], tsp_sequence[i + 1]] + matrix_dist[ - tsp_sequence[i], tsp_sequence[j]] + matrix_dist[tsp_sequence[i], tsp_sequence[j + 1]]) + old_link_len = (matrix_dist[tsp_sequence[i], tsp_sequence[i - 1]] + + matrix_dist[tsp_sequence[i], tsp_sequence[i + 1]] + + matrix_dist[tsp_sequence[j], tsp_sequence[j + 1]]) + changed_links_len = (matrix_dist[tsp_sequence[i - 1], tsp_sequence[i + 1]] + + matrix_dist[tsp_sequence[i], tsp_sequence[j]] + + matrix_dist[tsp_sequence[i], tsp_sequence[j + 1]]) return - old_link_len + changed_links_len @staticmethod