saealib.GA¶
- class saealib.GA(crossover, mutation, parent_selection, survivor_selection, repair=<function repair_clipping>)[source]¶
Bases:
AlgorithmGenetic Algorithm class.
- Parameters:
crossover (Crossover)
mutation (Mutation)
parent_selection (ParentSelection)
survivor_selection (SurvivorSelection)
repair (RepairFunc | None)
- parent_selection¶
Parent selection operator.
- Type:
- survivor_selection¶
Survivor selection operator.
- Type:
Methods
Initialize GA (Genetic Algorithm) class. |
|
Generate offspring via crossover and mutation. |
|
Return algorithm-specific attributes (GA needs none beyond the defaults). |
|
Update the population using (μ+λ) survivor selection. |
Method Details
- GA.__init__(crossover, mutation, parent_selection, survivor_selection, repair=<function repair_clipping>)[source]¶
Initialize GA (Genetic Algorithm) class.
- Parameters:
crossover (Crossover) – Crossover operator.
mutation (Mutation) – Mutation operator.
parent_selection (ParentSelection) – Parent selection operator.
survivor_selection (SurvivorSelection) – Survivor selection operator.
repair (RepairFunc or None, optional) – Repair function applied after crossover and after mutation. Defaults to
repair_clipping. PassNoneto disable repair.
- GA.ask(ctx, provider, n_offspring=None)[source]¶
Generate offspring via crossover and mutation.
- Parameters:
ctx (OptimizationContext) – Current optimization context.
provider (ComponentProvider) – Component provider.
n_offspring (int or None, optional) – Number of offspring. Defaults to the current population size.
- Return type:
- GA.get_required_attrs(problem)[source]¶
Return algorithm-specific attributes (GA needs none beyond the defaults).
- Parameters:
problem (Problem)
- Return type:
list[PopulationAttribute]
- GA.tell(ctx, provider, offspring)[source]¶
Update the population using (μ+λ) survivor selection.
- Parameters:
ctx (OptimizationContext) – Current optimization context.
provider (ComponentProvider) – Component provider.
offspring (Population) – Offspring population.