From b3211ff682923ed088370dfc30e2866464c88105 Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 13 Apr 2021 23:01:37 +0200 Subject: [PATCH] Select m random elements as the first solution --- src/processing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/processing.py b/src/processing.py index 013fcb1..0feb2bd 100644 --- a/src/processing.py +++ b/src/processing.py @@ -1,7 +1,7 @@ from preprocessing import parse_file +from numpy.random import choice, randint, seed from pandas import DataFrame, Series from sys import argv -from random import seed, randint from time import time @@ -59,10 +59,10 @@ def greedy_algorithm(n, m, data): return solutions -def get_pseudorandom_solution(n, data): +def get_first_random_solution(m, data): seed(42) - solution = data.iloc[randint(a=0, b=n)] - return Series(data={"point": solution["destination"], "distance": 0}) + random_indexes = choice(len(data.index), size=m) + return data.iloc[random_indexes] def local_search(n, m, data):