Фитнес функция как параметр
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user