laser.measles.biweekly
laser.measles.biweekly
laser.measles.biweekly.BaseScenario = BaseBiweeklyScenario
module-attribute
Base class for scenario data wrappers.
Provides a wrapper around polars DataFrames with additional validation and convenience methods.
Example:
1 2 3 4 5 6 | |
laser.measles.biweekly.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: |
required |
params
|
BiweeklyParams
|
Simulation parameters including
|
required |
name
|
str
|
Display name for log messages. Defaults to
|
'biweekly'
|
Example:
1 2 3 4 5 6 7 8 | |
laser.measles.biweekly.BiweeklyModel.__call__(model, tick)
Updates the model for the next tick.
Args:
1 2 | |
Returns:
1 | |
laser.measles.biweekly.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.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 |
laser.measles.biweekly.BiweeklyParams
Bases: BaseModelParams
Parameters for the biweekly compartmental measles model (14-day timesteps).
Inherits all fields from
BaseModelParams. Each tick
represents 14 days, and the model tracks three SIR states (no explicit
Exposed compartment).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_ticks
|
int
|
Number of biweekly simulation steps (e.g., 26 ≈ 1 year, 130 ≈ 5 years). |
required |
seed
|
int
|
Random seed for reproducibility. Default: |
required |
start_time
|
str
|
Simulation start in |
required |
verbose
|
bool
|
Print detailed logging. Default: |
required |
Example:
1 2 3 | |
laser.measles.biweekly.BiweeklyParams.states
property
SIR state names: ["S", "I", "R"].
laser.measles.biweekly.BiweeklyParams.time_step_days
property
Duration of one tick in days (always 14 for the biweekly model).
laser.measles.biweekly.create_component(component_class, params=None)
Wrap a component class and its parameters into a single callable.
Use this at set parameters time when a component requires a custom
Pydantic parameter object. The returned factory is callable with the
same (model, verbose) signature that
BaseLaserModel.components
expects, so it can be placed directly in the component list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_class
|
type[T]
|
The component class to instantiate. |
required |
params
|
type[B] | None
|
A Pydantic parameter object (or |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[Any, Any], T]
|
A callable that creates the component when invoked by the model. |
Example:
1 2 3 4 5 6 7 8 | |