Лаба 3

This commit is contained in:
2025-10-16 11:22:02 +03:00
parent 740a7be984
commit 268c4cf4a1
3 changed files with 85 additions and 199 deletions

View File

@@ -42,13 +42,13 @@ def build_fitness_function(cities):
BASE_DIR = "experiments"
# Параметры для экспериментов
POPULATION_SIZES = [10, 50, 100, 500]
PC_VALUES = [0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 1.0] # вероятности кроссинговера
PM_VALUES = [0.05, 0.2, 0.3, 0.4, 0.5, 0.8] # вероятности мутации
POPULATION_SIZES = [10, 25, 50, 100]
PC_VALUES = [0.5, 0.6, 0.7, 0.8, 0.9] # вероятности кроссинговера
PM_VALUES = [0.2, 0.3, 0.4, 0.5, 0.8] # вероятности мутации
SAVE_AVG_BEST_FITNESS = True
# Количество запусков для усреднения результатов
NUM_RUNS = 1
NUM_RUNS = 3
# Базовые параметры (как в main.py)
BASE_CONFIG = {
@@ -149,10 +149,10 @@ def run_experiments_for_population(pop_size: int) -> PrettyTable:
# Форматируем результат: среднееремя±стд_отклонение (среднее_поколения±стд_отклонение)
# cell_value = f"{avg_time:.1f}±{std_time:.1f} ({avg_generations:.1f}±{std_generations:.1f})"
cell_value = f"{avg_time:.1f} ({avg_generations:.0f})"
cell_value = f"{avg_time:.0f} ({avg_generations:.0f})"
if SAVE_AVG_BEST_FITNESS:
cell_value += f" {avg_best_fitness:.5f}"
cell_value += f" {avg_best_fitness:.0f}"
if avg_generations == BASE_CONFIG["max_generations"]:
cell_value = ""