Фитнес функция как параметр

This commit is contained in:
2025-09-11 11:06:19 +03:00
parent a1a53ef749
commit 1732a1dbb6
3 changed files with 33 additions and 19 deletions

View File

@@ -1,9 +1,16 @@
import math
import os
import shutil
from gen import GARunConfig, genetic_algorithm
from prettytable import PrettyTable
def target_function(x: float) -> float:
"""f(x) = sin(x)/x^2"""
return math.sin(x) / (x * x)
# Базовая папка для экспериментов
BASE_DIR = "experiments"
@@ -16,6 +23,7 @@ PM_VALUES = [0.001, 0.01, 0.05, 0.1, 0.2] # вероятности мутаци
BASE_CONFIG = {
"x_min": 3.1,
"x_max": 20.0,
"fitness_func": target_function,
"precision_digits": 3,
"max_generations": 200,
"seed": 17,