diff --git a/src/local_search.py b/src/local_search.py index 001ceb6..a30f5e8 100644 --- a/src/local_search.py +++ b/src/local_search.py @@ -1,4 +1,4 @@ -from numpy.random import choice, randint, seed +from numpy.random import choice, seed def get_first_random_solution(m, data): @@ -9,10 +9,9 @@ def get_first_random_solution(m, data): def replace_worst_element(previous, data): solution = previous.copy() - worst_index = previous["distance"].astype(float).idxmin() - random_candidate = data.loc[randint(low=0, high=len(data.index))] - solution.loc[worst_index] = random_candidate - return solution + worst_index = solution["distance"].astype(float).idxmin() + solution.loc[worst_index] = data.sample(random_state=42).squeeze() + return solution, worst_index def get_random_solution(previous, data):