From f73e28fb8af3d105474729bd8f423f1cd581fe09 Mon Sep 17 00:00:00 2001 From: coolneng Date: Mon, 12 Apr 2021 12:03:11 +0200 Subject: [PATCH] Choose pseudorandom first solution in local search --- src/processing.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/processing.py b/src/processing.py index ced928f..3dad429 100644 --- a/src/processing.py +++ b/src/processing.py @@ -1,6 +1,7 @@ from preprocessing import parse_file from pandas import DataFrame from sys import argv +from random import seed, randint def get_first_solution(n, data): @@ -44,9 +45,19 @@ def greedy_algorithm(n, m, data): return solutions +def get_pseudorandom_solution(n, data): + seed(42) + return data.iloc[randint(a=0, b=n)] + + # NOTE In each step, switch to the element that gives the least amount def local_search(n, m, data): - pass + solutions = DataFrame(columns=["point", "distance"]) + first_solution = get_pseudorandom_solution(n=n, data=data) + solutions = solutions.append(first_solution, ignore_index=True) + for _ in range(m): + pass + return solutions def execute_algorithm(choice, n, m, data):