EMOD_functions.py

CfgFn

Obtained from IDM’s emodpy-snt framework that had been modified for bf-seasonal https://github.com/numalariamodeling/bf-seasonal/blob/main/sweeping.py

Sweeping utility: works for sweeping on config parameters. Requirements: - func is a method that takes config as first parameter - func return a dict

Returns:
  • dict

Source code in EMOD\functions\EMOD_functions.py
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
class CfgFn:
    """
    Obtained from IDM's emodpy-snt framework that had been modified for bf-seasonal
    https://github.com/numalariamodeling/bf-seasonal/blob/main/sweeping.py

    Sweeping utility: works for sweeping on config parameters.
    Requirements:
     - func is a method that takes config as first parameter
     - func return a dict

    Returns:
        dict
    """

    def __init__(self, func, *args, **kwargs):
        self.func = func
        self.args = args
        self.kwargs = kwargs

    def __call__(self, simulation: Simulation):
        md = self.func(simulation.task.config, *self.args, **self.kwargs)

        # Make sure we cast numpy types into normal system types
        if md:
            for k, v in md.items():
                if isinstance(v, (np.int64, np.float64, np.float32, np.uint32, np.int16, np.int32)):
                    md[k] = v.item()

        return md

ItvFn

Obtained from IDM’s emodpy-snt framework that had been modified for bf-seasonal https://github.com/numalariamodeling/bf-seasonal/blob/main/sweeping.py

Sweeping utility: works for sweeping on interventions. Requirements: - func is a method that takes campaign as first parameter - func return a dict

Returns:
  • dict

Source code in EMOD\functions\EMOD_functions.py
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
class ItvFn:
    """
    Obtained from IDM's emodpy-snt framework that had been modified for bf-seasonal
    https://github.com/numalariamodeling/bf-seasonal/blob/main/sweeping.py

    Sweeping utility: works for sweeping on interventions.
    Requirements:
     - func is a method that takes campaign as first parameter
     - func return a dict

    Returns:
        dict
    """

    def __init__(self, func, *args, **kwargs):
        self.func = func
        self.args = args
        self.kwargs = kwargs

    def __call__(self, simulation: Simulation):
        import emod_api.campaign as campaign
        campaign.reset()
        md = self.func(campaign, *self.args, **self.kwargs)

        # add events
        events = campaign.campaign_dict["Events"]
        simulation.task.campaign.add_events(events)

        # update config for adhoc events
        adhoc_events = campaign.get_adhocs()
        if len(adhoc_events) > 0:
            print("Found adhoc events in campaign. Needs some special processing behind the scenes.")
            if "Custom_Individual_Events" in simulation.task.config.parameters:
                ev_exist = set(simulation.task.config.parameters.Custom_Individual_Events)
                ev_addhoc = set(adhoc_events.keys())
                simulation.task.config.parameters.Custom_Individual_Events = list(ev_exist.union(ev_addhoc))
            else:
                simulation.task.config.parameters.Custom_Individual_Events = list(set(adhoc_events.keys()))

        # Make sure we cast numpy types into normal system types
        if md:
            for k, v in md.items():
                if isinstance(v, (np.int64, np.float64, np.float32, np.uint32, np.int16, np.int32)):
                    md[k] = v.item()

        return md

SwpFn

Sweeping utility: works for sweeping on report, demographics, migrations and climate, etc. Requirements: - func is a method that takes task as first parameter - func return a dict Returns: dict

Source code in EMOD\functions\EMOD_functions.py
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
class SwpFn:
    """
    Sweeping utility: works for sweeping on report, demographics, migrations and climate, etc.
    Requirements:
     - func is a method that takes task as first parameter
     - func return a dict
    Returns:
        dict
    """

    def __init__(self, func, *args, **kwargs):
        self.func = func
        self.args = args
        self.kwargs = kwargs

    def __call__(self, simulation: Simulation):
        md = self.func(simulation.task, *self.args, **self.kwargs)
        # Make sure we cast numpy types into normal system types
        if md:
            for k, v in md.items():
                if isinstance(v, (np.int64, np.float64, np.float32, np.uint32, np.int16, np.int32)):
                    md[k] = v.item()
        return md

all_campaigns(camp, exp=None, row=None, intervention_list=[])

Defines and adds various interventions and campaigns to be included in the campaigns.json for EMOD. The function serves as a wrapper that conditionally applies different campaigns based on the values in the provided row (e.g., from a scenario DataFrame), experiment configuration (exp), and the intervention_list parameter.

Parameters:
  • camp (object) –

    The campaign object to which the interventions will be applied.

  • exp (object, default: None ) –

    The experiment configuration containing simulation parameters (default is None).

  • row (Series, default: None ) –

    A row of data containing scenario parameters for the campaign (default is None).

  • intervention_list (list, default: [] ) –

    List of interventions to be included in the simulation (default is empty list).

Returns:
  • dict

    A dictionary containing the scenario ID (scen_id) associated with the campaign. Example: {‘scen_id’: 1}

Source code in EMOD\functions\EMOD_functions.py
 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
def all_campaigns(camp, exp=None, row=None, intervention_list=[]):
    """
    Defines and adds various interventions and campaigns to be included in the `campaigns.json` for EMOD.
    The function serves as a wrapper that conditionally applies different campaigns based on the values in
    the provided `row` (e.g., from a scenario DataFrame), experiment configuration (`exp`), and the
    `intervention_list` parameter.

    Args:
        camp (object): The campaign object to which the interventions will be applied.
        exp (object, optional): The experiment configuration containing simulation parameters (default is None).
        row (pandas.Series, optional): A row of data containing scenario parameters for the campaign (default is None).
        intervention_list (list, optional): List of interventions to be included in the simulation (default is empty list).

    Returns:
        dict: A dictionary containing the scenario ID (scen_id) associated with the campaign.
              Example: {'scen_id': 1}

    """

    ## If forced EIR, treated as campaign in EMOD
    if row.entomology_mode == 'forced':
        set_inputEIR_seasonality(camp, float(row.model_input_em), row.seasonality)

    # Case management
    treatment_camp_simple(camp, cm_start=row.cm_start, cm_clinical=row.cm_clinical, cm_severe=row.cm_severe)

    ## Carrying capacity step change
    if 'cc_step' in intervention_list and (
            exp.emod_step == 'pickup' or exp.emod_step is None):  # Make sure to include the cc_step change only at pickup simulations.
        eir_df = pd.DataFrame({'CONSTANT': [row.cc_factor_emod]})
        add_scale_larval_habitats(camp, df=eir_df,
                                  start_day=row.cc_timestep_emod,
                                  repetitions=1)
    if exp.importation_rate != 0:
        ncases_per_year_per1000pop = (exp.importation_rate * exp.emod_pop_size) / 1000
        add_outbreak_individual(camp, start_day=1, target_num_individuals=ncases_per_year_per1000pop,
                                repetitions=-1, timesteps_between_repetitions=365)

    # SMC currently not supported
    # SMC using PKPD model
    #if 'smc' in intervention_list and exp.emod_step == 'pickup':
    #    print(row.smc_coverage)
    #    if row.model_input_emod == 4:
    #        start_array = [366, 731, 1096, 1461, 1826]
    #    elif row.model_input_emod == 8:
    #        start_array = [366, 731, 1096, 1461, 1826]
    #    else:
    #        start_array = [335, 700, 1065, 1430, 1795]
    #        # add_drug_campaign(camp, campaign_type = "SMC", start_days = [396,761,1126,1491,1856],
    #    smc_campaign(camp, row, start_array)

    return {'scen_id': int(row.scen_id)}

build_burnin_df(exp_id, platform, serialize_days)

Builds a DataFrame containing information about serialized files and simulation configurations for the burn-in process of the experiment. The serialized population filenames are in the format: state-{step}-{core}.dtk, where {step} refers to the serialization timestep and {core} refers to the core number. The Serialized_Population_Filenames field varies based on the number of cores used. For example, if Num_Cores = 2, the filenames will look like this: state-00050-000.dtk and state-00050-001.dtk.

Parameters:
  • exp_id (str) –

    The unique experiment identifier for which the burn-in DataFrame is being created.

  • platform (object) –

    The platform object that represents the high-performance computing environment. Used to retrieve core count and other platform-related information.

  • serialize_days (int) –

    The number of days over which serialization occurs. This is used to determine the length of time steps for the serialized population.

Returns:
  • pd.DataFrame: A DataFrame containing the following columns: - Run_Number: The simulation run number. - Serialization_Time_Steps: The number of time steps for serialization. - task_type: Type of the task being run (e.g., simulation). - sweep_tag: The tag associated with the current simulation sweep. - simid: The unique simulation ID. - serialized_file_path: Path to the serialized files for the simulation. - Num_Cores: The number of cores allocated for the simulation. - Serialized_Population_Filenames: The filenames of the serialized population files.

Source code in EMOD\functions\EMOD_functions.py
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
def build_burnin_df(exp_id: str, platform, serialize_days):
    """
    Builds a DataFrame containing information about serialized files and simulation configurations
    for the burn-in process of the experiment.
    The serialized population filenames are in the format: `state-{step}-{core}.dtk`, where `{step}` refers to
    the serialization timestep and `{core}` refers to the core number.
    The `Serialized_Population_Filenames` field varies based on the number of cores used. For example,
    if `Num_Cores = 2`, the filenames will look like this: `state-00050-000.dtk` and `state-00050-001.dtk`.

    Args:
        exp_id (str): The unique experiment identifier for which the burn-in DataFrame is being created.
        platform (object): The platform object that represents the high-performance computing environment.
                           Used to retrieve core count and other platform-related information.
        serialize_days (int): The number of days over which serialization occurs. This is used to determine
                               the length of time steps for the serialized population.

    Returns:
        pd.DataFrame: A DataFrame containing the following columns:
            - `Run_Number`: The simulation run number.
            - `Serialization_Time_Steps`: The number of time steps for serialization.
            - `task_type`: Type of the task being run (e.g., simulation).
            - `sweep_tag`: The tag associated with the current simulation sweep.
            - `simid`: The unique simulation ID.
            - `serialized_file_path`: Path to the serialized files for the simulation.
            - `Num_Cores`: The number of cores allocated for the simulation.
            - `Serialized_Population_Filenames`: The filenames of the serialized population files.

    """

    df = create_sim_directory_map(exp_id, platform)
    # add Num_Cores to df
    df["Num_Cores"] = df["simid"].apply(_get_core_counts, platform=platform)

    # try:
    burnin_length_in_days = serialize_days  # int(df["Serialization_Time_Steps"].iloc[0].strip('[]'))
    # except AttributeError:
    # different versions of pandas save this as either a string or a list
    # burnin_length_in_days = df["Serialization_Time_Steps"].iloc[0][-1]

    df["Serialized_Population_Filenames"] = df["Num_Cores"].apply(_get_serialized_filenames,
                                                                  timesteps=burnin_length_in_days)
    df = df.reset_index(drop=True)
    return df

climate_setup(task, seasonality=None)

The function sets up the climate input filenames for EMOD.

Parameters:
  • task (object) –

    The task object that holds the configuration and parameters for the simulation.

  • seasonality (str, default: None ) –

    The seasonality type (e.g., ‘perennial’ or ‘seasonal’) that determines the climate files. If not provided, defaults to None.

Returns:
  • None

Source code in EMOD\functions\EMOD_functions.py
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
def climate_setup(task, seasonality=None):
    """
    The function sets up the climate input filenames for EMOD.

    Args:
        task (object): The task object that holds the configuration and parameters for the simulation.
        seasonality (str, optional): The seasonality type (e.g., 'perennial' or 'seasonal') that determines the climate files.
                                      If not provided, defaults to None.

    Returns:
        None
    """
    task.config.parameters.Air_Temperature_Filename = os.path.join('climate',
                                                                   f'{seasonality}_air_temperature_daily.bin')
    task.config.parameters.Land_Temperature_Filename = os.path.join('climate',
                                                                    f'{seasonality}_air_temperature_daily.bin')
    task.config.parameters.Rainfall_Filename = os.path.join('climate', f'{seasonality}_rainfall_daily.bin')
    task.config.parameters.Relative_Humidity_Filename = os.path.join('climate',
                                                                     f'{seasonality}_relative_humidity_daily.bin')

create_sim_directory_map(exp_id, platform)

Return a dataframe which contains simulation's working_path and tags.

Args: exp_id: experiment id platform: idmtools platform Returns: dataframe

Source code in EMOD\functions\EMOD_functions.py
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
def create_sim_directory_map(exp_id: str, platform: 'IPlatform'):
    """
        Return a dataframe which contains simulation's working_path and tags.
    Args:
        exp_id: experiment id
        platform: idmtools platform
    Returns:
        dataframe
    """
    # Get idmtools Experiment
    exp = platform.get_item(exp_id, ItemType.EXPERIMENT, raw=False)

    tags_list = []
    for sim in exp.simulations:
        tags = copy.deepcopy(sim.tags)
        tags.update(dict(simid=sim.id))
        tags_list.append(tags)
    df = pd.DataFrame(tags_list)

    if len(df) != len(exp.simulations):
        print(f'Warning: not all jobs in {exp_id} succeeded', ':', )
        print(len(exp.simulations) - len(df), 'unsucceeded')

    simulations = exp.simulations
    dir_list = []
    for sim in simulations:
        dir_dict = {"simid": str(sim.id), "serialized_file_path": platform._op_client.get_directory(sim)}
        dir_list.append(dir_dict)

    df_dir = pd.DataFrame(dir_list)
    df = pd.merge(left=df, right=df_dir, on='simid')

    return df

get_burnin_exp_name(serialized_df)

Retrieve the name of the EMOD burnin experiment from the metadata.json file Args: serialized_df (DataFrame): A pandas DataFrame containing serialized data information. Returns: str: The name of the burnin experiment as defined in the serialization df from emod_serialized_id.

Source code in EMOD\functions\EMOD_functions.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
def get_burnin_exp_name(serialized_df):
    """
    Retrieve the name of the EMOD burnin experiment from the metadata.json file
    Args:
        serialized_df (DataFrame): A pandas DataFrame containing serialized data information.
    Returns:
        str: The name of the burnin experiment as defined in the serialization df from emod_serialized_id.
    """

    import json
    metadata_path = serialized_df.serialized_file_path[0].parent / 'metadata.json'
    with open(metadata_path, 'r') as json_file:
        metadata = json.load(json_file)
    return metadata['name']

get_scendf_burnin(exp, emod_serialized_id, manifest, platform, burnin)

Load the scenarios.csv file associated with the EMOD burnin experiment.

Parameters:
  • exp (Experiment) –

    An experiment object containing information about the experiment.

  • emod_serialized_id (str) –

    The serialized ID for the EMOD input data.

  • manifest (Manifest) –

    A manifest object containing job directory information.

  • platform (Platform) –

    A platform object specifying the execution platform.

  • burnin (int) –

    The duration of the burnin period in days.

Returns: pandas.DataFrame: A DataFrame containing scenarios from the burn-in experiment.

Source code in EMOD\functions\EMOD_functions.py
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
def get_scendf_burnin(exp, emod_serialized_id, manifest, platform, burnin):
    """
    Load the scenarios.csv file associated with the EMOD burnin experiment.

    Args:
        exp (Experiment): An experiment object containing information about the experiment.
        emod_serialized_id (str): The serialized ID for the EMOD input data.
        manifest (Manifest): A manifest object containing job directory information.
        platform (Platform): A platform object specifying the execution platform.
        burnin (int): The duration of the burnin period in days.
    Returns:
        pandas.DataFrame: A DataFrame containing scenarios from the burn-in experiment.
    """
    serialized_df = build_burnin_df(emod_serialized_id, platform, burnin * 365)
    exp_name_burnin = get_burnin_exp_name(serialized_df)
    scen_df_burnin_path = os.path.join(exp.suite_directory, exp_name_burnin)
    scen_df_burnin = pd.read_csv(os.path.join(scen_df_burnin_path, 'scenarios.csv'))
    return scen_df_burnin

get_workdir_from_simulations(platform, comps_simulations)

Get COMPS filepath Args: platform: idmtools Platform comps_simulations: COMPS Simulations Returns: dictionary with simid as key and filepath as value

Source code in EMOD\functions\EMOD_functions.py
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def get_workdir_from_simulations(platform: 'IPlatform', comps_simulations: List[Simulation]) -> Dict[str, str]:
    """
    Get COMPS filepath
    Args:
        platform: idmtools Platform
        comps_simulations: COMPS Simulations
    Returns: dictionary with simid as key and filepath as value
    """

    if platform.environment.upper() == "SLURMSTAGE" or platform.environment.upper() == "CALCULON":
        mounts = AuthManager.get_environment_macros(platform.environment)['DOCKER_MOUNTS']
        mounts = {v[0]: v[1:4] for v in [m.split(';') for m in mounts.split('|')]}
        # pretend I'm on Linux and set the Linux mapping environment variables
        for k, v in mounts.items():
            os.environ[k] = ';'.join([v[0], v[2]])
    sim_work_dir = {str(sim.id): sim.hpc_jobs[-1].working_directory for sim in comps_simulations if sim.hpc_jobs}

    return sim_work_dir

habitat_setup(config, exp, row)

Sets up the habitat parameters for malaria vector species in EMOD, based on the climate seasonality and experiment configuration. The function configures different habitat types (“CONSTANT” or “TEMPORARY_RAINFALL”) and larval capacity based on the seasonality condition (‘perennial’ or ‘seasonal’) for the specified malaria species (gambiae).

Parameters:
  • config (object) –

    The configuration object that holds the simulation settings and parameters.

  • exp (object) –

    The experiment object containing the population size and other simulation configurations.

  • row (Series) –

    A row of data containing scenario-specific information, such as seasonality.

Returns:
  • None

Source code in EMOD\functions\EMOD_functions.py
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
def habitat_setup(config, exp, row):
    """
    Sets up the habitat parameters for malaria vector species in EMOD, based on the climate seasonality
    and experiment configuration. The function configures different habitat types ("CONSTANT" or "TEMPORARY_RAINFALL")
    and larval capacity based on the seasonality condition ('perennial' or 'seasonal') for the specified malaria species (gambiae).

    Args:
        config (object): The configuration object that holds the simulation settings and parameters.
        exp (object): The experiment object containing the population size and other simulation configurations.
        row (pandas.Series): A row of data containing scenario-specific information, such as seasonality.

    Returns:
        None
    """

    # Parameter configurations on climate for dynamic EIR
    malaria_config.add_species(config, manifest, ["gambiae"])  # , "arabiensis", "funestus"
    max_capacity_multiplier = (exp.emod_pop_size / 1000)
    import emod_api.config.default_from_schema_no_validation as dfs
    if row.seasonality == 'perennial':
        habitat1 = dfs.schema_to_config_subnode(manifest.schema_file, ["idmTypes", "idmType:VectorHabitat"])
        habitat1.parameters.Habitat_Type = "CONSTANT"
        habitat1.parameters.Max_Larval_Capacity = 8000000 * max_capacity_multiplier
        habitat_list = [{"Habitat_Type": habitat1.parameters.Habitat_Type,
                         "Max_Larval_Capacity": habitat1.parameters.Max_Larval_Capacity}]
        malaria_config.set_species_param(config, 'gambiae', parameter="Habitats", value=habitat_list, overwrite=True)
    else:
        habitat1 = dfs.schema_to_config_subnode(manifest.schema_file, ["idmTypes", "idmType:VectorHabitat"])
        habitat1.parameters.Habitat_Type = "TEMPORARY_RAINFALL"
        habitat1.parameters.Max_Larval_Capacity = 100000000 * max_capacity_multiplier
        habitat_list = [{"Habitat_Type": habitat1.parameters.Habitat_Type,
                         "Max_Larval_Capacity": habitat1.parameters.Max_Larval_Capacity}]
        malaria_config.set_species_param(config, 'gambiae', parameter="Habitats", value=habitat_list, overwrite=True)
        habitat2 = dfs.schema_to_config_subnode(manifest.schema_file, ["idmTypes", "idmType:VectorHabitat"])
        habitat2.parameters.Habitat_Type = "CONSTANT"
        habitat2.parameters.Max_Larval_Capacity = 850000 * max_capacity_multiplier
        habitat_list = [{"Habitat_Type": habitat2.parameters.Habitat_Type,
                         "Max_Larval_Capacity": habitat2.parameters.Max_Larval_Capacity}]
        malaria_config.set_species_param(config, 'gambiae', parameter="Habitats", value=habitat_list, overwrite=False)

set_inputEIR_seasonality(camp, EIR_scale_factor=1, seasonality='perennial')

Set input EIR (Entomological Inoculation Rate) based on seasonality.

Parameters: - camp: Campaign object from EMOD. - EIR_scale_factor: Scaling factor for EIR (default is 1). - seasonality: Type of seasonality, either ‘perennial’ or ‘seasonal’ (default is ‘perennial’).

Returns: A dictionary containing the EIR scale factor and the specified seasonality.

Source code in EMOD\functions\forcedEIR.py
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
def set_inputEIR_seasonality(camp, EIR_scale_factor=1, seasonality='perennial'):
    """
    Set input EIR (Entomological Inoculation Rate) based on seasonality.

    Parameters:
    - camp: Campaign object from EMOD.
    - EIR_scale_factor: Scaling factor for EIR (default is 1).
    - seasonality: Type of seasonality, either 'perennial' or 'seasonal' (default is 'perennial').

    Returns:
    A dictionary containing the EIR scale factor and the specified seasonality.
    """

    season_daily, season_month, seasonal, perennial = get_seasonal_eir() 
    if seasonality == 'perennial':
        daily_EIR = [x / 365 for x in [1] * 365]
    elif seasonality == 'seasonal':
        daily_EIR = season_daily
        eir_sum = sum([x for x in daily_EIR])
        daily_EIR = [(x / eir_sum) for x in daily_EIR]  # rescale to sum = 1
    else:
        raise ValueError("Please specify valid seasonality")

    add_scheduled_input_eir(campaign=camp, start_day=1, daily_eir=daily_EIR, age_dependence="SURFACE_AREA_DEPENDENT",
                            node_ids=None, scaling_factor=EIR_scale_factor)

    return {'EIR_scale_factor': EIR_scale_factor,'seasonality': seasonality}

set_param(simulation, param, value)

Set specific parameter value Args: simulation: idmtools Simulation param: parameter value: new value Returns: dict

Source code in EMOD\functions\EMOD_functions.py
67
68
69
70
71
72
73
74
75
76
77
def set_param(simulation, param, value):
    """
    Set specific parameter value
    Args:
        simulation: idmtools Simulation
        param: parameter
        value: new value
    Returns:
        dict
    """
    return simulation.task.set_parameter(param, value)

sweep_functions(simulation, func_list)

Obtained from IDM’s emodpy-snt framework that had been modified for bf-seasonal https://github.com/numalariamodeling/bf-seasonal/blob/main/sweeping.py

Apply funcs on simulation. Args: simulation: idmtools Simulation func_list: a list of functions

Returns:
  • Dict[str, Any]

    dict of parameters

Source code in EMOD\functions\EMOD_functions.py
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
def sweep_functions(simulation: Simulation, func_list: List) -> Dict[str, Any]:
    """
    Obtained from IDM's emodpy-snt framework that had been modified for bf-seasonal
    https://github.com/numalariamodeling/bf-seasonal/blob/main/sweeping.py

    Apply funcs on simulation.
    Args:
        simulation: idmtools Simulation
        func_list: a list of functions

    Returns:
        dict of parameters
    """
    tags_updated = {}
    for func in func_list:
        tags = func(simulation)
        if tags:
            tags_updated.update(tags)
    return tags_updated

treatment_camp_simple(camp, cm_start, cm_clinical, cm_severe)

This function helps us establish treatment seeking behavior in an EMOD simulation.

Parameters: - camp: Campaign object from EMOD. - cm_start: Day when the treatment campaign starts. - cm_clinical: Clinical case coverage (float). - cm_severe: Severe case coverage (float).

Returns: A dictionary containing the start day of the treatment campaign, clinical case coverage, and severe case coverage.

Source code in EMOD\functions\interventions.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def treatment_camp_simple(camp, cm_start, cm_clinical, cm_severe):
    """
    This function helps us establish treatment seeking behavior in an EMOD simulation.

    Parameters:
    - camp: Campaign object from EMOD.
    - cm_start: Day when the treatment campaign starts.
    - cm_clinical: Clinical case coverage (float).
    - cm_severe: Severe case coverage (float).

    Returns:
    A dictionary containing the start day of the treatment campaign, clinical case coverage, and severe case coverage.
    """
    cm_clinical = float(cm_clinical)
    cm_severe = float(cm_severe)

    if cm_clinical * 1.15 > cm_severe:
        cm_severe = min(cm_clinical * 1.15, 1)
    if cm_clinical == 0:
        cm_severe = 0

    add_treatment_seeking(camp, start_day=cm_start, drug=['Artemether', 'Lumefantrine'],
                             targets=[
                                 {'trigger': 'NewClinicalCase', 'coverage': cm_clinical, 'agemin': 0, 'agemax': 115,
                                  'seek': 1, 'rate': 0.3}],
                             broadcast_event_name="Received_Treatment")

    add_treatment_seeking(camp, start_day=cm_start, drug=['Artemether', 'Lumefantrine'],
                             targets=[
                                 {'trigger': 'NewSevereCase', 'coverage': cm_severe, 'agemin': 0, 'agemax': 115,
                                  'seek': 1, 'rate': 0.5}],
                             broadcast_event_name="Received_Severe_Treatment")

    return {'cm_start': cm_start,'cm_clinical': cm_clinical, 'cm_severe': cm_severe}

update_mab(simulation, value)

Update the Maternal Antibody Protection parameter within the simulation.

Parameters:
  • simulation (object) –

    The simulation object from EMOD.

  • value (float) –

    The value by which to multiply the Maternal Antibody Protection parameter.

Returns:
  • None. The function modifies the simulation object in place.

Source code in EMOD\functions\forcedEIR.py
12
13
14
15
16
17
18
19
20
21
22
23
24
def update_mab(simulation, value):
    """
    Update the Maternal Antibody Protection parameter within the simulation.

    Parameters:
        simulation (object): The simulation object from EMOD.
        value (float): The value by which to multiply the Maternal Antibody Protection parameter.

    Returns:
        None. The function modifies the simulation object in place.
    """
    simulation.task.config.parameters.Maternal_Antibody_Protection *= value
    return None