Skip to content

epymorph.simulator.basic.ipm_exec

IPMExecutor is part of the internal workings of BasicSimulator, implementing the logic for processing the IPM phase of the simulation. Most users will not use this module directly.

CompiledTransition module-attribute

CompiledTransition = CompiledEdge | CompiledFork

A transition is either a fork or a plain edge.

Result

Bases: NamedTuple

The result from executing a single IPM step.

visit_compartments instance-attribute

visit_compartments: SimArray

updated compartments as a result of these events (an (N,C) array) tracked by the location where the individuals currently are

visit_events instance-attribute

visit_events: SimArray

events that happened this tick (an (N,E) array) tracked by the location where the event occurred

home_compartments instance-attribute

home_compartments: SimArray

updated compartments as a result of these events (an (N,C) array) tracked by the location that the individuals consider home

home_events instance-attribute

home_events: SimArray

events that happened this tick (an (N,E) array) tracked by the home location of the individuals effected

CompiledEdge dataclass

CompiledEdge(rate_lambda: SympyLambda)

Lambdified EdgeDef (no fork). Effectively: poisson(rate * tau).

size class-attribute

size: int = 1

The number of edges in this transition.

rate_lambda instance-attribute

rate_lambda: SympyLambda

The lambdified edge rate.

CompiledFork dataclass

CompiledFork(
    size: int,
    rate_lambda: SympyLambda,
    prob_lambda: SympyLambda,
)

Lambdified ForkDef. Effectively: multinomial(poisson(rate * tau), prob).

size instance-attribute

size: int

The number of edges in this transition.

rate_lambda instance-attribute

rate_lambda: SympyLambda

The lambdified edge base rate.

prob_lambda instance-attribute

prob_lambda: SympyLambda

The lambdified edge fork probabilities.

IPMExecutor

IPMExecutor(
    rume: RUME,
    world: World,
    data: DataResolver,
    rng: Generator,
)

The standard implementation of compartment model IPM execution.

Parameters:

  • rume (RUME) –

    The RUME.

  • world (World) –

    The world state.

  • data (DataResolver) –

    The evaluated data attributes of the simulation.

  • rng (Generator) –

    The simulation RNG.

apply

apply(tick: Tick) -> Result

Apply the IPM for this tick, mutating the world state.

Parameters:

  • tick (Tick) –

    Which tick to process.

Returns:

  • Result

    The location-specific events that happened this tick (an (N,E) array) and the new compartments resulting from these events (an (N,C) array).