Remove redundant code
This commit is contained in:
parent
112f40d00f
commit
fb5e9dc703
|
@ -22,16 +22,6 @@ def compute_distance(element, solution, data):
|
||||||
return accumulator
|
return accumulator
|
||||||
|
|
||||||
|
|
||||||
def get_first_random_solution(n, m, data):
|
|
||||||
solution = DataFrame(columns=["point", "distance"])
|
|
||||||
seed(42)
|
|
||||||
solution["point"] = choice(n, size=m, replace=False)
|
|
||||||
solution["distance"] = solution["point"].apply(
|
|
||||||
func=compute_distance, solution=solution, data=data
|
|
||||||
)
|
|
||||||
return solution
|
|
||||||
|
|
||||||
|
|
||||||
def element_in_dataframe(solution, element):
|
def element_in_dataframe(solution, element):
|
||||||
duplicates = solution.query(f"point == {element}")
|
duplicates = solution.query(f"point == {element}")
|
||||||
return not duplicates.empty
|
return not duplicates.empty
|
||||||
|
|
|
@ -48,7 +48,6 @@ def memetic_algorithm(n, m, data, hybridation, max_iterations=100000):
|
||||||
population = evaluate_population(population, data)
|
population = evaluate_population(population, data)
|
||||||
for i in range(max_iterations):
|
for i in range(max_iterations):
|
||||||
if i % 10 == 0:
|
if i % 10 == 0:
|
||||||
best_index, _ = get_best_elements(population)
|
|
||||||
population = run_local_search(n, data, population, mode=hybridation)
|
population = run_local_search(n, data, population, mode=hybridation)
|
||||||
i += 5
|
i += 5
|
||||||
parents = select_parents(population, n, mode="stationary")
|
parents = select_parents(population, n, mode="stationary")
|
||||||
|
|
Loading…
Reference in New Issue