Auto-generated API listing
Generated from the source code. The hand-written pages in this section explain semantics in more depth.
cimba
Object-addressed discrete-event models and source-agnostic inputs.
- class cimba.Array(contents=0)
A fixed-length table of
int,floatorboolvalues.Declare the field as
cb.Array[int](orfloat,bool). The length is configuration, not code:Array(4)is four zeros (orFalse),Array([1, 2, 3])holds those initial values. Assign one as a class default or on the host, or sweep it withcb.sweep(Array(2), Array(4)); a spawned model takes its length as an int spawn argument (cb.spawn(Case, joins=n)) or uses the class default. Every trial, and every spawned model, starts from the configured contents.In compiled model code an array field supports
a[i],a[i] = v,a[i] += 1,len(a)andfor x in a. Indices run from 0 tolen(a) - 1; any other index, including a negative one, fails the trial. Arrays are per-trial state, not results.- Parameters:
contents (int | list | tuple)
- class cimba.Condition(*, observe=())
A wait for a predicate over model state.
A waiting process resumes when a signal finds its predicate true. Model code signals with
signal(). A condition can also observe entities: every change to an observed entity signals it, as ifsignal()were called right after.observetakes entities of the same model tree:Resource,Store,PriorityStore,ContainerorFractionalContainer.- Parameters:
observe (Entity | tuple[Entity, ...] | list[Entity])
- observe(*entities)
Also observe
entities, for those that exist only after this condition, such as a parent’s inattached(). Returns the condition.- Parameters:
entities (Entity)
- Return type:
Condition
- wait_until(predicate, timeout=inf)
Wait for a predicate, returning whether it holds on return.
A finite timeout bounds the wait in simulation time. Zero polls the predicate without blocking; infinity waits without a deadline.
- Parameters:
timeout (float)
- Return type:
bool
- class cimba.Container(initial=0)
A counted level of whole units.
initialunits are present when each trial starts.Amounts are
int; useFractionalContainerfor fractional amounts.- Parameters:
initial (int)
- class cimba.Decision(low, high, step=None, log=False, parent=None, transform=None)
A parameter domain; identity links fields to the same search dimension.
- Parameters:
low (float)
high (float)
step (float | None)
log (bool)
parent (Decision | None)
transform (Any)
- class cimba.FractionalContainer(initial=0.0, *, capacity=inf, decimals=6)
A level with fractional amounts, such as kilograms of flour in a silo.
The level is kept in fixed point with
decimalsdecimal places. Amounts are rounded half away from zero to that many places once, and every put and get after that is exact, so the level never drifts from what was put in minus what was taken out.initialis present when each trial starts, andputwaits while the level is atcapacity.roundrounds an amount computed outside the level the same way, so it compares exactly with the level.- Parameters:
initial (float)
capacity (float)
decimals (int)
- class cimba.Input
A sequence input. In model code, consume it with
next().
- class cimba.Model(*args, **kwargs)
A configured model node; constructing it does not compile or run code.
- attached(owner, field)
Host hook called after this model is assigned to an owned field.
Each child sweep option and each owned list item receives the same owner and field name. Override to bind a reference back to the owner.
- Parameters:
owner (Model)
field (str)
- Return type:
None
- class cimba.PriorityStore(*, capacity=1000000000)
- Parameters:
capacity (int)
- class cimba.Resource(*, capacity=1)
A pool of
capacityidentical units, possibly zero.capacityis the capacity each trial starts with, kept asinitial_capacity. Model code reads the current capacity withcapacity()and changes it withset_capacity().- Parameters:
capacity (int)
- class cimba.Results(by_object: 'MappingProxyType', failed: 'np.ndarray', failure_reasons: 'np.ndarray', seeds: 'np.ndarray', meta: 'RunMeta', design: 'Any')
- Parameters:
by_object (MappingProxyType)
failed (ndarray)
failure_reasons (ndarray)
seeds (ndarray)
meta (RunMeta)
design (Any)
- class cimba.Samples(values: 'np.ndarray')
- Parameters:
values (ndarray)
- class cimba.Series(*, step, origin=0.0)
A time-indexed input.
stepandorigindefine its buckets.- Parameters:
step (float)
origin (float)
- class cimba.Signal(trials)
Captured series addressed by design point and replication.
- Parameters:
trials (tuple[tuple[tuple[ndarray, ndarray], ...], ...])
- trial(point, replication)
Return read-only
(times, values)arrays for one trial.- Parameters:
point (int)
replication (int)
- class cimba.Store(*, capacity=1000000000)
- Parameters:
capacity (int)
- class cimba.Window(warmup: 'float' = 0.0, duration: 'float' = inf, cooldown: 'float' = 0.0)
- Parameters:
warmup (float)
duration (float)
cooldown (float)
- cimba.acquire_any(resources, priority=None)
Wait for one unit of whichever resource grants first; return its index.
resourcesis a tuple of resources, such as(self.clerks, self.seniors), or alist[cb.Ref[cb.Resource]]field, such asself.pool.resources, whose members and length are configuration. A free unit is taken at once, from the first listed resource that has one. Otherwise the request waits in every resource’s queue, with the place anacquire()would get, and the first to grant serves it. A resource listed twice counts at its first index. The unit is an ordinary holding of that resource: release it with itsrelease().priorityranks the request as foracquire(). Returns the negative signal instead if the wait is interrupted (-2) or preempted (-1), or ends with any other signal. An empty list fails the trial.- Parameters:
resources (tuple[Resource, ...] | list[Resource])
priority (int | None)
- Return type:
int
- cimba.cache_info()
Report in-memory class compilation cache usage.
- cimba.clear_cache()
Discard compiled class callbacks after current runs have finished.
- Return type:
None
- cimba.decision(low, high, *, step=None, log=False)
Choose a Param’s value in inclusive bounds during an Optimization.
- Return type:
Decision
- cimba.engine_version()
Version of the bundled Cimba engine.
- Return type:
str
- cimba.function(method)
Make a method callable from compiled model code, with dynamic dispatch.
Parameters and the return value must be annotated with
float,int,boolor a model class (Nonefor no return value). Subclasses may override it with the same signature; calls through a base-typed reference or list run the implementation of the model’s actual class. On the host the method stays an ordinary Python method.
- cimba.is_dynamic(model)
Whether this instance was spawned, even if it has been released.
Available only in compiled model code. Static tree instances return False. This reports creation mode, not whether the model is still active.
- Parameters:
model (Model)
- Return type:
bool
- cimba.options(value)
Return a sweep’s options, or a one-item tuple for an ordinary value.
- Parameters:
value (T | Sweep[T])
- Return type:
tuple[T, …]
- cimba.release(model)
Stop this model’s processes, whether it is static or spawned.
Releasing the caller’s own model ends the calling process. Static records, children and end hooks remain; spawned models are retired as before.
- Parameters:
model (Model)
- Return type:
None
- cimba.set_engine_log_level(flags)
Set the native engine’s category bitmask for subsequent runs.
- Parameters:
flags (int)
- Return type:
None
- cimba.spawn(model_class, /, **fields)
Create a model of
model_classduring the trial and start it.Keyword arguments set its fields: scalar values, references, input handles to clone, and an int length for each
cb.Arrayfield.- Parameters:
model_class (type[M])
fields (Any)
- Return type:
M
- cimba.sweep(*values)
An independent design axis:
sweep(a, b, c)orsweep([a, b, c]).- Parameters:
values (T)
- Return type:
Sweep[T]
cimba.inputs
Sources for model inputs: distributions, recordings and resampled data.
- class cimba.inputs.DistributionSource(method: 'str', parameters: 'tuple[tuple[str, Any], ...]', on_exhausted: 'str' = 'fail', tag: 'str | None' = None)
- Parameters:
method (str)
parameters (tuple[tuple[str, Any], ...])
on_exhausted (str)
tag (str | None)
- class cimba.inputs.FitResult(source: 'DistributionSource', aic: 'float', ks: 'float', log_likelihood: 'float')
- Parameters:
source (DistributionSource)
aic (float)
ks (float)
log_likelihood (float)
- class cimba.inputs.GeneratedRows(method, data, fingerprint, parameters, draw, tag=None, prefix_stable=True, max_length=None, length_hint=None, on_exhausted='extend')
A finite row source whose generator consumes RNG draws in prefix order.
- Parameters:
method (str)
data (ndarray[tuple[Any, ...], dtype[float64]])
fingerprint (str)
parameters (tuple[tuple[str, Any], ...])
draw (Callable[[Generator, int], ndarray[tuple[Any, ...], dtype[float64]]])
tag (str | None)
prefix_stable (bool)
max_length (int | None)
length_hint (int | None)
on_exhausted (str)
- exception cimba.inputs.InputError
An input cannot be bound or generated as requested.
- class cimba.inputs.RowSource(*args, **kwargs)
- class cimba.inputs.Source(*args, **kwargs)
- class cimba.inputs.TraceSource(values: 'NDArray[np.float64]', fingerprint: 'str', on_exhausted: 'str' = 'fail')
- Parameters:
values (ndarray[tuple[Any, ...], dtype[float64]])
fingerprint (str)
on_exhausted (str)
- cimba.inputs.fit(data, candidates=None)
Return supported maximum-likelihood fits ordered by AIC.
- Parameters:
data (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
candidates (Sequence[Callable[[...], DistributionSource]] | None)
- Return type:
tuple[FitResult, …]
- cimba.inputs.trace_rng(seed, tag)
Derive a stable stream without consuming another input’s RNG.
- Parameters:
seed (int)
tag (str)
- Return type:
Generator
Parametric sources drawn in the native trial on per-input streams.
Prefix-stable bootstrap sources for recorded sequences and panels.
- class cimba.inputs.bootstrap.JointMembers(panel, mean_block, tag)
Members of a panel resample, indexed like the supplied panel.
- Parameters:
panel (Mapping[Any, ArrayLike] | Sequence[ArrayLike])
mean_block (float)
tag (str | None)
Fitted time-series sources, generated outside simulation trials.
cimba.analysis
Post-run summaries, paired comparisons and input-model checks.
- class cimba.analysis.Comparison(a: 'int', b: 'int', n: 'int', difference: 'float', lower: 'float', upper: 'float')
- Parameters:
a (int)
b (int)
n (int)
difference (float)
lower (float)
upper (float)
- class cimba.analysis.InputCheck(reference_mean: 'float', generated_mean: 'float', reference_variance: 'float', generated_variance: 'float', reference_quantiles: 'tuple[float, ...]', generated_quantiles: 'tuple[float, ...]', reference_acf: 'tuple[float, ...]', generated_acf: 'tuple[float, ...]', reference_pacf: 'tuple[float, ...]', generated_pacf: 'tuple[float, ...]', ks_statistic: 'float', ks_pvalue: 'float')
- Parameters:
reference_mean (float)
generated_mean (float)
reference_variance (float)
generated_variance (float)
reference_quantiles (tuple[float, ...])
generated_quantiles (tuple[float, ...])
reference_acf (tuple[float, ...])
generated_acf (tuple[float, ...])
reference_pacf (tuple[float, ...])
generated_pacf (tuple[float, ...])
ks_statistic (float)
ks_pvalue (float)
- class cimba.analysis.JointInputCheck(keys: 'tuple', members: 'tuple[InputCheck, ...]', reference_correlation: 'np.ndarray', generated_correlation: 'np.ndarray')
- Parameters:
keys (tuple)
members (tuple[InputCheck, ...])
reference_correlation (ndarray)
generated_correlation (ndarray)
- class cimba.analysis.Summary(n: 'np.ndarray', mean: 'np.ndarray', std: 'np.ndarray', lower: 'np.ndarray', upper: 'np.ndarray')
- Parameters:
n (ndarray)
mean (ndarray)
std (ndarray)
lower (ndarray)
upper (ndarray)