Compare commits
No commits in common. "da234aae96e15ea2cbfbfb93cafdfc4511420edf" and "bf7ca7f520a4ac1ec09d331e40332f2d21eebd0f" have entirely different histories.
da234aae96
...
bf7ca7f520
|
@ -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_first_random_solution(m, data):
|
||||
def get_pseudorandom_solution(n, data):
|
||||
seed(42)
|
||||
random_indexes = choice(len(data.index), size=m)
|
||||
return data.iloc[random_indexes]
|
||||
solution = data.iloc[randint(a=0, b=n)]
|
||||
return Series(data={"point": solution["destination"], "distance": 0})
|
||||
|
||||
|
||||
def local_search(n, m, data):
|
||||
|
@ -72,17 +72,6 @@ def local_search(n, m, data):
|
|||
for _ in range(m):
|
||||
pass
|
||||
return solutions
|
||||
def get_random_solution(previous, data):
|
||||
solution = previous.copy()
|
||||
worst_index = previous["distance"].astype(float).idxmin()
|
||||
random_candidate = data.loc[randint(low=0, high=len(data.index))]
|
||||
while (
|
||||
solution.loc[worst_index, "distance"] <= previous.loc[worst_index, "distance"]
|
||||
):
|
||||
solution.loc[worst_index] = random_candidate
|
||||
return solution
|
||||
|
||||
|
||||
|
||||
|
||||
def execute_algorithm(choice, n, m, data):
|
||||
|
|
Loading…
Reference in New Issue