Scalars

Inheritance diagram of hermespy.core.pymonte.scalar.ScalarEvaluator, hermespy.core.pymonte.scalar.ScalarEvaluationResult, hermespy.core.pymonte.scalar.ScalarDimension
class ScalarEvaluator(confidence=1.0, tolerance=0.0, min_num_samples=1024, plot_scale='linear', tick_format=ValueType.LIN, plot_surface=True)[source]

Bases: Evaluator

Evaluation routine for investigated object states, extracting scalar performance indicators of interest.

Evaluators represent the process of extracting arbitrary performance indicator samples \(X_m\) in the form of Artifact instances from investigated object states. Once a MonteCarloActor has set its investigated object to a new random state, it calls the evaluate routines of all configured evaluators, collecting the resulting respective Artifact instances.

For a given set of Artifact instances, evaluators are expected to report a confidence() which may result in a premature abortion of the sample collection routine for a single GridSection. By default, the routine suggested by Bayer et al.[1] is applied: Considering a tolerance \(\mathrm{TOL} \in \mathbb{R}_{++}\) the confidence in the mean performance indicator

\[\bar{X}_M = \frac{1}{M} \sum_{m = 1}^{M} X_m\]

is considered sufficient if a threshold \(\delta \in \mathbb{R}_{++}\), defined as

\[\mathrm{P}\left(\left\| \bar{X}_M - \mathrm{E}\left[ X \right] \right\| > \mathrm{TOL} \right) \leq \delta\]

has been crossed. The number of collected actually collected artifacts per GridSection \(M \in [M_{\mathrm{min}}, M_{\mathrm{max}}]\) is between a minimum number of required samples \(M_{\mathrm{min}} \in \mathbb{R}_{+}\) and an upper limit of \(M_{\mathrm{max}} \in \mathbb{R}_{++}\).

Parameters:
  • confidence (float) – Required confidence level for the given tolerance between zero and one.

  • tolerance (float) – Acceptable non-negative bound around the mean value of the estimated scalar performance indicator.

  • min_num_samples (int) – Minimum number of samples required to compute the confidence bound.

  • plot_scale (str) – Scale of the plot. Can be 'linear' or 'log'.

  • tick_format (ValueType) – Tick format of the plot.

  • plot_surface (bool) – Enable surface plotting for two-dimensional grids. Enabled by default.

initialize_result(grid)[source]

Initialize the respective result object for this evaluator.

Parameters:

grid (Sequence[GridDimensionInfo]) – The parameter grid over which the simulation iterates.

Return type:

ScalarEvaluationResult

Returns: The initialized evaluation result.

property confidence: float[source]

Confidence threshold required for premature simulation abortion.

The confidence threshold \(\delta \in [0, 1]\) is the upper bound to the confidence level

\[\mathrm{P}\left(\left\| \bar{X}_M - \mathrm{E}\left[ X \right] \right\| > \mathrm{TOL} \right)\]

at which the sample collection for a single GridSection may be prematurely aborted [1].

Raises:

ValueError – If confidence is lower than zero or greater than one.

property min_num_samples: int[source]

Minimum number of samples required to compute the confidence bound.

The minimum number of samples \(M_{\mathrm{min}} \in \mathbb{R}_{+}\) is the minimum number of samples required to compute the confidence bound for a single GridSection.

Returns: Minimum number of samples \(M_{\mathrm{min}}\).

Raises:

ValueError – If minimum number of samples is less than two.

property plot_surface: bool[source]

Enable surface plotting for two-dimensional grids.

property tolerance: float[source]

Tolerance level required for premature simulation abortion.

The tolerance \(\mathrm{TOL} \in \mathbb{R}_{++}\) is the upper bound to the interval

\[\left\| \bar{X}_M - \mathrm{E}\left[ X \right] \right\|\]

by which the performance indicator estimation \(\bar{X}_M\) may diverge from the actual expected value \(\mathrm{E}\left[ X \right]\).

Returns: Non-negative tolerance \(\mathrm{TOL}\).

Raises:

ValueError – If tolerance is negative.

class ScalarEvaluationResult(grid, evaluator, accuracy=0.0, confidence=1.0, min_num_samples=1024, plot_surface=True, base_dimension_index=0)[source]

Bases: EvaluationResult

Base class for scalar evaluation results.

Parameters:
  • grid (Sequence[GridDimensionInfo]) – Simulation grid.

  • evaluator (Evaluator) – Evaluator associated with this result.

  • accuracy (float) – Acceptable bound around the mean value of the estimated scalar performance indicator.

  • tolerance – Required confidence level for the given accuracy.

  • min_num_samples (int) – Minimum number of samples required to compute the confidence bound.

  • plot_surface (bool) – Enable surface plotting for two-dimensional grids. Enabled by default.

  • base_dimension_index (int) – Index of the base dimension used for plotting.

add_artifact(coordinates, artifact, compute_confidence=True)[source]

Add an artifact to this evaluation result.

Parameters:
  • coordinates (tuple[int, ...]) – Coordinates of the grid section to which the artifact belongs.

  • artifact (Artifact) – Artifact to be added.

  • compute_confidence (bool) – Whether to compute the confidence level of the evaluation result for the given section coordinates.

Return type:

bool

Returns:

Can the result be trusted? Always False if compute_confidence is set to False.

create_figure(**kwargs)[source]

Create a new figure for plotting.

Returns: Newly generated figure and axes to plot into.

Return type:

tuple[FigureBase, ndarray[tuple[int, int], dtype[Any]]]

runtime_estimates()[source]

Extract a runtime estimate for this evaluation result.

Returns: A numpy array containing the runtime estimates for each grid section. If no estimates are available, None is returned.

Return type:

None | ndarray

to_array()[source]

Convert the evaluation result raw data to an array representation.

Used to store the results in arbitrary binary file formats after simulation execution.

Returns: The array result representation.

Return type:

ndarray

plot_surface: bool[source]
property title: str[source]

Title of the visualizable.

Returns: Title string.

class ScalarDimension[source]

Bases: ABC

Base class for objects that can be configured by scalar values.

When a property of type ScalarDimension is defined as a simulation parameter GridDimension, the simulation will automatically configure the object with the scalar value of the sample point during simulation runtime.

The configuration operation is represented by the lshift operator <<.

abstract property title: str[source]

Title of the scalar dimension.

Displayed in plots and tables during simulation runtime.