simopt.input_models
Simple input-model wrappers for common distributions.
Module Contents
- simopt.input_models.P
- simopt.input_models.R
- class simopt.input_models.InputModel
-
Abstract base for input models used by simulations.
- rng: random.Random | None = None
- set_rng(rng: random.Random) None
Attach a Python RNG to the input model.
- Parameters:
rng (random.Random) – Random number generator to use for sampling.
- unset_rng() None
Detach any RNG currently attached to the input model.
- abstractmethod random(*args: P, **kwargs: P) R
Generate a random variate from the input model.
- Returns:
A random variate from the input model.
- Return type:
T
- class simopt.input_models.Exp
Bases:
InputModelExponential distribution wrapper.
- class simopt.input_models.Gamma
Bases:
InputModelGamma distribution wrapper.
- random(alpha: float, beta: float) float
Sample from Gamma(alpha, beta).
- Parameters:
alpha (float) – Shape parameter.
beta (float) – Scale parameter.
- Returns:
A gamma variate.
- Return type:
float
- class simopt.input_models.WeightedChoice
Bases:
InputModelDiscrete weighted choice wrapper.
- random(population: collections.abc.Sequence[object], weights: collections.abc.Sequence[float]) object
Sample an element from
populationaccording toweights.- Parameters:
population (Sequence) – Items to choose from.
weights (Sequence[float]) – Nonnegative weights for each item.
- Returns:
A randomly selected element from
population.- Return type:
Any
- class simopt.input_models.Poisson
Bases:
InputModelPoisson distribution wrapper.
- random(lam: float) int
Sample from Poisson(lam).
- Parameters:
lam (float) – Mean rate parameter (lambda >= 0).
- Returns:
A Poisson variate.
- Return type:
int
- class simopt.input_models.Beta
Bases:
InputModelBeta distribution wrapper.
- random(alpha: float, beta: float) float
Sample from Beta(alpha, beta).
- Parameters:
alpha (float) – Alpha (>= 0).
beta (float) – Beta (>= 0).
- Returns:
A beta variate in [0, 1].
- Return type:
float
- class simopt.input_models.Triangular
Bases:
InputModelTriangular distribution wrapper.
- random(low: float, high: float, mode: float) float
Sample from Triangular(low, high, mode).
- Parameters:
low (float) – Lower bound.
high (float) – Upper bound.
mode (float) – Mode of the distribution.
- Returns:
A triangular variate.
- Return type:
float
- class simopt.input_models.Uniform
Bases:
InputModelUniform distribution wrapper.
- random(low: float, high: float) float
Sample from Uniform(low, high).
- Parameters:
low (float) – Lower bound.
high (float) – Upper bound.
- Returns:
A uniform variate in [low, high].
- Return type:
float
- class simopt.input_models.Normal
Bases:
InputModelNormal distribution wrapper.
- random(mu: float = 0.0, sigma: float = 1.0) float
Sample from Normal(mu, sigma).
- Parameters:
mu (float) – Mean.
sigma (float) – Standard deviation.
- Returns:
A normal variate.
- Return type:
float