From b6fb5534e26dd66f666ae744ec9417e03d929c35 Mon Sep 17 00:00:00 2001 From: maksim Date: Thu, 6 Jun 2024 01:21:15 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B8=D0=BB,=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8F=20=D1=8D=D1=82=D0=BE=20=D1=80=D0=B5=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=20=D0=BA=D0=B0=D0=BA=D0=B0=D1=8F=20=D1=82?= =?UTF-8?q?=D0=BE=20=D0=BC=D0=B0=D0=B3=D0=B8=D1=8F,=20=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B2=D1=81=D0=B5=20=D1=80?= =?UTF-8?q?=D0=BE=D0=B1=D0=B8=D1=82,=20=D1=82=D1=80=D0=B5=D1=88...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- genetic_algorithm/genetic_algorithm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/genetic_algorithm/genetic_algorithm.py b/genetic_algorithm/genetic_algorithm.py index 33368ea..726a27a 100644 --- a/genetic_algorithm/genetic_algorithm.py +++ b/genetic_algorithm/genetic_algorithm.py @@ -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: