saealib.GA

class saealib.GA(crossover, mutation, parent_selection, survivor_selection, repair=<function repair_clipping>)[source]

Bases: Algorithm

Genetic Algorithm class.

Parameters:
crossover

Crossover operator.

Type:

Crossover

mutation

Mutation operator.

Type:

Mutation

parent_selection

Parent selection operator.

Type:

ParentSelection

survivor_selection

Survivor selection operator.

Type:

SurvivorSelection

Methods

__init__

Initialize GA (Genetic Algorithm) class.

ask

Generate offspring via crossover and mutation.

get_required_attrs

Return algorithm-specific attributes (GA needs none beyond the defaults).

tell

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. Pass None to 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:

Population

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.