laser.generic
laser.generic
laser.generic.ImmunizationCampaign(model, period, coverage, age_lower, age_upper, start=0, end=-1, verbose=False)
A LASER component that applies an immunization campaign over an age band.
On eligible ticks, all agents with age in [age_lower, age_upper) are considered
and immunized with probability coverage. Susceptibles become immune
(population.susceptibility[idx] = 0). This aligns with the campaign-style
immunization component described in the laser-generic docs.
Initialize an ImmunizationCampaign instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
LASER |
required |
period
|
int
|
Number of ticks between campaign events. Must be >= 1. |
required |
coverage
|
float
|
Per-event immunization probability in [0.0, 1.0]. |
required |
age_lower
|
int
|
Inclusive lower bound of target age band (ticks). |
required |
age_upper
|
int
|
Exclusive upper bound of target age band (ticks). Must be > age_lower. |
required |
start
|
int
|
First tick (inclusive) to run campaigns. Default 0. |
0
|
end
|
int
|
Last tick (exclusive) to run campaigns. If -1, defaults
to |
-1
|
verbose
|
bool
|
Enable verbose logging. Default False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
model |
object
|
The LASER model instance. |
period |
int
|
Ticks between campaign events. |
coverage |
float
|
Immunization probability at each event. |
age_lower |
int
|
Inclusive lower age (ticks). |
age_upper |
int
|
Exclusive upper age (ticks). |
start |
int
|
First campaign tick (inclusive). |
end |
int
|
Last campaign tick (exclusive). |
verbose |
bool
|
Verbosity flag. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are out of range (e.g., period < 1, coverage not in [0, 1], age bounds invalid). |
laser.generic.ImmunizationCampaign.__call__(model, tick)
Apply the immunization campaign at the given tick, if eligible.
Triggers when
tick >= start and ((tick - start) % period == 0) and tick < end
On each event
- Agents with age in [age_lower, age_upper) are considered.
- A Binomial draw with probability
coverageselects agents to immunize. - Selected agents have
susceptibilityset to 0 (immune). - If present, test arrays on
model.nodesare updated for validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
LASER model (unused; provided for signature parity). |
required |
tick
|
int
|
Current simulation tick. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
laser.generic.ImmunizationCampaign.plot(fig=None)
Placeholder for campaign visualization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure
|
A Matplotlib Figure to draw into. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |
laser.generic.Infect_Random_Agents(model, verbose=False)
A LASER model component that introduces random infections into the population at regular intervals. This is typically used to simulate importation events or background infection pressure.
Initialize an Infect_Random_Agents instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
The LASER model object that contains the population,
patches, and parameters. The following attributes must exist
in |
required |
verbose
|
bool
|
If True, enables verbose output. Defaults to False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
model |
object
|
The LASER model object used by the component. |
period |
int
|
Number of ticks between infection events. |
count |
int
|
Number of agents infected at each event. |
start |
int
|
First tick to apply infections. |
end |
int
|
Last tick to apply infections. |
laser.generic.Infect_Random_Agents.__call__(model, tick)
Introduce random infections into the population at the given tick.
Infections are seeded if
- The current tick is greater than or equal to
start. - The tick falls on a multiple of
period(relative tostart). - The tick is less than
end.
This updates both the agent-level infections and, if present,
the test arrays in model.patches for validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
The LASER model containing the population and patches. |
required |
tick
|
int
|
The current tick (time step) of the simulation. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
laser.generic.Infect_Random_Agents.plot(fig=None)
Placeholder for visualization of infection events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure
|
A matplotlib Figure to plot into. If None, no plot is generated. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
None |
laser.generic.Model(scenario, params, birthrates=None, name='generic', skip_capacity=False, states=None, additional_states=None)
Initialize the SI model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
GeoDataFrame
|
The scenario data containing per patch population, initial S and I counts, and geometry. |
required |
params
|
PropertySet
|
The parameters for the model, including 'nticks' and 'beta'. |
required |
birthrates
|
ndarray
|
Birth rates in CBR per patch per tick. Defaults to None. |
None
|
name
|
str
|
Name of the model instance. Defaults to "generic". |
'generic'
|
skip_capacity
|
bool
|
If True, skips capacity checks. Defaults to False. |
False
|
states
|
list
|
List of state names. Defaults to None == {"S", "E", "I", "R"}. |
None
|
additional_states
|
list
|
List of additional state names. Defaults to None. |
None
|
laser.generic.RoutineImmunization(model, period, coverage, age, start=0, end=-1, verbose=False)
A LASER component that updates immunity via routine immunization (RI).
At eligible ticks, agents whose age (in ticks) falls within an RI window
centered at age with half-width period // 2 are sampled with probability
coverage and made immune (by setting population.susceptibility[idx] = 0).
This component follows the general component style in laser-generic and can
be added to Model.components. See package documentation for details on the component pattern.
Initialize a RoutineImmunization instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
LASER |
required |
period
|
int
|
Number of ticks between RI events. Must be >= 1. |
required |
coverage
|
float
|
Per-event immunization probability in [0.0, 1.0]. |
required |
age
|
int
|
Target age (in ticks) around which to immunize. |
required |
start
|
int
|
First tick (inclusive) to run RI. Default 0. |
0
|
end
|
int
|
Last tick (exclusive) to run RI. If -1, defaults
to |
-1
|
verbose
|
bool
|
Enable verbose logging. Default False. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
model |
object
|
The LASER model instance. |
period |
int
|
Ticks between RI events. |
coverage |
float
|
Immunization probability at each event. |
age |
int
|
Target age in ticks. |
start |
int
|
First RI tick (inclusive). |
end |
int
|
Last RI tick (exclusive). |
verbose |
bool
|
Verbosity flag. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
laser.generic.RoutineImmunization.__call__(model, tick)
Apply routine immunization at the given tick, if eligible.
An event fires when
tick >= start and ((tick - start) % period == 0) and tick < end
On each event
- Agents with age in [age - period//2, age + period//2) are considered.
- A Binomial draw with probability
coverageselects agents to immunize. - Selected agents have
susceptibilityset to 0 (immune). - If present, test arrays on
model.nodesare updated for validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
LASER model (unused; provided for signature parity). |
required |
tick
|
int
|
Current simulation tick. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
laser.generic.RoutineImmunization.plot(fig=None)
Placeholder for RI visualization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure
|
A Matplotlib Figure to draw into. |
None
|