saealib.AskStage#

class saealib.AskStage(algorithm, n_offspring=None, cbmanager=None)[source]#

Bases: Stage

Generate offspring candidates via the algorithm’s ask() method.

Writes the offspring population to state.offspring.

Parameters:
  • algorithm (Algorithm) – The evolutionary algorithm that generates candidates.

  • n_offspring (int or None) – Number of offspring to request. Passed directly to algorithm.ask(). None lets the algorithm decide.

  • cbmanager (CallbackManager or None) – If provided, PostCrossoverEvent / PostMutationEvent / PostAskEvent are dispatched through this manager.

Methods

__init__

Initialize base Stage attributes.

contract

Return this stage's structural and direct state-access contract.

execute

Execute this stage and return the updated state.

to_pseudocode

Expand into per-operator lines via Algorithm.ask_notation.

to_text

Render this stage as a plain-text algorithmic line.

Method Details

AskStage.__init__(algorithm, n_offspring=None, cbmanager=None)[source]#

Initialize base Stage attributes.

Parameters:
  • name (str, optional) – Override the class-level name.

  • label (str, optional) – Override the class-level label.

  • notation (str, optional) – Override the class-level notation.

  • algorithm (Algorithm | Proposer)

  • n_offspring (int | None)

  • cbmanager (CallbackManager | None)

Return type:

None

AskStage.contract()[source]#

Return this stage’s structural and direct state-access contract.

Return type:

ComponentContract

AskStage.execute(state)[source]#

Execute this stage and return the updated state.

Parameters:

state (OptimizationState) – Current optimization state.

Returns:

Updated state.

Return type:

OptimizationState

AskStage.to_pseudocode(*, expand=False, indent=0)[source]#

Expand into per-operator lines via Algorithm.ask_notation.

Parameters:
  • expand (bool)

  • indent (int)

Return type:

str

AskStage.to_text(*, expand=False, indent=0)#

Render this stage as a plain-text algorithmic line.

Parameters:
  • expand (bool)

  • indent (int)

Return type:

str