saealib.PymooAlgorithm#
- class saealib.PymooAlgorithm(pymoo_algorithm, *, allow_partial_tell=False)[source]#
Bases:
AskTellAlgorithmAdapter wrapping a pymoo Algorithm (e.g.
NSGA2()) as saealib’sAlgorithm.Lets researchers who already have a pymoo algorithm reuse it unchanged inside saealib’s ask-tell loop and surrogate-assisted strategies.
- Parameters:
pymoo_algorithm (pymoo.core.algorithm.Algorithm) – An already-constructed pymoo algorithm instance (not yet
setup()).allow_partial_tell (bool, optional) –
PreSelectionStrategytruncates offspring beforetell(), sotell()may receive only a subset of whatask()produced. By default this raisesConfigurationError, since index-coupled pymoo algorithms (e.g. differential evolution) would silently misalign parents and offspring under a subset. SetTrueto opt in and pass the subset through anyway. Default: False.
Notes
Engine mode. The wrapped pymoo algorithm owns its own population and internal state (survival mechanics, index-coupled operators, adaptive parameters).
ctx.populationis a mirror, refreshed from the pymoo algorithm’s own.popat the end of everytell(), not the source of truth. This is the only way to reuse a pymoo algorithm’s own tested logic unchanged, but it comes with real limitations:No checkpoint/resume.
OptimizationState.save()only serializes saealib’s own arrays; the wrapped pymoo algorithm’s internal state is not captured.``n_offspring`` is ignored. The offspring count is fixed by the wrapped algorithm’s own configuration (e.g. its
pop_size); strategies that request a larger candidate pool for pre-selection cannot enlarge it here.Constrained problems combined with surrogate-only generations are unsupported. When a candidate never receives a true evaluation, saealib leaves its
g/cvat schema defaults (0.0, looking falsely feasible) — this is an existing, library-wide limitation (SurrogatePredictionhas nocvfield), not something specific to this adapter, but it meansPymooAlgorithm’s constraint handling should not be trusted underSurrogateOnlyLoopStage/IB’s untrue tail.
Initialization is handled by mirroring saealib’s already-evaluated initial population into the pymoo algorithm’s own initial
ask()result before callingtell()on it, so the initial design-of- experiments is not duplicated or discarded.A
pymoo_idxcolumn tracks each candidate’s position in the pymoo infill population, so thattell()can recover the correct mapping even afterSortByScoreStage/TopKSelectionStagereorder or truncatestate.offspringbetweenaskandtell.
Methods
Generate offspring via the wrapped pymoo algorithm's own |
|
Return the family contract with optional partial-feedback capability. |
|
Create a ParetoArchive with the correct direction for the problem. |
|
Add a |
|
Update the wrapped pymoo algorithm, then mirror its population into |
Method Details
- PymooAlgorithm.__init__(pymoo_algorithm, *, allow_partial_tell=False)[source]#
- Parameters:
pymoo_algorithm (_PymooAlgorithmLike)
allow_partial_tell (bool)
- Return type:
None
- PymooAlgorithm.ask(request, state)[source]#
Generate offspring via the wrapped pymoo algorithm’s own
ask().- Parameters:
ctx (ExecutionContext) – Current optimization context.
provider (Dispatchable) – Component provider.
n_offspring (int or None, optional) – Ignored; the offspring count is fixed by the wrapped pymoo algorithm’s own configuration.
request (ProposalRequest)
state (StateView)
- Returns:
Candidates with
xandpymoo_idxset.- Return type:
- PymooAlgorithm.contract()[source]#
Return the family contract with optional partial-feedback capability.
- Return type:
- PymooAlgorithm.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:
- PymooAlgorithm.get_required_attrs(problem)[source]#
Add a
pymoo_idxcolumn tracking position in the pymoo infill pop.- Parameters:
problem (Problem)
- Return type:
list[PopulationAttribute]
- PymooAlgorithm.tell(feedback, state)[source]#
Update the wrapped pymoo algorithm, then mirror its population into
ctx.- Parameters:
ctx (ExecutionContext) – Current optimization context.
provider (Dispatchable) – Component provider.
offspring (Population) – Offspring population, possibly reordered or truncated relative to what
ask()produced.feedback (FeedbackBatch)
state (StateView)
- Return type: