distributor
add_broadcast_coordinator_event(campaign, broadcast_event, start_day=None, start_year=None, coordinator_name='BroadcastCoordinatorEvent', cost_to_consumer=0, event_name=None, node_ids=None)
Add a coordinator-level event broadcast to the campaign. This creates a BroadcastCoordinatorEvent coordinator that broadcasts a single coordinator event when the campaign event fires. It does not distribute interventions.
This is useful for triggering coordinator-level event chains. For example, it can
broadcast the start trigger for a
SurveillanceEventCoordinator,
TriggeredEventCoordinator <https://emod.idmod.org/emodpy-malaria/emod/parameter-campaign-event-triggeredeventcoordinator/> (not yet implemented in emodpy),
DelayEventCoordinator <https://emod.idmod.org/emodpy-malaria/emod/parameter-campaign-event-delayeventcoordinator/> (not yet implemented in emodpy), or a
[VectorSurveillanceEventCoordinator][emodpy_malaria.campaign.event_coordinator.VectorSurveillanceEventCoordinator].
The coordinator event is automatically registered via the campaign module, just like individual-level events. It will appear in Custom_Coordinator_Events in the simulation configuration at build time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
|
required |
broadcast_event
|
(str, required)
|
|
required |
start_day
|
float
|
|
None
|
start_year
|
float
|
|
None
|
coordinator_name
|
str
|
|
'BroadcastCoordinatorEvent'
|
cost_to_consumer
|
float
|
|
0
|
event_name
|
str
|
|
None
|
node_ids
|
Optional[List[int]]
|
|
None
|
Returns:
| Type | Description |
|---|---|
None
|
None, adds the configuration to the campaign. |
Example
from emodpy.campaign.distributor import add_broadcast_coordinator_event from emod_api import campaign as api_campaign my_campaign = api_campaign my_campaign.set_schema('path_to_schema.json') add_broadcast_coordinator_event( ... campaign=my_campaign, ... broadcast_event="StartSurveillance", ... start_day=1, ... coordinator_name="TriggerSurveillance" ... )
Source code in emodpy/campaign/distributor.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
add_community_health_worker(campaign, intervention_list, trigger_condition_list, initial_amount_distribution, max_distributed_per_day, waiting_period, days_between_shipments, amount_in_shipment, start_day=None, start_year=None, duration=None, max_stock=None, event_name=None, node_ids=None, delay_distribution=None, target_demographics_config=None, property_restrictions=None, targeting_config=None)
Add a community health worker (CHW) intervention to the campaign. The CHW models treatment-seeking behavior where individuals or nodes queue for service and a health worker distributes interventions at a limited rate constrained by available stock.
The CHW listens for trigger events, queues individuals or nodes, and distributes interventions at a configurable rate. Stock is replenished periodically via shipments. This is useful for modeling scenarios such as drug distribution at a health facility where supply is limited and patients may wait or leave before being served.
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 (duration of -1 means it never expires).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
|
required |
intervention_list
|
(Union[list[IndividualIntervention], list[NodeIntervention]], required)
|
|
required |
trigger_condition_list
|
(list[str], required)
|
|
required |
initial_amount_distribution
|
(BaseDistribution, required)
|
|
required |
max_distributed_per_day
|
(int, required)
|
|
required |
waiting_period
|
(float, required)
|
|
required |
days_between_shipments
|
(float, required)
|
|
required |
amount_in_shipment
|
(int, required)
|
|
required |
start_day
|
float
|
|
None
|
start_year
|
float
|
|
None
|
duration
|
float
|
|
None
|
max_stock
|
int
|
|
None
|
event_name
|
str
|
|
None
|
node_ids
|
Optional[List[int]]
|
|
None
|
delay_distribution
|
BaseDistribution
|
|
None
|
target_demographics_config
|
TargetDemographicsConfig
|
|
None
|
property_restrictions
|
PropertyRestrictions
|
|
None
|
targeting_config
|
AbstractTargetingConfig
|
|
None
|
Returns:
| Type | Description |
|---|---|
None
|
None, add the configuration to the campaign. |
Example
from emodpy.campaign.distributor import add_community_health_worker from emodpy.campaign.common import TargetDemographicsConfig from emodpy.campaign.individual_intervention import BroadcastEvent from emodpy.utils.distributions import ConstantDistribution from emod_api import campaign as api_campaign my_campaign = api_campaign my_campaign.set_schema('path_to_schema.json') add_community_health_worker( campaign=my_campaign, intervention_list=[BroadcastEvent(my_campaign, broadcast_event="receive_treatment")], trigger_condition_list=["NewClinicalCase"], initial_amount_distribution=ConstantDistribution(500), max_distributed_per_day=10, waiting_period=30, days_between_shipments=7, amount_in_shipment=100, start_day=1, duration=365, target_demographics_config=TargetDemographicsConfig(demographic_coverage=0.8) )
Source code in emodpy/campaign/distributor.py
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 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
add_intervention_scheduled(campaign, intervention_list, start_day=None, start_year=None, event_name=None, node_ids=None, target_demographics_config=None, delay_distribution=None, repetition_config=None, property_restrictions=None, targeting_config=None)
Add the intervention(s) to the campaign at scheduled time with the given parameters.
This function distributes individual-level or node-level interventions to a specified fraction of individuals or nodes within a node set using node_ids argument.
When distributing individual-level interventions, users can target specific demographics using the
target_demographics_config and specify the individual_property_restrictions in the PropertyRestrictions
object. Users can further refine the selection of individuals by using the targeting_config argument to target
criteria such as whether they have a particular intervention or are in a relationship.
The target_demographics_config, property_restrictions with individual_property_restrictions, and
targeting_config do not apply when distributing node-level interventions.
Recurring campaigns can be created by specifying the number of times distributions should occur and the time between repetitions using repetition_config argument.
It can add a delay between when the individual-level interventions are distributed to the individual and when they receive the actual intervention using delay_distribution argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
|
required |
intervention_list
|
(Union[list[IndividualIntervention], list[NodeIntervention]], required)
|
|
required |
start_day
|
float
|
|
None
|
start_year
|
float
|
|
None
|
event_name
|
str
|
|
None
|
node_ids
|
Optional[List[int]]
|
|
None
|
target_demographics_config
|
TargetDemographicsConfig
|
|
None
|
delay_distribution
|
BaseDistribution
|
|
None
|
repetition_config
|
RepetitionConfig
|
|
None
|
property_restrictions
|
PropertyRestrictions
|
|
None
|
targeting_config
|
AbstractTargetingConfig
|
|
None
|
Returns:
| Type | Description |
|---|---|
None
|
None, add the configuration to the campaign. |
Examples:
from emodpy.campaign.distributor import add_intervention_scheduled from emodpy.campaign.common import TargetDemographicsConfig, RepetitionConfig, PropertyRestrictions, TargetGender from emodpy.campaign.individual_intervention import BroadcastEvent, OutbreakIndividual from emodpy.utils.distributions import UniformDistribution from emodpy.utils.targeting_config import IsPregnant from emod_api import campaign as api_campaign my_campaign = api_campaign my_campaign.set_schema('path_to_schema.json')
Create a list of interventions containing a BroadcastEvent and an OutbreakIndividual
my_intervention_list = [BroadcastEvent(my_campaign, broadcast_event="received_outbreak"), OutbreakIndividual(my_campaign)]
Create a UniformDistribution for the delay_distribution
uniform_distribution = UniformDistribution(0, 365)
Create an IsPregnant targeting config
is_pregnant = IsPregnant()
Add the event to the campaign, please note that only the first 2 arguments and start_day or start_year are required.
add_intervention_scheduled( campaign=my_campaign, intervention_list=my_intervention_list, # Distribute the interventions on January 1st, 1990. start_year=1990, event_name="test_event", # Distribute the interventions to nodes (or the people there in) 1, 2, 3 node_ids=[1, 2, 3], # Distribute the interventions twice with 365 timesteps between repetitions repetition_config=RepetitionConfig(number_repetitions=2, timesteps_between_repetitions=365), # Target 70% of female individuals whose Risk is High and are pregnant target_demographics_config=TargetDemographicsConfig(demographic_coverage=0.7, target_gender=TargetGender.FEMALE), property_restrictions=PropertyRestrictions(individual_property_restrictions=[["Risk:High"]]), targeting_config=is_pregnant, # Add a uniform delay (from 0 to 365 days) before the actual intervention is distributed delay_distribution=uniform_distribution )
Source code in emodpy/campaign/distributor.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 | |
add_intervention_triggered(campaign, intervention_list, triggers_list, start_day=None, start_year=None, duration=-1, event_name=None, node_ids=None, delay_distribution=None, target_demographics_config=None, property_restrictions=None, targeting_config=None)
Configure the campaign to distribute an intervention to an individual when that individual broadcasts an event. For example, you might want to distribute a vaccine to an individual when they broadcast the EighteenMonthsOld event. The triggered events are specified as triggers_list.
When distributing individual-level interventions, users can target specific demographics using the
target_demographics_config and specify the individual_property_restrictions in the PropertyRestrictions
object. Users can further refine the selection of individuals by using the targeting_config argument to target
criteria such as whether they have a particular intervention or are in a relationship.
The target_demographics_config, property_restrictions with individual_property_restrictions, and
targeting_config do not apply when distributing node-level interventions.
It can add a delay between when the individual-level interventions are distributed to the individual and when they receive the actual intervention using delay_distribution argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
|
required |
intervention_list
|
(Union[list[IndividualIntervention], list[NodeIntervention]], required)
|
|
required |
triggers_list
|
(list[str], required)
|
|
required |
start_day
|
int
|
|
None
|
start_year
|
float
|
|
None
|
duration
|
float
|
|
-1
|
event_name
|
str
|
|
None
|
node_ids
|
Optional[List[int]]
|
|
None
|
delay_distribution
|
BaseDistribution
|
|
None
|
target_demographics_config
|
TargetDemographicsConfig
|
|
None
|
property_restrictions
|
PropertyRestrictions
|
|
None
|
targeting_config
|
AbstractTargetingConfig
|
|
None
|
Examples:
from emodpy.campaign.distributor import add_intervention_triggered from emodpy.campaign.common import TargetDemographicsConfig, RepetitionConfig, PropertyRestrictions, TargetGender from emodpy.campaign.individual_intervention import BroadcastEvent, OutbreakIndividual from emodpy.utils.distributions import ExponentialDistribution from emodpy.utils.targeting_config import IsPregnant from emod_api import campaign as api_campaign my_campaign = api_campaign my_campaign.set_schema('path_to_schema.json')
Create a list of interventions containing a BroadcastEvent and an OutbreakIndividual
my_intervention_list = [BroadcastEvent(my_campaign, broadcast_event="received_outbreak"), OutbreakIndividual(my_campaign)]
Create an ExponentialDistribution for the delay_distribution with a mean of 10 timesteps
exponential_distribution = ExponentialDistribution(10)
Create an is not pregnant targeting config
is_not_pregnant = ~IsPregnant()
Add the event to the campaign, please note that only the first 3 arguments and start_day or start_year are required.
add_intervention_triggered(my_campaign, my_intervention_list, # Trigger the distribution of the intervention when either of the events: "trigger1" or "trigger2" are broadcast. triggers_list=["trigger1", "trigger2"], # Listen to the triggers for 30 days. duration=30, # Start the event at the 730th timestep. start_day=730, event_name="test_event", # Have nodes 1, 2, 3 listen for the event and distribute the intervention to the people in those nodes. node_ids=[1, 2, 3], # Add a delay between the trigger and the actual intervention delay_distribution=exponential_distribution, # Target 70% of female individual from age 10 to 20 whose Risk is High and are not pregnant target_demographics_config=TargetDemographicsConfig(demographic_coverage=0.7, target_gender=TargetGender.FEMALE, target_age_min=10, target_age_max=20), property_restrictions=PropertyRestrictions(individual_property_restrictions=[["Risk:High"]]) targeting_config=is_not_pregnant )
Returns:
| Type | Description |
|---|---|
None
|
None, add the configuration to the campaign. |
Source code in emodpy/campaign/distributor.py
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 176 177 178 179 180 181 182 183 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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |