Skip to content

laser.cohorts.model

model

Core Model class for cohort-based compartmental disease simulation.

Model

Model(scenario, params=None, carry_forward_states=None)

Compartmental disease model that orchestrates cohort-based simulation components.

Manages a population scenario, a set of epidemiological components, and the discrete-time simulation loop.

Attributes:

Name Type Description
scenario GeoDataFrame

Geographic/demographic scenario defining nodes.

params PropertySet | None

Model parameters, including nticks.

nodes LaserFrame

Per-node property storage.

states StateArray

Compartment state array of shape (nticks+1, n_states, n_nodes).

network ndarray

2-D inter-node mixing matrix of shape (nnodes, nnodes). Defaults to a uniform-zero scalar set at initialisation.

Initialize the Model.

Parameters:

Name Type Description Default
scenario GeoDataFrame

Geographic/demographic scenario; each row is a node.

required
params PropertySet | None

Named model parameters. Must contain nticks before components is assigned.

None
carry_forward_states Iterable[str] | None

Names of compartment states to carry forward at the start of each tick. None (default) carries forward every state. Pass an explicit iterable to restrict carry-forward to a subset. Unknown state names raise ValueError when components is assigned.

None

components property writable

components

Return the list of registered simulation components.

Returns:

Name Type Description
list list

Ordered list of component instances.

network property writable

network

Return the inter-node mixing matrix.

Returns:

Type Description
ndarray

np.ndarray: 2-D array of shape (nnodes, nnodes) whose entry [i, j] gives the connectivity weight from node i to node j.

run

run()

Execute the simulation for params.nticks time steps.

At the start of each tick, carries forward the selected compartment states from tick to tick+1, then calls start_step, step, and end_step on every registered component in order.