From 17acfa5409bc8892b5e555b8ce4a8edd35338602 Mon Sep 17 00:00:00 2001 From: weixin_46229132 Date: Sat, 22 Mar 2025 17:24:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9GA=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GA/main.py | 3 ++- GA/main_parallel.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/GA/main.py b/GA/main.py index 1c0ba7e..ae9131b 100644 --- a/GA/main.py +++ b/GA/main.py @@ -82,7 +82,8 @@ with tqdm(total=total_iterations, desc="Processing") as pbar: car_path = [] for k in range(from_index, end_index + 1): rectrangle_idx = best_solution[k] - car_path.append(rectrangles[rectrangle_idx]['center']) + if rectrangle_idx not in to_process_idx: + car_path.append(rectrangles[rectrangle_idx - 1]['center']) car_paths.append(car_path) pbar.update(1) diff --git a/GA/main_parallel.py b/GA/main_parallel.py index 2742ce4..cb815c8 100644 --- a/GA/main_parallel.py +++ b/GA/main_parallel.py @@ -112,7 +112,7 @@ if __name__ == "__main__": # 重要:在 Windows 上必须加这一行 for k in range(from_index, end_index + 1): rectrangle_idx = best_solution[k] if rectrangle_idx not in to_process_idx: - car_path.append(rectrangles[rectrangle_idx]['center']) + car_path.append(rectrangles[rectrangle_idx - 1]['center']) car_paths.append(car_path) # 输出最佳方案