Skip to content

laser.cohorts.SIR

SIR

SIR model component preset.

Assembles the Susceptible, Infectious (with recovery to R), and Recovered compartments with SI-style transmission for use as a standalone SIR model.

Infectious

Infectious(model, r_recovery=None, validating=False)

Bases: Infectious

Infectious (I) compartment with recovery to R.

Extends Infectious by drawing newly recovered individuals each tick and moving them from I to R. Used in SIR and SEIR model configurations.

Initialize the InfectiousToRecovered component.

Parameters:

Name Type Description Default
model Model

The parent model instance.

required
r_recovery ValuesMap | None

Per-tick, per-node recovery rate (I → R). Defaults to zero if not provided.

None
validating bool

Enable validation checks during simulation.

False

properties property

properties

Return node properties required by this component.

Returns:

Type Description
list[PropertyType]

list[PropertyType]: Parent properties plus ("newly_recovered", nticks, np.int32, 0).

states property

states

Return the compartment state names managed by this component.

Returns:

Type Description
list[str]

list[str]: Parent states plus ["R"].

step

step(tick)

Apply recovery (I → R) to infectious individuals.

Draws newly recovered individuals from a binomial using r_recovery, moving them from I to R and recording the flow in nodes.newly_recovered.

Parameters:

Name Type Description Default
tick int

Current simulation tick (0-indexed).

required

Recovered

Recovered(model, validating=False)

Recovered (R) compartment component.

Tracks the recovered population and applies non-disease mortality each time step. Initial R counts are read from the scenario at setup.

Initialize the Recovered component.

Parameters:

Name Type Description Default
model Model

The parent model instance.

required
validating bool

Enable validation checks during simulation.

False

properties property

properties

Return node properties required by this component.

Returns:

Type Description
list[PropertyType]

list[PropertyType]: Empty list; mortality tracking belongs to NonDiseaseMortality.

states property

states

Return the compartment state names managed by this component.

Returns:

Type Description
list[str]

list[str]: ["R"]

end_step

end_step(tick)

No-op end-of-step hook for the R compartment.

Parameters:

Name Type Description Default
tick int

Current simulation tick (0-indexed).

required

setup

setup()

Initialize state R at tick 0 from the scenario R column.

start_step

start_step(tick)

No-op start-of-step hook; carry-forward is handled by the Model.

Parameters:

Name Type Description Default
tick int

Current simulation tick (0-indexed).

required

step

step(tick)

No-op step hook for the R compartment.

Parameters:

Name Type Description Default
tick int

Current simulation tick (0-indexed).

required

Susceptible

Susceptible(model, validating=False)

Susceptible (S) compartment component.

Tracks the susceptible population and applies non-disease mortality each time step. Initial S counts are read from the scenario at setup.

Initialize the Susceptible component.

Parameters:

Name Type Description Default
model Model

The parent model instance.

required
validating bool

Enable validation checks during simulation.

False

properties property

properties

Return node properties required by this component.

Returns:

Type Description
list[PropertyType]

list[PropertyType]: Empty list; mortality tracking belongs to NonDiseaseMortality.

states property

states

Return the compartment state names managed by this component.

Returns:

Type Description
list[str]

list[str]: ["S"]

end_step

end_step(tick)

No-op end-of-step hook for the S compartment.

Parameters:

Name Type Description Default
tick int

Current simulation tick (0-indexed).

required

setup

setup()

Initialize state S at tick 0 from the scenario S column.

start_step

start_step(tick)

No-op start-of-step hook; carry-forward is handled by the Model.

Parameters:

Name Type Description Default
tick int

Current simulation tick (0-indexed).

required

step

step(tick)

No-op step hook for the S compartment.

Parameters:

Name Type Description Default
tick int

Current simulation tick (0-indexed).

required

Transmission

Transmission(
    model, beta, seasonality=None, validating=False
)

Bases: TransmissionCommon

Transmission component that moves individuals directly from S to I.

Specialises TransmissionCommon for models without an exposed period (SI, SIR, SIS, SIRS). Newly infected individuals enter the I compartment immediately.

Initialize the S → I transmission component.

Parameters:

Name Type Description Default
model Model

The parent model instance.

required
beta ValuesMap

Per-tick, per-node transmission rate.

required
validating bool

Enable validation checks during simulation.

False

properties property

properties

Return node properties required by this component.

Returns:

Type Description
list[PropertyType]

list[PropertyType]: Parent properties plus ("newly_infectious", nticks, np.int32, 0).

states property

states

Return the compartment state names managed by this component.

Returns:

Type Description
list[str]

list[str]: Parent states plus ["I"].