saealib.GA#
- class saealib.GA(crossover, mutation, parent_selection, survivor_selection, *, duplicate_elimination=None, variation_execution='batch', integer_crossover=None, integer_mutation=None, categorical_crossover=None, categorical_mutation=None)[source]#
Bases:
AskTellAlgorithmGenetic Algorithm class.
- Parameters:
crossover (Crossover)
mutation (Mutation)
parent_selection (ParentSelection)
survivor_selection (SurvivorSelection)
duplicate_elimination (DuplicateElimination | None)
variation_execution (Literal['batch', 'sequential'] | dict[str, Literal['batch', 'sequential']])
integer_crossover (Crossover | None)
integer_mutation (Mutation | None)
categorical_crossover (Crossover | None)
categorical_mutation (Mutation | None)
- parent_selection#
Parent selection operator.
- Type:
- survivor_selection#
Survivor selection operator.
- Type:
- duplicate_elimination#
When set, offspring that duplicate any member of the current population are replaced by re-generated candidates (up to
max_retriesattempts).Nonedisables duplicate elimination (default behaviour).- Type:
DuplicateElimination or None
- variation_execution#
Execution mode for crossover and mutation. A string applies to both; a dict may set
"crossover"and"mutation"independently, with omitted keys defaulting to"batch". In batch mode, all gate decisions and operations complete before any post-operation hook runs, so a stateful hook cannot influence a later individual’s operation. Sequential mode completes each individual’s operation and hook before starting the next, preserving the pre-batching behavior byte-for-byte. Mixed-variable problems now use per-type batch operations by default, which changes their historical random-number sequence; select sequential mode to preserve it. This is a semantic choice, not only a performance setting.- Type:
{“batch”, “sequential”} or dict
Methods
Initialize GA (Genetic Algorithm) class. |
|
Generate offspring via crossover and mutation. |
|
Return the genetic-algorithm contract. |
|
Create a ParetoArchive with the correct direction for the problem. |
|
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, *, duplicate_elimination=None, variation_execution='batch', integer_crossover=None, integer_mutation=None, categorical_crossover=None, categorical_mutation=None)[source]#
Initialize GA (Genetic Algorithm) class.
- Parameters:
crossover (Crossover) – Crossover operator for continuous dimensions.
mutation (Mutation) – Mutation operator for continuous dimensions.
parent_selection (ParentSelection) – Parent selection operator.
survivor_selection (SurvivorSelection) – Survivor selection operator.
duplicate_elimination (DuplicateElimination, optional) – When provided, offspring that duplicate any member of the current population are replaced by re-generated candidates.
None(default) disables duplicate elimination.variation_execution ({"batch", "sequential"} or dict, optional) – Execution mode for crossover and mutation. A string applies to both operators. A dict may contain
"crossover"and"mutation"independently; an omitted key defaults to"batch". In batch mode, every individual’s gate decision and operation is computed before anypost_crossoverorpost_mutationhook runs for any individual in that call. A stateful hook may observe earlier hooks in the subsequent post-processing pass, but cannot influence a later individual’s operation. In sequential mode, each individual’s complete operation-then-hook cycle finishes before the next begins, matching the library’s pre-batching behavior byte-for-byte. This is a semantic choice, not only a performance setting. Mixed-variable problems use per-type batch operations by default, changing their historical random-number sequence; use sequential mode to preserve it.integer_crossover (Crossover, optional) – Crossover operator for integer dimensions. Defaults to
CrossoverIntegerSBXwith the same rate as crossover.integer_mutation (Mutation, optional) – Mutation operator for integer dimensions. Defaults to
MutationIntegerUniformwith the same rate as mutation.categorical_crossover (Crossover, optional) – Crossover operator for categorical dimensions. Defaults to
CrossoverCategoricalwith the same rate as crossover.categorical_mutation (Mutation, optional) – Mutation operator for categorical dimensions. Defaults to
MutationCategoricalwith the same rate as mutation.
- GA.ask(request, state)[source]#
Generate offspring via crossover and mutation.
- Parameters:
request (ProposalRequest) – Request-specific offspring count.
state (StateView) – Read-only algorithm state view.
- Return type:
- GA.create_pareto_archive(attrs, init_capacity, problem)#
Create a ParetoArchive with the correct direction for the problem.
- Parameters:
attrs (list[PopulationAttribute])
init_capacity (int)
problem (Problem)
- 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(feedback, state)[source]#
Update the population using (μ+λ) survivor selection.
- Parameters:
feedback (FeedbackBatch) – Feedback delivered for the current proposal.
state (StateView) – Read-only algorithm state view.
- Return type: