Actors¶

- class MonteCarloActor(queue_manager, argument_tuple, index, stage_arguments=None, catch_exceptions=True)[source]¶
-
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]]]
- abstract stage_executors()[source]¶
list of simulation stage execution callbacks.
Simulations stages will be executed in the order specified here.
- class MonteCarloCollector(queue_manager, actors, grid, evaluators)[source]¶
Bases:
objectCollects samples from actors during simulation runtime.
- Parameters:
queue_manager (
MonteCarloQueueManager) – Reference to the queue management actor.actors (
list[MonteCarloActor]) – References to invidual monte carlo simulation actors.grid (
Sequence[GridDimensionInfo]) – The grid to be simulated.evaluators (
list[Evaluator]) – The evaluators to be used for collecting processing the simulation results.
- fetch_results()[source]¶
Fetch the results of the collector run.
Returns: list of evaluation results from the collector run.
- Return type:
- 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.
- 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:
- class MonteCarloQueueManager(grid, num_samples, batch_size=None)[source]¶
Bases:
objectQueue 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 callingnext_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.
- 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.