Skip to content

laser.measles.biweekly.model

model

A class to represent the biweekly model.

BiweeklyModel(scenario, params, name='biweekly')

Bases: BaseLaserModel

Population-level measles model with 14-day (biweekly) timesteps.

Tracks SEIR compartment counts per patch without individual agents, making it significantly faster than ABMModel for large-scale parameter sweeps and multi-country analyses. Choose this model when individual-level detail is not required and computational speed is a priority. For daily timesteps with explicit SEIR compartment dynamics, see CompartmentalModel.

This is the first object created in the build model stage of the researcher workflow. After construction, attach components with add_component or by setting the components property, then call model.run().

Parameters:

Name Type Description Default
scenario DataFrame | BaseBiweeklyScenario

Metapopulation patch data. Required columns: id (str), pop (int), lat (Float64), lon (Float64), mcv1 (Float64). A plain polars.DataFrame is automatically wrapped.

required
params BiweeklyParams

Simulation parameters including num_ticks, seed, and start_time.

required
name str

Display name for log messages. Defaults to "biweekly".

'biweekly'

Examples:

1
2
3
4
5
6
from laser.measles.biweekly import BiweeklyModel, BiweeklyParams

params = BiweeklyParams(num_ticks=26, seed=42, start_time="2000-01")
model = BiweeklyModel(scenario=df, params=params)
model.components = [InfectionSeedingProcess, InfectionProcess]
model.run()

__call__(model, tick)

Updates the model for the next tick.

Parameters:

Name Type Description Default
model

The model containing the patches and their populations.

required
tick int

The current time step or tick.

required

Returns:

Type Description
None

None

infect(indices, num_infected)

Infects the given nodes with the given number of infected individuals.

Parameters:

Name Type Description Default
indices int | ndarray

The indices of the nodes to infect.

required
num_infected int | ndarray

The number of infected individuals to infect.

required

recover(indices, num_recovered)

Recovers the given nodes with the given number of recovered individuals. Moves individuals from Infected to Recovered compartment.

Parameters:

Name Type Description Default
indices int | ndarray

The indices of the nodes to recover.

required
num_recovered int | ndarray

The number of recovered individuals.

required