Все проверил, для меня это реально какая то магия, но вроде все робит, треш...
This commit is contained in:
parent
0cb70cc8e4
commit
b6fb5534e2
@ -144,7 +144,7 @@ def mutate(child):
|
||||
return child
|
||||
|
||||
|
||||
def update_best_paths(best_paths, path, graph, max_best_paths=3):
|
||||
def update_best_paths(best_paths, path, graph, max_best_paths=10):
|
||||
length, _, _ = path_length_and_time(path, graph)
|
||||
if path not in best_paths:
|
||||
best_paths[path] = length
|
||||
@ -176,7 +176,7 @@ def genetic_algorithm(start, end, graph, flights_data, type, departure_date, pop
|
||||
population = new_population
|
||||
|
||||
best_paths = sorted(best_paths.items(), key=lambda item: item[1])
|
||||
top_paths = [list(path) for path, _ in best_paths[:3]]
|
||||
top_paths = [list(path) for path, _ in best_paths[:10]]
|
||||
|
||||
result = []
|
||||
for path in top_paths:
|
||||
|
Loading…
Reference in New Issue
Block a user