βοΈ Configurationsο
Configuration models and registries for simulator components.
βοΈ Rootsο
Reusable root configuration types for simulation parameters and source.
- class phyloom.configs.roots.ContextCfg(*, root: dict[str, DistributionCfg | NumPyExpressionCfg] = {})[source]ο
Bases:
RootModel[dict[str,DistributionCfg|NumPyExpressionCfg]]Configuration for the sample-specific context variables.
For every sample, the context is materialized into sample-specific parameter values: each entry is either drawn from its prior distribution or evaluated as an expression, such as a fixed constant or a quantity derived from earlier entries.
- class phyloom.configs.roots.DistributionCfg(*, type: StrCfg)[source]ο
Bases:
BaseModelConfiguration for a context variable drawn from a prior distribution.
- Parameters:
type β Name of the
numpy.random.Generatordistribution method, such as"uniform","lognormal", or"integers".**extra_data β Keyword arguments accepted by that NumPy distribution method.
- class phyloom.configs.roots.ExpressionCfg(*, root: str)[source]ο
-
Base configuration for a Python expression that produces a value.
The expression is syntax-checked during validation and evaluated later, during a simulation. It sees the materialized context,
numpyasnp, and the keyword bindings passed toevaluate()orevaluate_typed(), which take precedence over context names. Subclasses implementcontextualizeto return a function that evaluates the expression each time it is called. The source is not sandboxed, so configuration input must be trusted.- evaluate(context: Context, **bindings: object) object[source]ο
Evaluate the expression and return its raw value.
- evaluate_typed(context: Context, typeguard: NamedTypeguard[T], **bindings: object) T[source]ο
Evaluate the expression and check its type.
NumPy results are converted to plain Python values before the value is checked with
typeguard.
- class phyloom.configs.roots.FloatCfg(*, root: NumPyExpressionCfg)[source]ο
Bases:
RootModel[NumPyExpressionCfg]Configuration for a float-valued NumPy expression.
- class phyloom.configs.roots.FloatSequenceCfg(*, root: NumPyExpressionCfg | Sequence[FloatCfg])[source]ο
Bases:
RootModel[NumPyExpressionCfg|Sequence[FloatCfg]]Configuration for a sequence of floats.
The sequence is given either as a list of float-valued expressions or as a single NumPy expression that evaluates to a sequence of floats.
- class phyloom.configs.roots.IntCfg(*, root: NumPyExpressionCfg)[source]ο
Bases:
RootModel[NumPyExpressionCfg]Configuration for an integer-valued NumPy expression.
- class phyloom.configs.roots.ModelActionCfg(*, root: str)[source]ο
Bases:
StatementCfgConfiguration for statements acting on the current model.
- class phyloom.configs.roots.ModelExpressionCfg(*, root: str)[source]ο
Bases:
ExpressionCfgConfiguration for an expression of the current model with any result.
- class phyloom.configs.roots.ModelPredicateCfg(*, root: str)[source]ο
Bases:
ExpressionCfgConfiguration for a boolean expression of the current model.
- class phyloom.configs.roots.NonNegativeModelFnCfg(*, root: str)[source]ο
Bases:
ExpressionCfgConfiguration for a non-negative float expression of the current model.
- class phyloom.configs.roots.NonNegativeTimeFnCfg(*, root: str)[source]ο
Bases:
ExpressionCfgConfiguration for a non-negative float expression of the time.
- class phyloom.configs.roots.NumPyExpressionCfg(*, root: str)[source]ο
Bases:
ExpressionCfgConfiguration for a NumPy expression.
- class phyloom.configs.roots.OutputHookCfg(*, root: str)[source]ο
Bases:
StatementCfgConfiguration for statements of the current model and the sampleβs output directory.
- class phyloom.configs.roots.PostCommandCfg(*, root: str)[source]ο
-
Configuration for a context-interpolated shell command run on the output directory of a sample.
Interpolation is performed using standard Python string formatting (
str.format()), where{name}placeholders matching context variables are replaced with their corresponding values, and the{output_dir}placeholder with the sampleβs output directory. The command runs through the system shell and is not sandboxed, so configuration input must be trusted.
- class phyloom.configs.roots.StatementCfg(*, root: str)[source]ο
-
Base configuration for Python statements run for their side effects.
The statements are syntax-checked during validation and run later, during a simulation. They see the materialized context,
numpyasnp, and the keyword bindings passed toexecute(), which take precedence over context names. Subclasses implementcontextualizeto return a function that runs the statements each time it is called. The source is not sandboxed, so configuration input must be trusted.
- class phyloom.configs.roots.StrCfg(*, root: str)[source]ο
-
Configuration for a context-interpolated string.
Interpolation is performed using standard Python string formatting (
str.format()), where{name}placeholders matching context variables are replaced with their corresponding values.
π‘οΈ Typeguardsο
Typeguards for type-safe evaluation of Python source code in configuration.
- phyloom.configs.roots.typeguards.is_bool(value: object) TypeGuard[bool][source]ο
Check if a value is a bool.
- phyloom.configs.roots.typeguards.is_int(value: object) TypeGuard[int][source]ο
Check if a value is an int (but not a bool).
- phyloom.configs.roots.typeguards.is_float(value: object) TypeGuard[float][source]ο
Check if a value is a float (or an int, but not a bool).
- phyloom.configs.roots.typeguards.is_sequence(value: object) TypeGuard[Sequence[object]][source]ο
Check if a value is a sequence (but not a string).
- phyloom.configs.roots.typeguards.is_float_sequence(value: object) TypeGuard[Sequence[float]][source]ο
Check if a value is a sequence of floats.
- class phyloom.configs.roots.typeguards.NamedTypeguard(name: str, fn: Callable[[object], TypeGuard[T]])[source]ο
Bases:
Generic[T]A typeguard paired with a human-readable name used in error messages.
- Parameters:
name β Description of the expected type.
fn β Function that checks whether a value has the expected type.
- phyloom.configs.roots.typeguards.BOOL_TG = NamedTypeguard(name='bool', fn=<function is_bool>)ο
Typeguard accepting a bool.
- phyloom.configs.roots.typeguards.INT_TG = NamedTypeguard(name='int', fn=<function is_int>)ο
Typeguard accepting an int, but not a bool.
- phyloom.configs.roots.typeguards.FLOAT_TG = NamedTypeguard(name='float', fn=<function is_float>)ο
Typeguard accepting a float or an int, but not a bool.
- phyloom.configs.roots.typeguards.FLOAT_SEQUENCE_TG = NamedTypeguard(name='sequence of floats', fn=<function is_float_sequence>)ο
Typeguard accepting a sequence of floats.
π² Hazardsο
Configuration models for time-dependent event hazards.
- class phyloom.configs.hazards.HazardCfgBase[source]ο
-
Base configuration for a
Hazard.Subclasses declare the hazard parameters as fields and build the runtime hazard from them in
contextualize(). Concrete configurations are registered inHAZARD_REGISTRYand selected by theirspeckey. Hazards do not depend on the model type, so any registered hazard can be combined with any event rule.
- phyloom.configs.hazards.HAZARD_REGISTRY: Registry[HazardCfgBase] = Registry(name='Hazard', base_type='HazardCfgBase', keys=['constant', 'delta', 'exponential', 'skyline', 'numeric'])ο
Registry of concrete hazard configurations keyed by their
specvalue. It also supplies the validator used byHazardCfg.
- type phyloom.configs.hazards.HazardCfgο
Hazard configuration type resolved by
HAZARD_REGISTRY. Alias forAnnotated[HazardCfgBase,HAZARD_REGISTRY.validator].
- class phyloom.configs.hazards.ConstantHazardCfg(*, rate: FloatCfg)[source]ο
Bases:
HazardCfgBaseConfiguration for a
ConstantHazardwith a constant per-opportunity rate.Registered under
"constant"inHAZARD_REGISTRY.- Parameters:
rate β Positive per-opportunity event rate.
- contextualize(context: Context) ConstantHazard[source]ο
Build the
ConstantHazardfrom materialized context values.
- class phyloom.configs.hazards.DeltaHazardCfg[source]ο
Bases:
HazardCfgBaseConfiguration for a
DeltaHazardthat fires immediately at a point mass.Registered under
"delta"inHAZARD_REGISTRY.- contextualize(context: Context) DeltaHazard[source]ο
Build the
DeltaHazardfrom materialized context values.
- class phyloom.configs.hazards.ExponentialHazardCfg(*, rate: FloatCfg, decay: FloatCfg)[source]ο
Bases:
HazardCfgBaseConfiguration for a
ExponentialHazardwhose rate changes exponentially with time.Registered under
"exponential"inHAZARD_REGISTRY.- Parameters:
rate β Positive rate at simulated time zero.
decay β Exponential decay or growth parameter. A positive value gives decay, zero gives a constant rate, and a negative value gives growth.
- contextualize(context: Context) ExponentialHazard[source]ο
Build the
ExponentialHazardfrom materialized context values.
- class phyloom.configs.hazards.SkylineHazardCfg(*, rates: FloatSequenceCfg, break_times: FloatSequenceCfg)[source]ο
Bases:
HazardCfgBaseConfiguration for a
SkylineHazardwith piecewise-constant rates.Registered under
"skyline"inHAZARD_REGISTRY.- Parameters:
rates β Non-negative per-interval rates, ordered from earliest to latest interval.
break_times β Positive, strictly increasing times separating adjacent intervals. Provide one fewer value than
rates.
- contextualize(context: Context) SkylineHazard[source]ο
Build the
SkylineHazardfrom materialized context values.
- class phyloom.configs.hazards.NumericHazardCfg(*, rate_fn: NonNegativeTimeFnCfg, max_bracketing_steps: IntCfg = IntCfg(root=NumPyExpressionCfg(root='16')), initial_dt: FloatCfg = FloatCfg(root=NumPyExpressionCfg(root='1.0')))[source]ο
Bases:
HazardCfgBaseConfiguration for a
NumericHazardwhose rate is numerically inverted over time.Registered under
"numeric"inHAZARD_REGISTRY.- Parameters:
rate_fn β Expression for the non-negative event rate as a function of simulated time.
max_bracketing_steps β Maximum number of interval expansions used to bracket the numerical inversion.
initial_dt β Initial interval width used when searching for a bracket.
- contextualize(context: Context) NumericHazard[source]ο
Build the
NumericHazardfrom materialized context values.
π§± Coreο
Core configuration types and registries for simulator models and events.
- class phyloom.configs.core.EventRuleCfg[source]ο
Bases:
ABC,BaseModel,Generic[ModelT_contra]Base configuration for a model-specific
EventRule.Subclasses declare the parameters of an event rule as fields and build the runtime rule from them in
contextualize(). Event rules act on a specific model type, so concrete configurations are registered in the event-ruleRegistryof that model.
- class phyloom.configs.core.EventCfg(*, rule: RuleCfgT_co, hazard: HazardCfg, rate_multiplier: NonNegativeModelFnCfg | None = None)[source]ο
Bases:
BaseModel,Generic[RuleCfgT_co]Configuration for a model-specific
Event.Concrete model configurations specialize it with their own registry-backed rule type.
- Parameters:
rule β Event-rule configuration that determines which state transitions are eligible and how one is applied.
hazard β Time-dependent per-opportunity hazard used to sample firing times.
rate_multiplier β Optional model expression that scales the eventβs overall rate based on the current model state. It must return a non-negative numeric multiplier; zero disables the event.
- class phyloom.configs.core.ScheduledEventCfg(*, action: ModelActionCfg, times: FloatSequenceCfg)[source]ο
Bases:
BaseModelConfiguration for an action executed at one or more fixed times.
- Parameters:
action β Model statements run at each scheduled time.
times β Non-negative simulated times at which to run the action.
- class phyloom.configs.core.ModelCfgBase[source]ο
-
Base configuration for a
Model.Subclasses declare the model parameters, together with the modelβs
eventsandschedule, as fields and build a new runtime model from them incontextualize(). Concrete configurations are registered inMODEL_REGISTRYand selected by theirspeckey.
- phyloom.configs.core.MODEL_REGISTRY: Registry[ModelCfgBase] = Registry(name='Model', base_type='ModelCfgBase', keys=[])ο
Registry of concrete model configurations keyed by their
specvalue. It also supplies the validator used byModelCfg.
- type phyloom.configs.core.ModelCfgο
Model configuration type resolved by
MODEL_REGISTRY. Alias forAnnotated[ModelCfgBase,MODEL_REGISTRY.validator].
π± BDSHο
Configuration models and event rules for BDSH simulations.
- phyloom.configs.bdsh.BDSH_EVENT_RULE_REGISTRY: Registry[EventRuleCfg[BDSHModel]] = Registry(name='BDSH event rule', base_type='EventRuleCfg[BDSHModel]', keys=['birth', 'death', 'migration', 'sampling', 'ldh', 'lnh', 'lgh'])ο
Registry of concrete BDSH event-rule configurations keyed by their
specvalue. It also supplies the validator used byBDSHEventRuleCfg.
- type phyloom.configs.bdsh.BDSHEventRuleCfgο
BDSH event-rule configuration type resolved by
BDSH_EVENT_RULE_REGISTRY. Alias forAnnotated[EventRuleCfg,BDSH_EVENT_RULE_REGISTRY.validator].
- class phyloom.configs.bdsh.BirthCfg(*, parent_state: StrCfg | None = None, child_states: tuple[StrCfg | None, StrCfg | None] = (None, None))[source]ο
Bases:
EventRuleCfg[BDSHModel]Configuration for a
Birthevent that replaces one active lineage with two descendants.Registered under
"birth"inBDSH_EVENT_RULE_REGISTRY.- Parameters:
parent_state β Optional state restricting eligible parent lineages.
child_states β Optional pair of states assigned to the descendant lineages. A
Noneentry inherits the parentβs state.
- class phyloom.configs.bdsh.DeathCfg(*, state: StrCfg | None = None)[source]ο
Bases:
EventRuleCfg[BDSHModel]Configuration for a
Deathevent that finalizes one active lineage without sampling it.Registered under
"death"inBDSH_EVENT_RULE_REGISTRY.- Parameters:
state β Optional state restricting eligible lineages.
- class phyloom.configs.bdsh.MigrationCfg(*, source_state: StrCfg, target_state: StrCfg)[source]ο
Bases:
EventRuleCfg[BDSHModel]Configuration for a
Migrationevent that replaces one active lineage with a continuing child.Registered under
"migration"inBDSH_EVENT_RULE_REGISTRY.- Parameters:
source_state β State restricting eligible parent lineages.
target_state β State assigned to the child lineage.
- class phyloom.configs.bdsh.SamplingCfg(*, removal: bool, state: StrCfg | None = None)[source]ο
Bases:
EventRuleCfg[BDSHModel]Configuration for a
Samplingevent that records one eligible active lineage.Registered under
"sampling"inBDSH_EVENT_RULE_REGISTRY.- Parameters:
state β Optional state restricting eligible lineages.
removal β Whether to end the sampled lineage. If
False, the lineage first branches; one descendant is recorded as the sample at the current time, and the other remains active.
- class phyloom.configs.bdsh.LDHCfg(*, parent_states: StrPairCfg | None = None, hybrid_state: StrCfg | None = None)[source]ο
Bases:
EventRuleCfg[BDSHModel]Configuration for a
LDH(lineage-degenerative hybridization) event that replaces two active lineages with one hybrid child.Registered under
"ldh"inBDSH_EVENT_RULE_REGISTRY.- Parameters:
parent_states β Optional pair of states restricting the two parent lineages.
hybrid_state β Optional state assigned to the hybrid child. If omitted, the parents must share the same state, which the child inherits.
- class phyloom.configs.bdsh.LNHCfg(*, continuing_parent_state: StrCfg | None = None, terminating_parent_state: StrCfg | None = None, new_parent_state: StrCfg | None = None, hybrid_state: StrCfg | None = None)[source]ο
Bases:
EventRuleCfg[BDSHModel]Configuration for a
LNH(lineage-neutral hybridization) event.Registered under
"lnh"inBDSH_EVENT_RULE_REGISTRY.- Parameters:
continuing_parent_state β Optional state restricting the primary (birth-giving) parent lineage.
terminating_parent_state β Optional state restricting the secondary (hybridizing) parent lineage.
new_parent_state β Optional state assigned to the continuing primary (birth-giving) parent lineage. If omitted, the continuing lineage inherits the parentβs state.
hybrid_state β Optional state assigned to the resulting hybrid lineage. If omitted, the parents must share the same state, which the child inherits.
- class phyloom.configs.bdsh.LGHCfg(*, parent_states: StrPairCfg | None = None, hybrid_state: StrCfg | None = None, new_parent_states: tuple[StrCfg | None, StrCfg | None] = (None, None))[source]ο
Bases:
EventRuleCfg[BDSHModel]Configuration for a
LGH(lineage-generative hybridization) event.Registered under
"lgh"inBDSH_EVENT_RULE_REGISTRY.- Parameters:
parent_states β Optional pair of states restricting the two parent lineages.
hybrid_state β Optional state assigned to the resulting hybrid lineage. If omitted, the parents must share the same state, which the child inherits.
new_parent_states β Optional pair of states assigned to the continuing parent lineages, in the same order as
parent_states. ANoneentry inherits the parentβs state.
- class phyloom.configs.bdsh.BDSHModelCfg(*, init_state: StrCfg, events: tuple[EventCfg[BDSHEventRuleCfg], ...] = (), schedule: tuple[ScheduledEventCfg, ...] = ())[source]ο
Bases:
ModelCfgBaseConfiguration for a
BDSHModel.Registered under
"bdsh"inMODEL_REGISTRY. Each event selects its rule byspecfromBDSH_EVENT_RULE_REGISTRY.- Parameters:
init_state β State assigned to the initial active lineage.
events β Stochastic events governing continuous-time state transitions.
schedule β Deterministic actions executed at configured simulated times. Actions scheduled for the same time are shuffled before execution.
π Coalescentο
Configuration models and event rules for coalescent simulations.
- phyloom.configs.coalescent.COALESCENT_EVENT_RULE_REGISTRY: Registry[EventRuleCfg[CoalescentModel]] = Registry(name='Coalescent event rule', base_type='EventRuleCfg[CoalescentModel]', keys=['retrace', 'coalesce'])ο
Registry of concrete coalescent event-rule configurations keyed by their
specvalue. It also supplies the validator used byCoalescentEventRuleCfg.
- type phyloom.configs.coalescent.CoalescentEventRuleCfgο
Coalescent event-rule configuration type resolved by
COALESCENT_EVENT_RULE_REGISTRY. Alias forAnnotated[EventRuleCfg,COALESCENT_EVENT_RULE_REGISTRY.validator].
- class phyloom.configs.coalescent.RetraceCfg(*, ancestral_state: StrCfg, current_state: StrCfg | None = None)[source]ο
Bases:
EventRuleCfg[CoalescentModel]Configuration for a
Retraceevent that replaces one active lineage with an ancestral parent.Registered under
"retrace"inCOALESCENT_EVENT_RULE_REGISTRY.- Parameters:
ancestral_state β State assigned to the new parent.
current_state β Optional state restricting eligible lineages.
- class phyloom.configs.coalescent.CoalesceCfg(*, current_states: StrPairCfg | None = None, ancestral_state: StrCfg | None = None)[source]ο
Bases:
EventRuleCfg[CoalescentModel]Configuration for a
Coalesceevent that replaces two active lineages with one ancestral parent.Registered under
"coalesce"inCOALESCENT_EVENT_RULE_REGISTRY.- Parameters:
current_states β Optional pair of states restricting the child pair.
ancestral_state β Optional state assigned to the ancestral parent. If omitted, the child lineages must share the same state, which the parent inherits.
- class phyloom.configs.coalescent.CoalescentModelCfg(*, init_population: dict[str, IntCfg], events: tuple[EventCfg[CoalescentEventRuleCfg], ...] = (), schedule: tuple[ScheduledEventCfg, ...] = ())[source]ο
Bases:
ModelCfgBaseConfiguration for a
CoalescentModel.Registered under
"coalescent"inMODEL_REGISTRY. Each event selects its rule byspecfromCOALESCENT_EVENT_RULE_REGISTRY.- Parameters:
init_population β Positive number of initial active lineages for each state.
events β Stochastic events governing continuous-time state transitions.
schedule β Deterministic actions executed at configured simulated times. Actions scheduled for the same time are shuffled before execution.
- contextualize(context: Context) CoalescentModel[source]ο
Build the
CoalescentModelfrom materialized context values.
π¦ Epidemicο
Configuration models and event rules for compartmental epidemic simulations.
- phyloom.configs.epidemic.EPIDEMIC_EVENT_RULE_REGISTRY: Registry[EventRuleCfg[EpidemicModel]] = Registry(name='Epidemic event rule', base_type='EventRuleCfg[EpidemicModel]', keys=['infection', 'recovery', 'migration', 'flow'])ο
Registry of concrete epidemic event-rule configurations keyed by their
specvalue. It also supplies the validator used byEpidemicEventRuleCfg.
- type phyloom.configs.epidemic.EpidemicEventRuleCfgο
Epidemic event-rule configuration type resolved by
EPIDEMIC_EVENT_RULE_REGISTRY. Alias forAnnotated[EventRuleCfg,EPIDEMIC_EVENT_RULE_REGISTRY.validator].
- class phyloom.configs.epidemic.InfectionCfg(*, recipient_pool: StrCfg, source_state: StrCfg | None = None, child_states: tuple[StrCfg | None, StrCfg | None] = (None, None))[source]ο
Bases:
EventRuleCfg[EpidemicModel]Configuration for an
Infectionevent that replaces one active lineage with two descendants and decrements a pool.Registered under
"infection"inEPIDEMIC_EVENT_RULE_REGISTRY.- Parameters:
recipient_pool β Pool from which the infected individual is removed.
source_state β Optional state used to restrict eligible source lineages.
child_states β Optional pair of states assigned to the descendant lineages. A
Noneentry inherits the parentβs state.
- class phyloom.configs.epidemic.RecoveryCfg(*, destination_pool: StrCfg, source_state: StrCfg | None = None, sample: bool = False)[source]ο
Bases:
EventRuleCfg[EpidemicModel]Configuration for a
Recoveryevent that finalizes a lineage and increments a pool.Registered under
"recovery"inEPIDEMIC_EVENT_RULE_REGISTRY.- Parameters:
destination_pool β Pool that receives the recovered individual.
source_state β Optional state restricting eligible lineages.
sample β Whether to record the finalized lineage as a sample.
- class phyloom.configs.epidemic.MigrationCfg(*, source_state: StrCfg, target_state: StrCfg)[source]ο
Bases:
EventRuleCfg[EpidemicModel]Configuration for a
Migrationevent that replaces one active lineage with a continuing child.Registered under
"migration"inEPIDEMIC_EVENT_RULE_REGISTRY.- Parameters:
source_state β State restricting eligible parent lineages.
target_state β State assigned to the child lineage.
- class phyloom.configs.epidemic.FlowCfg(*, source_pool: StrCfg, destination_pool: StrCfg)[source]ο
Bases:
EventRuleCfg[EpidemicModel]Configuration for a
Flowevent that moves one individual from a source pool to a destination pool.Registered under
"flow"inEPIDEMIC_EVENT_RULE_REGISTRY.- Parameters:
source_pool β Pool to decrement.
destination_pool β Pool to increment.
- class phyloom.configs.epidemic.EpidemicModelCfg(*, init_state: StrCfg, init_pools: dict[str, IntCfg], events: tuple[EventCfg[EpidemicEventRuleCfg], ...] = (), schedule: tuple[ScheduledEventCfg, ...] = ())[source]ο
Bases:
ModelCfgBaseConfiguration for a
EpidemicModel.Registered under
"epidemic"inMODEL_REGISTRY. Each event selects its rule byspecfromEPIDEMIC_EVENT_RULE_REGISTRY.- Parameters:
init_state β State assigned to the initial infectious lineage.
init_pools β Initial non-negative count for each population pool.
events β Stochastic events governing continuous-time state transitions.
schedule β Deterministic actions executed at configured simulated times. Actions scheduled for the same time are shuffled before execution.
- contextualize(context: Context) EpidemicModel[source]ο
Build the
EpidemicModelfrom materialized context values.
π Runnerο
Configuration and execution entrypoint for the dataset-generation pipeline.
- class phyloom.configs.runner.Runner(*, output_dir: str = 'phyloom-outputs', n_samples: int | dict[str, int] = 1, n_jobs: int = -1, seed: int | None = None, context: ContextCfg = ContextCfg(root={}), model: ModelCfg, max_time: FloatCfg | None = None, stop_criterion: ModelPredicateCfg | None = None, acceptance_criterion: ModelPredicateCfg | None = None, stop_hook: ModelActionCfg | None = None, max_rejections: int | None = None, timeout: float | None = None, logs: dict[str, ModelExpressionCfg] = {}, output_hooks: tuple[OutputHookCfg, ...], post_commands: tuple[PostCommandCfg, ...] = ())[source]ο
Bases:
BaseModelEntry point for the dataset-generation pipeline.
For every sample, the runner materializes sample-specific values from the context priors, builds and advances a model, evaluates the stopping and acceptance criteria, and records the accepted sample. An unsplit run writes its output to
output_dir, and a split run writes each split tooutput_dir/<split>with the same layout:data/<sample_id>/: the files written byoutput_hooksandpost_commandsfor each accepted sample;metadata.csv: one row per sample, with its materialized context values, itslogs, the number of rejected trials (n_rejections), and the wall-clock run time (total_time);timed_out_contexts.csvandmax_rejections_exceeded_contexts.csv: the materialized context values abandoned after a timeout or after too many rejections, if any.
- Parameters:
output_dir β Root directory for generated data. An unsplit run writes its output directly here; split runs create one subdirectory per split.
n_samples β Number of samples, or a mapping from split names to sample counts. Mapping keys name the output split directories.
n_jobs β Number of worker processes passed to
joblib.Parallel().-1uses all available CPUs.seed β Optional seed for the random number generator used to derive per-sample seeds. If
None, a non-deterministic seed source is used.context β Priors of the parameters, as named random draws, constants, and derived expressions. Sample-specific values are drawn from these priors, and can be used in the model configuration, stopping and acceptance criteria, logs, hooks and post-commands. Rejected trials are rerun with the same values; values whose trials time out or exceed the maximum rejection threshold are replaced by a new draw from the priors. The values of each accepted sample are recorded in
metadata.csv.model β Registered model configuration to materialize for each trial.
max_time β Optional inclusive upper bound on simulated time.
stop_criterion β Optional model predicate evaluated after each successful simulation step. A true result ends the trial.
acceptance_criterion β Optional model predicate evaluated after a trial. A false result rejects the trial and starts another one.
stop_hook β Optional model action evaluated after an accepted trial stops.
max_rejections β Maximum number of rejected trials permitted for one context. When the limit is exceeded, the context is replaced and recorded in
max_rejections_exceeded_contexts.csvin the relevant output directory.timeout β Optional wall-clock limit in seconds for one trial. A timed-out context is replaced and recorded in
timed_out_contexts.csvin the relevant output directory.logs β Mapping from metadata column names to model expressions evaluated after an accepted trial. Their results become columns in
metadata.csv.output_hooks β Output-hook statements run in order after each accepted trial. They can write files to the sampleβs output directory.
post_commands β Shell commands run in order, last, after the output hooks of each accepted trial, such as external simulators of sequence or trait evolution that read the files written by the hooks.