Actors

Inheritance diagram of hermespy.core.pymonte.actors.MonteCarloActor, hermespy.core.pymonte.actors.MonteCarloCollector, hermespy.core.pymonte.actors.MonteCarloQueueManager
class MonteCarloActor(queue_manager, argument_tuple, index, stage_arguments=None, catch_exceptions=True)[source]

Bases: Generic[MO]

Monte Carlo Simulation Actor.

Actors are essentially workers running in a private process executing simulation tasks. The result of each individual simulation task is a simulation sample.

Parameters:
  • argument_tuple (tuple[TypeVar(MO), Sequence[GridDimension], Sequence[Evaluator]]) – Object to be investigated during the simulation runtime. Dimensions over which the simulation will iterate. Evaluators used to process the investigated object sample state.

  • index (int) – Global index of the actor.

  • stage_arguments (dict[str, Sequence[tuple]] | None) – Arguments for the simulation stages.

  • catch_exceptions (bool) – Catch exceptions during run. Enabled by default.

fetch_results()[source]

Fetch the results of the actor run.

Returns: list of results from the actor run.

Return type:

list[ObjectRef[list[MonteCarloSample]]]

run()[source]
Return type:

None

abstract stage_executors()[source]

list of simulation stage execution callbacks.

Simulations stages will be executed in the order specified here.

Return type:

list[Callable]

Returns:

list of function callbacks for simulation stage execution routines.

abstract static stage_identifiers()[source]

list of simulation stage identifiers.

Simulations stages will be executed in the order specified here.

Return type:

list[str]

Returns:

list of function identifiers for simulation stage execution routines.

catch_exceptions: bool[source]
class MonteCarloCollector(queue_manager, actors, grid, evaluators)[source]

Bases: object

Collects samples from actors during simulation runtime.

Parameters:
fetch_results()[source]

Fetch the results of the collector run.

Returns: list of evaluation results from the collector run.

Return type:

list[EvaluationResult]

query_estimates()[source]

Query intermediate estimates during simulation runtime.

Returns: A list with the length of the number of evaluators, each containing the runtime estimates for the respective evaluator. If no estimates are available, the entry will be None.

Return type:

list[None | ndarray]

run()[source]

Start up the collector, collecting samples from all actors.

This method will block and keep running until fetch_results() is called.

Return type:

None

class MonteCarloQueueManager(grid, num_samples, batch_size=None)[source]

Bases: object

Queue management actor for monte carlo simulations.

The queue manager is responsible for distributing section indices of the simulation grid to individual actors.

Parameters:
  • grid (Sequence[GridDimensionInfo]) – The grid to be simulated.

  • num_samples (int) – The number of samples to collect for each section.

  • batch_size (int | None) – The number of individual section index tuples to return when calling next_batch().

disable_section(coordinates)[source]

Disable a section from being processed in the future.

Once a section is disabled, its respective coordinates will not be returned by the next_batch() method anymore.

Parameters:

coordinates (tuple[int, ...]) – Coordinates of the section to disable.

Return type:

None

next_batch()[source]

Get the next batch of simulation grid sections to run.

This function gets called remotely by actors once they are ready to run a new batch of simulation tasks.

Returns: A list of tuples containing the coordinates of the sections to run in this batch.

Return type:

list[tuple[int, ...]]

query_progress()[source]

Query the current absolute progress of the managed simulation.

Returns: A floating point value between zero and one indicating the progress of the simulation as well as a boolean array indicating which sections are still actively being processed.

Return type:

tuple[float, ndarray]