event_coordinator
Action
Defines a single threshold-action pair for use in a Responder. When the incidence value (count or percentage) meets or exceeds the threshold, the specified event is broadcast. If multiple actions are defined, the one with the highest threshold that is still less than or equal to the incidence value is selected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
(float, required)
|
The threshold value that the incidence count or percentage must meet or exceed for this action to be selected. When multiple actions are defined, the action with the highest threshold that is still less than or equal to the sampled value is chosen. Thresholds must be unique across all actions in the same Responder. Minimum value: 0 Maximum value: 3.40282e+38 Default value: 0 |
required |
event_to_broadcast
|
(str, required)
|
A string that will be broadcast as an event when this action's threshold is met. The level of the event broadcast depends on the value of the event_type parameter in the same action. |
required |
event_type
|
(Union[EventType, str], required)
|
The type of event to broadcast. Use the [EventType][emodpy.utils.emod_enum.EventType] enum values:
|
required |
Source code in emodpy/campaign/event_coordinator.py
BaseEventCoordinator
The EventCoordinator class is the base class for all event coordinators. It is not intended for direct use.
Source code in emodpy/campaign/event_coordinator.py
__init__(campaign, event_coordinator_class_name)
Initializes an EventCoordinator object with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
campaign
|
|
required |
event_coordinator_class_name
|
str
|
|
required |
Source code in emodpy/campaign/event_coordinator.py
to_schema_dict()
Returns the EventCoordinator object as a dictionary that match the schema and can be used in the campaign.
BroadcastCoordinatorEvent
Bases: BaseEventCoordinator
The BroadcastCoordinatorEvent coordinator broadcasts a coordinator-level event. It does not distribute interventions. Instead, it broadcasts a single coordinator event that other coordinators (such as SurveillanceEventCoordinator) can listen for and respond to.
This coordinator is useful for triggering coordinator-level event chains. For example, it can be used to start a SurveillanceEventCoordinator by broadcasting its start trigger event. You can use the Report_Coordinator_Event_Recorder to report on the events broadcasted by this coordinator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
An instance of the emod_api.campaign module. |
required |
broadcast_event
|
(str, required)
|
The name of the Coordinator Event to broadcast. This cannot be an empty string. |
required |
coordinator_name
|
str
|
The name of the event coordinator, which is useful in output reports such as ReportCoordinatorEventRecorder.csv and ReportSurveillanceEventRecorder.csv. EMOD does not ensure that this name is unique. Default value: "BroadcastCoordinatorEvent" |
'BroadcastCoordinatorEvent'
|
cost_to_consumer
|
float
|
The unit cost per each of these event coordinators created. Minimum value: 0 Maximum value: 3.40282e+38 Default value: 0 |
0
|
Source code in emodpy/campaign/event_coordinator.py
CommunityHealthWorkerEventCoordinator
Bases: InterventionDistributorEventCoordinator
The CommunityHealthWorkerEventCoordinator simulates a community health worker (CHW) who distributes interventions to individuals or nodes that trigger specified events. When a trigger event occurs, the individual or node is added to a queue. The CHW processes the queue at a configurable rate, limited by available stock. Stock is replenished periodically via shipments.
Individuals or nodes that have been in the queue longer than the Waiting_Period are removed. Individuals who die or emigrate are automatically removed from the queue. The coordinator expires after Duration days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
An instance of the emod_api.campaign module. |
required |
intervention_list
|
(Union[list[IndividualIntervention], list[NodeIntervention]], required)
|
A list of intervention objects to distribute. Can be individual-level or node-level, but not both. Demographic restrictions do not apply when distributing node-level interventions. |
required |
trigger_condition_list
|
(list[str], required)
|
A list of individual-level events that add the triggering individual or node to the
CHW's queue. Events can be EMOD built-in (e.g., |
required |
initial_amount_distribution
|
(BaseDistribution, required)
|
The distribution used to determine the initial stock of interventions. Use
any [BaseDistribution][emodpy.utils.distributions.BaseDistribution] subclass, e.g.,
|
required |
duration
|
float
|
The number of days the coordinator remains active before it expires. Minimum value: 0. Maximum value: 3.40282e+38. Default value: None (uses EMOD default: 3.40282e+38). |
None
|
max_distributed_per_day
|
(int, required)
|
The maximum number of interventions the CHW can distribute per day. Minimum value: 1. Maximum value: 2147480000. Default value: 2147480000. |
required |
waiting_period
|
(float, required)
|
The number of days a person or node can remain in the queue. Entities in the queue will not be re-added if the trigger event occurs again, preserving their priority. Entities are removed from the queue if they exceed this waiting period. Minimum value: 0. Maximum value: 3.40282e+38. Default value: 3.40282e+38. |
required |
days_between_shipments
|
(float, required)
|
The number of days between restocking shipments. Minimum value: 1. Maximum value: 3.40282e+38. Default value: 3.40282e+38. |
required |
amount_in_shipment
|
(int, required)
|
The number of interventions received in each shipment. Minimum value: 0. Maximum value: 2147480000. Default value: 2147480000. |
required |
max_stock
|
int
|
The maximum inventory the CHW can hold. Excess stock from shipments is discarded. Minimum value: 0. Maximum value: 2147480000. Default value: None (uses EMOD default: 2147480000). |
None
|
target_demographics_config
|
TargetDemographicsConfig
|
Demographic targeting configuration (age, gender, residency, coverage). Only applies when distributing individual-level interventions. Default value: None |
None
|
property_restrictions
|
PropertyRestrictions
|
Individual and/or node property restrictions. Default value: None |
None
|
targeting_config
|
AbstractTargetingConfig
|
Advanced targeting configuration. Default value: None |
None
|
Source code in emodpy/campaign/event_coordinator.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
CoverageByNodeEventCoordinator
Bases: InterventionDistributorEventCoordinator
The CoverageByNodeEventCoordinator distributes individual-level interventions with
node-specific demographic coverage. It is similar to the
StandardEventCoordinator but allows specifying different coverage fractions
for each node via the coverage_by_node parameter. If no coverage is specified for a
particular node, coverage defaults to zero for that node.
This coordinator can only be used with individual-level interventions. It supports the same demographic targeting, property restrictions, repetition, and targeting config options as StandardEventCoordinator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
An instance of the emod_api.campaign module. |
required |
intervention_list
|
(Union[list[IndividualIntervention], list[NodeIntervention]], required)
|
A list of either individual-level intervention objects to distribute. |
required |
coverage_by_node
|
(list[tuple[int, float]], required)
|
A list of |
required |
target_demographics_config
|
TargetDemographicsConfig
|
Demographic targeting configuration (age, gender, residency). Default value: None |
None
|
repetition_config
|
RepetitionConfig
|
Repetition configuration for recurring distributions. Default value: None |
None
|
property_restrictions
|
PropertyRestrictions
|
Individual and/or node property restrictions. Default value: None |
None
|
targeting_config
|
AbstractTargetingConfig
|
Advanced targeting configuration. Default value: None |
None
|
Source code in emodpy/campaign/event_coordinator.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
IncidenceCounter
Defines what events to count and which individuals qualify for counting in an IncidenceEventCoordinator. The counter listens for specified individual events and counts them over a configurable number of timesteps. Only events from individuals matching the demographic and property restrictions are counted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger_condition_list
|
(list[str], required)
|
A list of individual-level events to count. When an individual broadcasts one of these
events and meets the demographic and property restrictions, the counter increments.
Events can be built-in (e.g., |
required |
count_events_for_num_timesteps
|
(int, required)
|
The number of simulation timesteps over which to count events before notifying the responder with the accumulated count. Minimum value: 1. Maximum value: 2147480000. |
required |
target_demographics_config
|
TargetDemographicsConfig
|
Demographic targeting configuration that controls which individuals' events
are counted. Allows filtering by demographic coverage, age, gender, and
residency status. When not specified, events from all individuals
( |
None
|
property_restrictions
|
PropertyRestrictions
|
Individual and/or node property restrictions that further filter which individuals' events are counted. You can specify individual property restrictions, node property restrictions, or both (using the appropriate parameter on the PropertyRestrictions object). Default value: None |
None
|
targeting_config
|
AbstractTargetingConfig
|
Advanced targeting configuration for more selective individual filtering using the targeting config system. Default value: None |
None
|
Source code in emodpy/campaign/event_coordinator.py
IncidenceCounterSurveillance
Bases: IncidenceCounter
Extends IncidenceCounter for use with SurveillanceEventCoordinator. Adds periodic counting with a configurable counter period and support for counting individual, node, or coordinator events.
Events are counted for count_events_for_num_timesteps during each period
(in days) as set by counter_period. At the end of each period, the counter notifies
the responder with the accumulated data and then starts listening again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger_condition_list
|
(list[str], required)
|
The list of events to count. The type of events is determined by
|
required |
counter_event_type
|
(Union[EventType, str], required)
|
The type of events counted in
|
required |
counter_period
|
(float, required)
|
The counting period in days. At the end of each period, accumulated counts are passed to the responder and counting restarts. Minimum value: 1. Maximum value: 1000. |
required |
count_events_for_num_timesteps
|
(int, required)
|
The number of simulation timesteps over which to count events. Minimum value: 1. Maximum value: 2147480000. |
required |
target_demographics_config
|
TargetDemographicsConfig
|
Demographic targeting configuration including demographic coverage. See TargetDemographicsConfig for details. Only applies when counting individual-level events. Default value: None |
None
|
property_restrictions
|
PropertyRestrictions
|
Individual and/or node property restrictions. Default value: None |
None
|
targeting_config
|
AbstractTargetingConfig
|
Advanced targeting configuration. See AbstractTargetingConfig for details. Default value: None |
None
|
Source code in emodpy/campaign/event_coordinator.py
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
IncidenceEventCoordinator
Bases: BaseEventCoordinator
The IncidenceEventCoordinator monitors for individual-level events within a simulation and responds by broadcasting events when configurable thresholds are met. It does not distribute interventions directly; instead, it counts specified events using an IncidenceCounter and evaluates the accumulated count or percentage against thresholds defined in a Responder. The responder then broadcasts the appropriate event, which can trigger other campaign events or event coordinators.
This coordinator is useful for implementing reactive strategies, such as deploying mass drug administration when disease incidence exceeds a threshold, or broadcasting alert events when case counts reach specified levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
An instance of the emod_api.campaign module. |
required |
incidence_counter
|
(IncidenceCounter, required)
|
An IncidenceCounter defining the events to count and the demographic and property restrictions for qualifying individuals. The counter accumulates events over the specified number of timesteps before passing the count to the responder. |
required |
responder
|
(Responder, required)
|
A Responder defining the threshold type and the list of threshold-action pairs. After the counter finishes counting, the responder calculates the incidence value and selects the appropriate action to execute. |
required |
coordinator_name
|
str
|
The name of the event coordinator. Useful for identification in output reports such as ReportCoordinatorEventRecorder.csv and ReportSurveillanceEventRecorder.csv. EMOD does not enforce uniqueness. Default value: "" |
''
|
number_repetitions
|
int
|
The number of times the count-respond cycle repeats. A value of |
1
|
timesteps_between_repetitions
|
int
|
The number of timesteps (not days) between repetitions. If the
Simulation_Timestep is 30 days and this is set to 4, there will be 120 days
between repetitions. A value of |
-1
|
Source code in emodpy/campaign/event_coordinator.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | |
InterventionDistributorEventCoordinator
Bases: BaseEventCoordinator
The InterventionDistributorEventCoordinator class is a base class for all event coordinators that distribute list of interventions and has a parameter Intervention_Config.
Source code in emodpy/campaign/event_coordinator.py
set_intervention_list(campaign)
Set the intervention list in the coordinator using the MultiInterventionDistributor or MultiNodeInterventionDistributor
Source code in emodpy/campaign/event_coordinator.py
validate_intervention_list()
Check that the intervention_list is not empty and should be a list of IndividualIntervention or NodeIntervention
Source code in emodpy/campaign/event_coordinator.py
NodeIdAndCoverage
Defines a single (node ID, coverage) pair for use in CoverageByNodeEventCoordinator. Each entry specifies a node and the fraction of its population that should receive the intervention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
(int, required)
|
The ID of the node as specified in the demographics file. Minimum value: 0. Maximum value: 999999. |
required |
coverage
|
(float, required)
|
The fraction of individuals in the node that should be randomly selected to receive the intervention. Minimum value: 0. Maximum value: 1. |
required |
Source code in emodpy/campaign/event_coordinator.py
Responder
Defines how the IncidenceEventCoordinator responds when the
IncidenceCounter finishes counting. The responder calculates the incidence as a
raw count or percentage (based on threshold_type), then selects the action from the
action_list whose threshold is the highest value that is still less than or equal to
the calculated incidence. The selected action's event is then broadcast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_list
|
(list[Action], required)
|
A list of Action objects specifying possible responses. Each action defines a threshold and an event to broadcast. Actions are evaluated in descending threshold order; the action with the highest threshold that does not exceed the incidence value is selected. The list must not be empty, and thresholds must be unique. |
required |
threshold_type
|
Union[ThresholdType, str]
|
How to interpret the incidence value and action thresholds. Use the [ThresholdType][emodpy.utils.emod_enum.ThresholdType] enum values:
Default value: ThresholdType.COUNT |
COUNT
|
Source code in emodpy/campaign/event_coordinator.py
ResponderSurveillance
Bases: Responder
Extends Responder for use with SurveillanceEventCoordinator.
Adds support for a responded event (broadcast when any action is taken) and
percentage-based event counting for the ThresholdType.PERCENTAGE_EVENTS
threshold type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_list
|
(list[Action], required)
|
A list of Action objects specifying possible responses. |
required |
threshold_type
|
(Union[ThresholdType, str], required)
|
How to interpret the incidence value and action thresholds. Use the [ThresholdType][emodpy.utils.emod_enum.ThresholdType] enum values:
|
COUNT
|
responded_event
|
str
|
A coordinator-level event that is broadcast when the responder takes any action. At the end of a counting period, if an action is selected, the action events are broadcast first, then the responded event is also broadcast. This allows other event coordinators to react to the action. Default value: None |
None
|
percentage_events_to_count
|
list[str]
|
When |
None
|
counter_event_type
|
Union[EventType, str]
|
The type of events in |
None
|
Source code in emodpy/campaign/event_coordinator.py
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 | |
StandardEventCoordinator
Bases: InterventionDistributorEventCoordinator
The StandardEventCoordinator coordinator class distributes an individual-level or node-level intervention to a specified fraction of individuals or nodes within a node set. Recurring campaigns can be created by specifying the number of times distributions should occur and the time between repetitions.
Demographic restrictions such as Demographic_Coverage and Target_Gender do not apply when distributing node-level interventions. The node-level intervention must handle the demographic restrictions.
Source code in emodpy/campaign/event_coordinator.py
__init__(campaign, intervention_list, target_demographics_config=None, repetition_config=None, property_restrictions=None, targeting_config=None)
StandardEventCoordinator class to create a StandardEventCoordinator with given parameters and return the coordinator.
NOTE: The actual object in EMOD is StandardInterventionDistributionEventCoordinator, but we use StandardEventCoordinator here for short.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
campaign
|
The campaign object to which the event will be added. This should be an instance of the emod_api.campaign class. |
required |
intervention_list
|
list
|
A list of intervention objects. The intervention_list should contain only IndividualIntervention or only NodeIntervention objects. |
required |
target_demographics_config
|
TargetDemographicsConfig
|
a TargetDemographicsConfig to define the demographics related parameters. |
None
|
repetition_config
|
RepetitionConfig
|
a RepetitionConfig to define the Number_Repetitions and Timesteps_Between_Repetitions parameters. |
None
|
property_restrictions
|
PropertyRestrictions
|
a PropertyRestrictions to define the Property_Restrictions, Property_Restrictions_Within_Node and Node_Property_Restrictions in the coordinator. |
None
|
Returns:
| Type | Description |
|---|---|
ReadOnlyDict
|
StandardEventCoordinator |
Source code in emodpy/campaign/event_coordinator.py
SurveillanceEventCoordinator
Bases: BaseEventCoordinator
The SurveillanceEventCoordinator extends the functionality of IncidenceEventCoordinator by adding start/stop trigger events, a configurable duration, and periodic counting. It monitors for coordinator-level start events, begins counting individual/node/coordinator events using an IncidenceCounterSurveillance, and responds via a ResponderSurveillance when counting periods complete.
The coordinator remains dormant until it receives a start trigger event. Once started, it counts events during each counter period and passes results to the responder. It can be stopped by a stop trigger event and restarted by a subsequent start event. The coordinator expires when its duration has elapsed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
An instance of the emod_api.campaign module. |
required |
incidence_counter
|
(IncidenceCounterSurveillance, required)
|
An IncidenceCounterSurveillance defining the events to count, the counter period, and demographic restrictions. |
required |
responder
|
(ResponderSurveillance, required)
|
A ResponderSurveillance defining the threshold type, action list, and optional responded event. |
required |
start_trigger_condition_list
|
(list[str], required)
|
A list of coordinator events that start the counter. When one of these events is heard, the incidence counter begins counting. The list must not be empty. Events must be broadcast by other campaign components to be valid triggers. |
required |
stop_trigger_condition_list
|
list[str]
|
A list of coordinator events that stop the counter. The coordinator can restart if it receives a new start trigger event. The coordinator does not expire until the duration has elapsed. Default value: None (the coordinator will not stop until duration elapses) |
None
|
coordinator_name
|
str
|
The name of the event coordinator for identification in output reports. Default value: "SurveillanceEventCoordinator" |
'SurveillanceEventCoordinator'
|
duration
|
float
|
The number of days the coordinator remains active after creation. Once elapsed,
the coordinator unregisters for events and expires. A value of |
-1
|
Source code in emodpy/campaign/event_coordinator.py
890 891 892 893 894 895 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 | |