From 193e9046eb1e345d49565f1e479f6551fe4ea2fb Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 15 Apr 2021 20:12:05 +0200 Subject: [PATCH] Refactor neighbourhood exploration --- src/processing.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/processing.py b/src/processing.py index 1b69943..290fc74 100644 --- a/src/processing.py +++ b/src/processing.py @@ -82,11 +82,14 @@ def get_random_solution(previous, data): def explore_neighbourhood(element, data, max_iterations=100000): - neighbour = DataFrame() + neighbourhood = [] + neighbourhood.append(element) for _ in range(max_iterations): - neighbour, stop_condition = get_random_solution(element, data) - if stop_condition: + previous_solution = neighbourhood[-1] + neighbour = get_random_solution(previous=previous_solution, data=data) + if neighbour.equals(previous_solution): break + neighbourhood.append(neighbour) return neighbour