Parameter Framework Reference¶
This is the primary reference for modelers. The parameter framework lets you
declaratively define all configurable values in a disease model -- compartments,
transmission edges, interventions, demographic groups, and more -- using the
ParameterSchemaBuilder API.
Builder API¶
The ParameterSchemaBuilder is the main interface model authors use inside
define_parameters(). It provides type-safe add_* / set_* methods for
declaring every aspect of a model's parameter schema.
ParameterSchemaBuilder()
¶
Builder for constructing a ModelParameterSchema via type-safe method calls.
An instance is passed into Model.define_parameters(schema) by the
framework. Model authors call add_* / set_* methods to declare
parameters. The framework then calls build() to produce the final
ModelParameterSchema.
Example::
@classmethod
def define_parameters(cls, schema):
schema.set_model_info("MPOX", "MPOX", "SIR model for MPOX")
schema.add_compartment("S", "Susceptible", "Population susceptible to infection")
schema.add_compartment("I", "Infected", "Currently infected population")
schema.add_compartment("R", "Recovered", "Recovered and immune population")
schema.add_transmission_parameter(
source="susceptible", target="infected", variable_name="beta",
label="Transmission Rate (S->I)",
description="Rate of new infections from contact",
default=0.3, min_value=0.01, max_value=2.0,
)
Source code in compartment/parameters.py
set_model_info(disease_type, label, description)
¶
Set the disease model identity. Must be called exactly once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disease_type
|
str
|
Disease-family identifier (e.g. |
required |
label
|
str
|
Human-readable name (e.g. |
required |
description
|
str
|
Short description shown in the UI. |
required |
Source code in compartment/parameters.py
set_model_metadata(authors=None, license=None, citations=None, model_type=None, diseases=None, transmission_routes=None, questions_answered=None, key_assumptions=None, applicability=None, not_for=None, constraints=None, biases=None, validation=None)
¶
Set editorial and publication metadata for the model. All fields are
optional — omit any that don't apply. Metadata is emitted under a
top-level metadata key in the artifact JSON and has no effect on
simulation runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
authors
|
list[dict] | None
|
List of author dicts. Each dict may contain any subset of
|
None
|
license
|
str | None
|
SPDX identifier or free-text license name
(e.g. |
None
|
citations
|
list[str] | None
|
DOI URLs, paper URLs, or repo links related to this model. |
None
|
model_type
|
str | None
|
Structural category (e.g. |
None
|
diseases
|
list[str] | None
|
ICD-11 codes or free-text disease names this model targets. |
None
|
transmission_routes
|
list[str] | None
|
Transmission pathways
(e.g. |
None
|
questions_answered
|
list[str] | None
|
Research or policy questions this model addresses. |
None
|
key_assumptions
|
list[str] | None
|
Core modelling assumptions to surface to users. |
None
|
applicability
|
str | None
|
Contexts or settings where this model is appropriate. |
None
|
not_for
|
str | None
|
Use-cases where this model should not be applied. |
None
|
constraints
|
str | None
|
Known technical or data constraints. |
None
|
biases
|
str | None
|
Known biases in the model or its parameterisation. |
None
|
validation
|
str | None
|
Summary of validation work done on this model. |
None
|
Source code in compartment/parameters.py
add_compartment(id, label, description, infective=False)
¶
Add a compartment to the model (e.g. S, I, R).
Set infective=True for compartments whose population
contributes to the force of infection. When a transmission
edge is marked frequency_dependent=True, the framework
uses the sum of all infective compartments to compute the
flow: source * rate * sum(infective) / N_total.
For most models only the Infected compartment (or its equivalents) should be marked infective.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Short key used in matrices and edge definitions (e.g. |
required |
label
|
str
|
Human-readable name (e.g. |
required |
description
|
str
|
Explanation shown in the UI. |
required |
infective
|
bool
|
Whether this compartment's population contributes
to the force of infection used by |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a compartment with the same id already exists. |
Source code in compartment/parameters.py
remove_compartment(id)
¶
Remove a compartment and any edges that reference it by source or target.
Source code in compartment/parameters.py
remove_transmission_parameter(variable_name)
¶
Remove a transmission parameter by its variable name.
add_transmission_parameter(source, target, variable_name, label, description, default, min_value=None, max_value=None, default_min=None, default_max=None, unit='per day', frequency_dependent=False, value_type=ValueType.RATE)
¶
Add a directed transmission parameter between two compartments.
The source and target are matched against previously added
compartment IDs or labels (case-insensitive). The resolved short
IDs are stored as source_id and target_id on the parameter for
direct use in equation computations.
All numeric arguments (default, min_value, max_value,
default_min, default_max) should be in the native units
of the chosen value_type:
ValueType.RATE: per-day rate (e.g.0.3).ValueType.DAYS: duration in days (e.g.5). The framework converts to a rate (1 / days) at model load time.ValueType.PERCENTAGE: percentage 0-100 (e.g.4). The framework converts to a fraction (value / 100) at model load time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Source compartment (e.g. |
required |
target
|
str
|
Target compartment (e.g. |
required |
variable_name
|
str
|
Model attribute name (e.g. |
required |
label
|
str
|
Human-readable edge label (e.g. |
required |
description
|
str
|
Tooltip text for the UI. |
required |
default
|
float
|
Default value in native units of |
required |
min_value
|
float | None
|
Hard minimum for validation (native units). |
None
|
max_value
|
float | None
|
Hard maximum for validation (native units). |
None
|
default_min
|
float | None
|
Default lower bound for parameter variance / uncertainty (native units). |
None
|
default_max
|
float | None
|
Default upper bound for parameter variance / uncertainty (native units). |
None
|
unit
|
str
|
Display unit (defaults to |
'per day'
|
frequency_dependent
|
bool
|
If |
False
|
value_type
|
ValueType
|
The unit system for this edge's value. Defaults
to |
RATE
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If source or target doesn't match a known compartment. |
Source code in compartment/parameters.py
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 | |
add_intervention(id, label, description, target_rates=None, modifies_travel=False, adherence=None, transmission_reduction=None)
¶
Add a supported intervention type.
Uses shared default parameters (adherence, transmission_percentage,
start/end date, start/end threshold). Pass adherence and/or
transmission_reduction to override the generic defaults with
disease-specific values.
target_rates declares which transmission-edge variable names
this intervention modifies at runtime (e.g. ["beta"]). This
eliminates the hardcoded per-disease if/else chains in
interventions.py.
Set modifies_travel=True for lockdown-style interventions that
replace the travel matrix with an identity matrix when active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Machine key (e.g. |
required |
label
|
str
|
Human-readable name (e.g. |
required |
description
|
str
|
Explanation shown in the UI. |
required |
target_rates
|
list[str] | None
|
Variable names of transmission edges this
intervention modifies (e.g. |
None
|
modifies_travel
|
bool
|
If |
False
|
adherence
|
float | None
|
Default population adherence percentage (0-100).
Overrides the generic 50% default on |
None
|
transmission_reduction
|
float | None
|
Default transmission reduction percentage
(0-100). Overrides the generic 5% default on
|
None
|
Source code in compartment/parameters.py
1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 | |
add_admin_zone_field(name, label, description, value_type, default, min_value=None, max_value=None, default_min=None, default_max=None, unit=None, required=False, options=None)
¶
Add a per-zone field beyond the shared defaults (name, population, etc.).
Use this for disease-specific zone data like seroprevalence or temperature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Machine key (e.g. |
required |
label
|
str
|
Human-readable label (e.g. |
required |
description
|
str
|
Tooltip / help text for the UI. |
required |
value_type
|
ValueType
|
Controls input widget rendering (e.g. |
required |
default
|
Any
|
Default value -- required so the example config is runnable. |
required |
min_value
|
float | None
|
Hard minimum for validation. |
None
|
max_value
|
float | None
|
Hard maximum for validation. |
None
|
default_min
|
float | None
|
Default lower bound for parameter variance / uncertainty. |
None
|
default_max
|
float | None
|
Default upper bound for parameter variance / uncertainty. |
None
|
unit
|
str | None
|
Display unit (e.g. |
None
|
required
|
bool
|
Whether this field is required in the config. |
False
|
options
|
list[str] | None
|
Valid choices for |
None
|
Source code in compartment/parameters.py
add_parameter(name, label, description, value_type, default, min_value=None, max_value=None, default_min=None, default_max=None, unit=None, required=True, options=None, enable_variance=True)
¶
Add a disease-specific top-level parameter.
Use this for parameters that don't fit into transmission edges, interventions, or admin zone fields -- e.g. immunity_period for Dengue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Machine key (e.g. |
required |
label
|
str
|
Human-readable label (e.g. |
required |
description
|
str
|
Tooltip / help text for the UI. |
required |
value_type
|
ValueType
|
Controls input widget rendering (e.g. |
required |
default
|
Any
|
Default value -- required so the example config is runnable. |
required |
min_value
|
float | None
|
Hard minimum for validation. |
None
|
max_value
|
float | None
|
Hard maximum for validation. |
None
|
default_min
|
float | None
|
Default lower bound for parameter variance / uncertainty. |
None
|
default_max
|
float | None
|
Default upper bound for parameter variance / uncertainty. |
None
|
unit
|
str | None
|
Display unit (e.g. |
None
|
required
|
bool
|
Whether this parameter is required in the config. |
True
|
options
|
list[str] | None
|
Valid choices for |
None
|
enable_variance
|
bool
|
Set |
True
|
Source code in compartment/parameters.py
add_demographic_group(id, label, default_weight, age_range=None)
¶
Declare a demographic group (e.g. an age band).
Groups are ordered by declaration order — that order defines axis 1 of the population tensor and the rows/columns of the contact matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Machine key (e.g. |
required |
label
|
str
|
Human-readable name (e.g. |
required |
default_weight
|
float
|
Percentage of the total population in this group (0-100). Used to split the initial population tensor when no per-zone override is provided. |
required |
age_range
|
Optional[tuple[int, int]]
|
Optional inclusive (low, high) age tuple, e.g. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a group with the same id already exists, or if
|
Source code in compartment/parameters.py
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 | |
set_contact_override(from_group, to_group, value)
¶
Set a single entry in the contact matrix.
The contact matrix defaults to identity (each group only contacts itself at rate 1.0). Call this to override any entry — including the diagonal if the self-contact rate differs from 1.0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_group
|
str
|
ID of the group being exposed (row index). |
required |
to_group
|
str
|
ID of the group doing the infecting (column index). |
required |
value
|
float
|
Contact rate replacing the identity default. |
required |
Source code in compartment/parameters.py
build()
¶
Finalize and return the ModelParameterSchema.
The schema contains only the compartments and edges explicitly
declared by the model author. Cumulative _total tracking
compartments are added later by the framework in
:meth:Model.__init_subclass__ so that the schema itself stays
a clean representation of the model author's declarations.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in compartment/parameters.py
1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 | |
Value Types¶
ValueType controls how parameter values are rendered in the UI and how
the framework converts them at load time (e.g. DAYS → 1/days rate).
ValueType
¶
Bases: str, Enum
Type of value -- drives UI input rendering and serialization.
RATE = 'rate'
class-attribute
instance-attribute
¶
DAYS = 'days'
class-attribute
instance-attribute
¶
PERCENTAGE = 'percentage'
class-attribute
instance-attribute
¶
COUNT = 'count'
class-attribute
instance-attribute
¶
DATE = 'date'
class-attribute
instance-attribute
¶
BOOLEAN = 'boolean'
class-attribute
instance-attribute
¶
TEXT = 'text'
class-attribute
instance-attribute
¶
SELECT = 'select'
class-attribute
instance-attribute
¶
FLOAT = 'float'
class-attribute
instance-attribute
¶
INTEGER = 'integer'
class-attribute
instance-attribute
¶
COORDINATE = 'coordinate'
class-attribute
instance-attribute
¶
Core Dataclasses¶
ParameterDef¶
The atomic unit of parameter metadata. Every configurable value in a disease
model has a corresponding ParameterDef.
ParameterDef(name, label, description, value_type, default=None, min_value=None, max_value=None, default_min=None, default_max=None, required=True, unit=None, options=None, enable_variance=True)
dataclass
¶
Metadata for a single model parameter.
This is the atomic unit -- every configurable value in a disease model should have a corresponding ParameterDef.
to_dict()
¶
Serialize to a plain dict (None values omitted).
Field names are mapped to match the GraphQL FieldMetadata type
used by the pandemic-simulator DB schema:
default→default_valuemin_value→minmax_value→maxoptions→enumvalue_typeis emitted UPPERCASE to match the GraphQLValueTypeenum (RATE,DAYS,PERCENTAGE, …).FLOATandINTEGERare mapped toNUMBERbecause the GraphQLValueTypeenum does not have those variants; themin/maxvalidation already distinguishes them.
Extra runtime fields (name, required, unit) are
preserved for UI/runtime consumers but are not part of
FieldMetadata.
Source code in compartment/parameters.py
CompartmentDef¶
Describes a single compartment in the model (e.g. S, I, R).
CompartmentDef(id, label, description, infective=False)
dataclass
¶
Describes a single compartment in the model (e.g. S, I, R).
Set infective=True on compartments whose population contributes
to the force of infection (e.g. the I compartment in an SIR model).
When a transmission edge is marked frequency_dependent=True,
:meth:Model._compute_equations uses the sum of all infective
compartments to compute the flow:
source * rate * sum(infective) / N_total.
TransmissionEdgeDef¶
A directed edge in the compartment graph with its associated rate parameter.
TransmissionEdgeDef(source, target, source_id, target_id, variable_name, parameter, frequency_dependent=False)
dataclass
¶
Defines a directed edge in the compartment graph with parameter metadata.
Example: susceptible -> infected (variable_name="beta")
When frequency_dependent is True, the framework computes the
flow as source * rate * sum(infective) / N_total instead of the
default rate * source. This is the standard frequency-dependent
force of infection used in most compartmental models.
to_dict(order=None)
¶
Serialize to a dict matching the TransmissionEdge DB schema.
The nested parameter is emitted as metadata with
FieldMetadata-compatible keys. value_type is also
hoisted to the edge level (UPPERCASE) so consumers can read it
without digging into metadata. The optional order
argument is injected into metadata.order.
Source code in compartment/parameters.py
InterventionDef¶
Defines a supported intervention type and its configurable parameters.
InterventionDef(id, label, description, target_rates=list(), modifies_travel=False, parameters=_intervention_shared_parameters())
dataclass
¶
Defines a supported intervention type and its configurable parameters.
Example: social_isolation with adherence, transmission_percentage, etc.
target_rates declares which transmission-edge variable names this
intervention modifies (e.g. ["beta"]). At runtime the
Intervention class reads this list and applies the reduction
formula only to those rates — no per-disease if/else branching.
If modifies_travel is True the intervention replaces the
travel matrix with an identity matrix when active (lockdown behavior).
to_dict()
¶
Serialize to a dict matching the Intervention DB schema.
Key mappings:
- id → name (machine key, replaces the legacy enum)
- label → display_name (human-readable name)
- A top-level metadata object is added for the intervention
itself (used by the FieldMetadata column on Intervention).
- Each entry in parameters is wrapped as
{"name": …, "metadata": {…}} with auto-assigned order.
Source code in compartment/parameters.py
DemographicGroupDef¶
Defines a demographic group (e.g. an age band) for age-stratified models.
DemographicGroupDef(id, label, default_weight, age_range=None)
dataclass
¶
Defines a single demographic group (e.g. an age band).
default_weight is the percentage of the total population in this
group and is used to split the initial population tensor when no
per-zone overrides are provided.
age_range is optional: when every group in a schema declares one,
the framework will auto-load a country-specific contact matrix (Prem
2021 synthetic matrices) and aggregate it to the declared bands. When
any group is missing age_range, the contact matrix falls back to
identity + explicit set_contact_override calls.
ContactOverrideDef¶
A single entry in the contact matrix for cross-demographic exposure.
ContactOverrideDef(from_group, to_group, value)
dataclass
¶
A single (from_group, to_group) entry in the contact matrix.
The contact matrix defaults to identity (each group only contacts itself). Add overrides to model cross-demographic exposure.
Schema and Registries¶
ModelParameterSchema¶
The complete parameter schema -- the single source of truth for a model.
ModelParameterSchema(disease_type, disease_label, description, compartments, transmission_edges, model_key=None, interventions=list(), admin_zone_fields=list(), disease_parameters=list(), simulation_parameters=list(), demographic_groups=list(), contact_matrix_overrides=list(), compartment_display_order=list(), metadata=None, model_documentation=None, run_mode='DETERMINISTIC', num_runs=30, num_runs_min=1, num_runs_max=100)
dataclass
¶
Complete parameter schema for a disease model.
This is the single source of truth. From it we generate: - artifact JSON (for UI / tables / Zod) - Pydantic validation models (runtime) - example config JSON (for testing / docs)
to_artifact_dict()
¶
Generate the artifact JSON structure consumed by the UI layer, database seeding, and downstream Zod schema generation.
The output is shaped so that each section maps directly to the corresponding DynamoDB / GraphQL table in pandemic-simulator:
- Top-level
name/definition→ModelArtifacttable. transmission_edges[].metadata→TransmissionEdge.metadata(FieldMetadata).interventions[].metadata→Intervention.metadata.custom_fields→CustomFieldrecords with acategorytag (admin_zoneordisease_parameter).simulation_parameters→ shared simulation-level fields (start_date, end_date, run_mode, travel volume, …).
Source code in compartment/parameters.py
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | |
to_json(indent=2)
¶
to_example_config(uncertainty=False)
¶
Generate an example simulation config JSON from parameter defaults.
The output matches the format expected by load_config_from_json()
(the "short-form" that gets wrapped in the GraphQL envelope).
For required date fields that have no default, sensible placeholder values are generated automatically so the config is immediately runnable.
When uncertainty is true, parameters that opt into variance and
declare both default_min and default_max are enabled for
uniform sampling using those bounds.
Source code in compartment/parameters.py
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 | |
CompartmentRegistry¶
Attribute-style access to compartment IDs (set as cls.COMPARTMENTS on
model classes).
CompartmentRegistry(compartment_defs)
¶
Attribute-style access to compartment IDs, auto-populated from the parameter schema.
Set as cls.COMPARTMENTS on migrated model classes by
Model.__init_subclass__.
Usage::
# Named access (returns the string ID)
cls.COMPARTMENTS.S # → "S"
cls.COMPARTMENTS.I # → "I"
# Iterable (drop-in replacement for COMPARTMENT_LIST)
list(cls.COMPARTMENTS) # → ["S", "I", "R"]
len(cls.COMPARTMENTS) # → 3
"S" in cls.COMPARTMENTS # → True
# In equation():
states = {c: y[i] for i, c in enumerate(self.COMPARTMENTS)}
S = states[self.COMPARTMENTS.S]
# Stack results in schema order:
return np.stack([derivs[c] for c in self.COMPARTMENTS])
Source code in compartment/parameters.py
infective_ids
property
¶
Compartment IDs marked infective=True.
DiseaseParamRegistry¶
Attribute-style access to disease parameter names (set as
cls.DISEASE_PARAMS).
DiseaseParamRegistry(param_defs)
¶
Attribute-style access to disease parameter names, auto-populated from the parameter schema.
Set as cls.DISEASE_PARAMS on migrated model classes by
Model.__init_subclass__.
Usage::
# Named access (returns the string name)
cls.DISEASE_PARAMS.immunity_period # → "immunity_period"
cls.DISEASE_PARAMS.latent_period # → "latent_period"
# Iterable
list(cls.DISEASE_PARAMS) # → ["immunity_period", ...]
len(cls.DISEASE_PARAMS) # → 5
"immunity_period" in cls.DISEASE_PARAMS # → True
# Full definition lookup
cls.DISEASE_PARAMS.get_def("immunity_period") # → ParameterDef(...)
Source code in compartment/parameters.py
AdminZoneFieldRegistry¶
Attribute-style access to admin zone field names (set as
cls.ADMIN_ZONE_FIELDS).
AdminZoneFieldRegistry(field_defs)
¶
Attribute-style access to admin zone field names, auto-populated from the parameter schema.
Set as cls.ADMIN_ZONE_FIELDS on migrated model classes by
Model.__init_subclass__.
Admin zone fields are per-zone values (e.g. seroprevalence, vector_population) so this registry provides name references only — actual values live on each zone dict in the case file.
Usage::
# Named access (returns the string name — avoids magic strings)
cls.ADMIN_ZONE_FIELDS.seroprevalence # → "seroprevalence"
# In get_initial_population():
sero = zone.get(cls.ADMIN_ZONE_FIELDS.seroprevalence, 0)
# Iterable
list(cls.ADMIN_ZONE_FIELDS) # → ["seroprevalence", ...]
"seroprevalence" in cls.ADMIN_ZONE_FIELDS # → True
# Full definition lookup
cls.ADMIN_ZONE_FIELDS.get_def("seroprevalence") # → ParameterDef(...)
Source code in compartment/parameters.py
DiseaseParamValues¶
Attribute-style access to disease parameter values from runtime config.
DiseaseParamValues(param_defs, disease_dict)
¶
Attribute-style access to disease parameter values from config.
Created at instance time in Model.__init__ from the schema's
disease parameter definitions combined with the config's Disease dict.
Provides typed values with schema defaults as fallbacks::
self.disease_params.immunity_period # → 240 (int, from config or default)
self.disease_params.latent_period # → 5.9 (float)
Iterable over parameter names::
for name in self.disease_params:
print(name, getattr(self.disease_params, name))