mutation
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user