saealib.PymooAlgorithm#

class saealib.PymooAlgorithm(pymoo_algorithm, *, allow_partial_tell=False)[source]#

Bases: AskTellAlgorithm

Adapter wrapping a pymoo Algorithm (e.g. NSGA2()) as saealib’s Algorithm.

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) – PreSelectionStrategy truncates offspring before tell(), so tell() may receive only a subset of what ask() produced. By default this raises ConfigurationError, since index-coupled pymoo algorithms (e.g. differential evolution) would silently misalign parents and offspring under a subset. Set True to 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.population is a mirror, refreshed from the pymoo algorithm’s own .pop at the end of every tell(), 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/cv at schema defaults (0.0, looking falsely feasible) — this is an existing, library-wide limitation (SurrogatePrediction has no cv field), not something specific to this adapter, but it means PymooAlgorithm’s constraint handling should not be trusted under SurrogateOnlyLoopStage/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 calling tell() on it, so the initial design-of- experiments is not duplicated or discarded.

A pymoo_idx column tracks each candidate’s position in the pymoo infill population, so that tell() can recover the correct mapping even after SortByScoreStage/TopKSelectionStage reorder or truncate state.offspring between ask and tell.

Methods

__init__

ask

Generate offspring via the wrapped pymoo algorithm's own ask().

contract

Return the family contract with optional partial-feedback capability.

create_pareto_archive

Create a ParetoArchive with the correct direction for the problem.

get_required_attrs

Add a pymoo_idx column tracking position in the pymoo infill pop.

tell

Update the wrapped pymoo algorithm, then mirror its population into ctx.

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 x and pymoo_idx set.

Return type:

Population

PymooAlgorithm.contract()[source]#

Return the family contract with optional partial-feedback capability.

Return type:

ComponentContract

PymooAlgorithm.create_pareto_archive(attrs, init_capacity, problem)#

Create a ParetoArchive with the correct direction for the problem.

Parameters:
Return type:

ParetoArchive

PymooAlgorithm.get_required_attrs(problem)[source]#

Add a pymoo_idx column 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:

StatePatch