Опечатка в типах в lab2

This commit is contained in:
2025-10-15 16:43:05 +03:00
parent 3436f94b61
commit 2cf0693070
2 changed files with 3 additions and 3 deletions

View File

@@ -16,7 +16,7 @@ from numpy.typing import NDArray
type Chromosome = NDArray[np.float64] type Chromosome = NDArray[np.float64]
type Population = list[Chromosome] type Population = list[Chromosome]
type Fitnesses = NDArray[np.float64] type Fitnesses = NDArray[np.float64]
type FitnessFn = Callable[[Chromosome], Fitnesses] type FitnessFn = Callable[[Chromosome], np.float64]
type CrossoverFn = Callable[[Chromosome, Chromosome], tuple[Chromosome, Chromosome]] type CrossoverFn = Callable[[Chromosome, Chromosome], tuple[Chromosome, Chromosome]]
type MutationFn = Callable[[Chromosome], Chromosome] type MutationFn = Callable[[Chromosome], Chromosome]
@@ -185,7 +185,7 @@ def plot_fitness_surface(
x_max: Chromosome, x_max: Chromosome,
ax: Axes3D, ax: Axes3D,
num_points: int = 100, num_points: int = 100,
) -> None: ):
"""Рисует поверхность функции фитнеса в 3D.""" """Рисует поверхность функции фитнеса в 3D."""
assert ( assert (
x_min.shape == x_max.shape == (2,) x_min.shape == x_max.shape == (2,)

View File

@@ -3,7 +3,7 @@ import numpy as np
from gen import GARunConfig, genetic_algorithm from gen import GARunConfig, genetic_algorithm
def fitness_function(chromosome: np.ndarray) -> np.ndarray: def fitness_function(chromosome: np.ndarray) -> np.float64:
return chromosome[0] ** 2 + 2 * chromosome[1] ** 2 return chromosome[0] ** 2 + 2 * chromosome[1] ** 2