Experiments and results

Sweeps

cimba.sweep(*values)

Create an independent design axis. Assign it to a Param field, a distribution parameter, an Input/Series field (as a sweep of sources), or a child model field (as a sweep of model objects: one model tree per option). Independent sweeps cross. A single list argument is accepted: sweep([a, b, c]). Results.levels returns the swept values, including the model objects of a model sweep.

The returned object has values and one method:

cimba.map(function)

A new sweep on the same axis with function applied to each value.

cimba.sweeps(*columns)

Create linked sweeps that share one axis, one per column. All columns must have the same, nonzero length. Returns a tuple of sweeps.

cimba.options(value)

Return a sweep’s tuple of options, or (value,) for an ordinary value. Host-only helper; lists are ordinary values and are not flattened.

Experiment

class cimba.Experiment(model, *, replications=1, window=None, seed=0, seeding='common', seeds=None)

Snapshot and validate a configured model for running.

Parameters:
  • model – The root Model instance.

  • replications – Trials per design point (≥ 1).

  • window – A Window; default Window.until_idle().

  • seed – Base seed of the experiment.

  • seeding – "common" (same seed per replication across design points) or "independent".

  • seeds – Explicit seeds, shaped (replications,) or (points, replications); overrides seed/seeding.

Raises:

cimba.schema.ModelDefinitionError – for missing or invalid configuration (the message names the instance path).

run(*, workers=None, on_failure='record', input_memory=1 << 30)

Compile (if needed) and run every trial; return Results.

Parameters:
  • workers – Worker threads; None uses all cores.

  • on_failure – "record", or "raise" to raise TrialsFailed if any trial fails.

  • input_memory – Byte budget for host-generated input rows; replications are chunked to fit.

only(*, trials, workers=1, on_failure='record', input_memory=1 << 30)

Rerun selected trials with their original seeds. trials holds flattened indices point * replications + replication. Returns a Results with one design point per selected trial.

describe()

A list of {"instance", "field", "kind", "source"} rows.

replications
window
seed
seeding
class cimba.Window(warmup=0.0, duration=inf, cooldown=0.0)

The measurement window of every trial. duration must be positive. An infinite duration means run until idle, with no warmup or cooldown.

classmethod until_idle()

Window(): run until no events remain, recording from time 0.

Results

class cimba.Results

Immutable outcome of Experiment.run().

__getitem__(model)

Results for a static model instance (including every option of a model sweep, with nan outputs where it wasn’t selected), with one attribute per field: Samples for outputs, an InputRecord for inputs and series, a Signal for captured entities.

failed

(points, replications) bool array.

failure_reasons

(points, replications) string array.

seeds

(points, replications) uint64 array of trial seeds.

meta

Read-only mapping: wall_time, workers, compile (misses, wall_time), extensions, native_failed, chunks when replications were chunked, and variants (model trees run) when a child model is swept.

levels(sweep)

The sweep’s value at each design point, as a tuple.

to_table()

One dict per trial: point, replication, seed, failed, reason and "Class.output" columns.

class cimba.Samples

One output across the design.

values

Read-only float64 array (points, replications); failed trials are nan.

shape

Supports indexing (samples[p, r]) and numpy.asarray.

class cimba.Signal

A captured entity history.

trial(point, replication)

Read-only (times, values) arrays for one trial.

class cimba.results.InputRecord

An input’s record in the results.

source

Tuple of provenance dicts, one per design point.

consumed

(points, replications) values consumed per trial.

extended

(points, replications) extensions per trial.

rows(point, replication)

Regenerate the exact values the trial consumed (read-only array).

Errors

Exception

Raised when

cimba.schema.ModelDefinitionError

the configured model is incomplete or inconsistent (at Experiment(...)).

cimba.experiments.run.ExperimentConfigError

run settings are invalid (replications, window, seeds, memory).

cimba.compiler.ModelCompileError

a model method can’t be compiled; the message gives file:line.

cimba.experiments.run.TrialsFailed

trials failed and on_failure="raise".

cimba.inputs.InputError

a source has invalid parameters or data.

cimba.modeling.NotInCompiledCode

a compiled-only call is made on the host.

TypeError

an assignment of the wrong kind (for example a sweep on a plain field).