Implement best first local search algorithm
This commit is contained in:
parent
b3211ff682
commit
da234aae96
|
@ -72,6 +72,17 @@ 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