Skip to content

laser.measles.abm.components.process_infection

laser.measles.abm.components.process_infection

Component defining the InfectionProcess, which orchestrates the transmission and disease progression of measles in a population.

laser.measles.abm.components.process_infection.InfectionParams

Bases: BaseInfectionParams

Combined parameters for ABM transmission and disease processes.

Spatial mixing is controlled in one of two ways:

  1. Default gravity — leave mixer as None and configure distance_exponent and mixing_scale. Internally a :class:~laser.measles.mixing.gravity.GravityMixing is constructed using those values.
  2. Custom mixer — pass any mixing object (e.g. GravityMixing(...), RadiationMixing(...)) as mixer=. When set, this takes precedence; distance_exponent and mixing_scale are ignored.

The model sets the patch scenario on the mixer automatically at initialisation, so callers don't need to assign mixer.scenario themselves.

Examples::

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 1. Default gravity, tuned via the convenience knobs
infection_params = InfectionParams(
    beta=20.0,
    distance_exponent=2.0,
    mixing_scale=0.005,
)

# 2. Custom mixer — e.g. radiation model
from laser.measles.mixing.radiation import RadiationMixing
infection_params = InfectionParams(
    beta=20.0,
    mixer=RadiationMixing(),
)

laser.measles.abm.components.process_infection.InfectionParams.disease_params property

Extract disease-specific parameters.

laser.measles.abm.components.process_infection.InfectionParams.transmission_params property

Build the TransmissionParams to hand to TransmissionProcess.

If the caller supplied a mixer, pass it through. Otherwise wire distance_exponent and mixing_scale into a default GravityMixing(GravityParams(c=..., k=...)). The latter is the fix called out in #140 — passing those values to TransmissionParams directly silently dropped them because TransmissionParams doesn't declare them.

laser.measles.abm.components.process_infection.InfectionProcess(model, params=None)

Bases: BaseInfectionProcess

Combined infection process that orchestrates transmission and disease progression.

This component provides a unified interface for both disease transmission (handled by TransmissionProcess) and disease progression through states (handled by DiseaseProcess), similar to the biweekly model's InfectionProcess but for agent-based modeling.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
```python
from laser.measles.scenarios.synthetic import single_patch_scenario
from laser.measles.abm import ABMModel, ABMParams
from laser.measles.abm import components
from laser.measles import create_component

scenario = single_patch_scenario(population=50_000, mcv1_coverage=0.85)
params = ABMParams(num_ticks=365, seed=42, start_time="2000-01")
model = ABMModel(scenario, params)
model.add_component(create_component(components.InfectionProcess, components.InfectionParams(beta=0.3)))
```

Initialize the combined infection process.

Parameters:

Name Type Description Default
model ABMModel

The model object that contains the patches and parameters.

required
params InfectionParams | None

Combined parameters for both transmission and disease processes.

None

laser.measles.abm.components.process_infection.InfectionProcess.mixing_matrix property

The spatial mixing matrix the wrapped TransmissionProcess is using.

Convenience accessor that walks down to the live mixer instance: self.transmission.params.mixer.mixing_matrix. Once the model has run, mixer.scenario is set and the matrix is lazily computed on first access. Shape is (n_patches, n_patches).

Provided here so code that has a handle on the InfectionProcess (e.g. model.get_instance("InfectionProcess")[0]) can get the matrix in one hop, without knowing that TransmissionProcess is nested inside as a sub-component rather than registered separately.

laser.measles.abm.components.process_infection.InfectionProcess.__call__(model, tick)

Execute both transmission and disease progression for the given tick.

Parameters:

Name Type Description Default
model ABMModel

The model object containing the population, patches, and parameters.

required
tick int

The current time step in the simulation.

required

laser.measles.abm.components.process_infection.InfectionProcess.infect(model, idx)

Move agents at the given indices from susceptible to exposed.

Parameters:

Name Type Description Default
model ABMModel

The ABM model instance.

required
idx ndarray

Array of agent indices to infect.

required

laser.measles.abm.components.process_infection.InfectionProcess.plot(fig=None)

Plot cases and incidence using the transmission component's plotting functionality.

Parameters:

Name Type Description Default
fig Figure | None

A Matplotlib Figure object to plot on. If None, a new figure is created.

None