PyMonte¶
PyMonte is a stand-alone core module of HermesPy, enabling efficient and flexible Monte Carlo simulations over arbitrary configuration parameter combinations. By wrapping the core of the Ray project, any object serializable by the pickle standard module can become a system model for a Monte Carlo style simulation campaign.
flowchart LR
subgraph gridsection[Grid Section]
parameter_a(Parameter)
parameter_b(Parameter)
end
object((Investigated Object))
evaluator_a{{Evaluator}}
evaluator_b{{Evaluator}}
evaluator_c{{Evaluator}}
subgraph sample[Sample]
artifact_a[(Artifact)]
artifact_b[(Artifact)]
artifact_c[(Artifact)]
end
parameter_a --> object
parameter_b --> object
object ---> evaluator_a ---> artifact_a
object ---> evaluator_b ---> artifact_b
object ---> evaluator_c ---> artifact_c
Monte Carlo simulations usually sweep over multiple combinations of multiple parameters settings, configuring the underlying system model and generating simulation samples from independent realizations of the model state. PyMonte refers to a single parameter combination as a grid section, with the set of all parameter combinations making up the simulation grid. Each settable property of the investigated object is treated as a potential simulation parameter within the grid, i.e. each settable property can be represented by an axis within the multidimensional simulation grid.
Evaluator instances extract performance indicators from each investigated object realization, referred to as Artifact.
A set of artifacts drawn from the same investigated object realization make up a single MonteCarloSample.
During the execution of PyMonte simulations between \(M_\mathrm{min}\) and \(M_\mathrm{max}\)
are generated from investigated object realizations for each grid section.
The sample generation for each grid section may be aborted prematurely if all evaluators have reached a configured
confidence threshold
Refer to Bayer et al.[1] for a detailed description of the implemented algorithm.
flowchart LR
controller{Simulation Controller}
gridsection_a[Grid Section]
gridsection_b[Grid Section]
sample_a[Sample]
sample_b[Sample]
subgraph actor_a[Actor #1]
object_a((Investigated Object))
end
subgraph actor_b[Actor #N]
object_b((Investigated Object))
end
controller --> gridsection_a --> actor_a --> sample_a
controller --> gridsection_b --> actor_b --> sample_b
The actual simulation workload distribution is visualized in the previous flowchart.
Using Ray, PyMonte spawns a number of MonteCarloActor containers,
with the number of actors depending on the available resources (i.e. number of CPU cores) detected.
A central simulation controller schedules the workload by assigning grid section index tuples as tasks to the actors, which return the resulting simulation Samples after the simulation iteration is completed.