Skip to content

laser.measles.biweekly.model

laser.measles.biweekly.model

A class to represent the biweekly model.

laser.measles.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'

Example:

1
2
3
4
5
6
7
8
```python
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()
```

laser.measles.biweekly.model.BiweeklyModel.__call__(model, tick)

Updates the model for the next tick.

Args:

1
2
model: The model containing the patches and their populations.
tick (int): The current time step or tick.

Returns:

1
None

laser.measles.biweekly.model.BiweeklyModel.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

laser.measles.biweekly.model.BiweeklyModel.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