susceptible
laser.cholera.metapop.susceptible
¶
Susceptible compartment — owns the S per-patch state and the births/deaths flows that feed it.
Allocates model.people.S (shape (nticks + 1, npatches)), seeds it from
params.S_j_initial, and on each tick applies natural mortality (drawn
from d_jt) and Poisson-distributed births (drawn from b_jt * N).
Births enter S directly; deaths are recorded into
model.patches.non_disease_deaths.
Sits first in the default component pipeline so all subsequent
compartments can rely on S[tick + 1] being initialized to the carried-
forward S value when their own __call__ runs.
Component
¶
Marker base class for metapop compartment components.
Currently empty: the metapop pipeline duck-types on
__init__(model) / check() / __call__(model, tick) / plot(),
so subclassing Component carries no behavior, only intent. Kept as
an inheritance anchor for future shared default implementations.
Source code in src/laser/cholera/metapop/susceptible.py
Susceptible
¶
Bases: Component
Susceptible compartment: tracks S_j(t) and runs births / non-disease deaths each tick.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The parent |
Source code in src/laser/cholera/metapop/susceptible.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
__init__
¶
Allocate the S state vector and seed it from S_j_initial.
Adds model.people.S (shape (nticks + 1, npatches)) and
model.patches.births (per-tick birth counts) as int32 vector
properties, then writes the initial susceptible counts from
params.S_j_initial into S[0].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The |
required |
Raises:
| Type | Description |
|---|---|
AttributeError
|
When |
ValueError
|
When |
Source code in src/laser/cholera/metapop/susceptible.py
check
¶
Validate prerequisites that other components are expected to set up.
Confirms model.patches.N (population census, set up by
Census) and
params.b_jt / params.d_jt (birth / non-disease-mortality
matrices) are present. Lazily allocates
model.patches.non_disease_deaths if no earlier component has
already done so.
Raises:
| Type | Description |
|---|---|
AttributeError
|
When |
ValueError
|
When |
Source code in src/laser/cholera/metapop/susceptible.py
__call__
¶
Advance S from tick to tick + 1: carry forward, kill, then birth.
For each patch:
S[tick + 1] := S[tick](carry forward).- Sample non-disease deaths from
Binomial(S, 1 - exp(-d_jt))and subtract; bank intopatches.non_disease_deaths[tick]. - Sample births from
Poisson(N * b_jt[tick])(whereNis the current total patch population fromCensus) and add; record intopatches.births[tick].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The parent |
required |
tick
|
int
|
Current simulation tick (0-indexed); |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
When the post-deaths susceptible population
goes negative (indicates a draw exceeded the population,
which should be impossible for a |
Source code in src/laser/cholera/metapop/susceptible.py
plot
¶
Yield one Matplotlib figure showing S(t) for the ten largest patches.
Patches are ranked by params.S_j_initial so the largest
initial-susceptible populations are surfaced. Used by
Model.visualize to
generate the per-component PDF / on-screen plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure
|
Optional existing Matplotlib |
None
|
Yields:
| Type | Description |
|---|---|
str
|
The string label |
str
|
the figure title / PDF section heading). |