This commit is contained in:
2025-11-07 12:54:27 +03:00
parent 74e02df205
commit bacfa20061
3 changed files with 110 additions and 95 deletions

View File

@@ -17,7 +17,7 @@ type FitnessFn = Callable[[Chromosome], float]
type InitializePopulationFn = Callable[[int], Population]
type CrossoverFn = Callable[[Chromosome, Chromosome], tuple[Chromosome, Chromosome]]
type MutationFn = Callable[[Chromosome, int], Chromosome]
type MutationFn = Callable[[Chromosome], Chromosome]
type SelectionFn = Callable[[Population, Fitnesses], Population]
@@ -132,7 +132,7 @@ def mutation(
next_population = []
for chrom in population:
next_population.append(
mutation_fn(chrom, gen_num) if np.random.random() <= pm else chrom
mutation_fn(chrom) if np.random.random() <= pm else chrom
)
return next_population