Scenario#

class Scenario(spec=None, label=None, pars=None, year=None, eff=None, dur_use=None, p_use=None, par=None, par_years=None, par_vals=None, interventions=None)[source]#

Bases: prettyobj, dictobj

Store the specification for a single scenario (which may consist of multiple interventions).

Note, this class may be deprecated. See the scripts in the examples folder and the tests in test_interventions for examples of how to define simulations with different parameters or interventions and run them in parallel.

Args (shared):

spec (dict): a pre-made specification of a scenario; see keyword explanations below (optional) args (list): additional specifications (optional) label (str): the sim label to use for this scenario pars (dict): optionally supply additional sim parameters to use with this scenario (that take effect at the beginning of the sim, not at the point of intervention) year (float): the year at which to activate efficacy and probability scenarios eff (dict): a dictionary of method names and new efficacy values par (str): the parameter to modify par_years (float/list): the year(s) at which to apply the modifications par_vals (float/list): the value(s) of the parameter for each year interventions (Intervention/list): any custom intervention(s) to be applied to the scenario

Congratulations on making it this far.

Examples:

# Basic efficacy scenario
s1 = fp.make_scen(eff={'Injectables':0.99}, year=2020)

# Parameter scenario: halve exposure
s2 = fp.make_scen(par='exposure_factor', par_years=2010, par_vals=0.5)

# Custom scenario
def update_sim(sim): sim.updated = True
s3 = fp.make_scen(interventions=update_sim)

# Scenarios can be combined (although this is not necessarily recommended)
s4 = s1 + s2

Methods

__add__(scen2)[source]#

Combine two scenario spec lists

update_label(label=None)[source]#

Ensure all specs have the correct label

run(run_args=None, **kwargs)[source]#

Shortcut for creating and running a Scenarios object based on the current scenario.

Parameters:
  • run_args (dict) – passed to scens.run()

  • kwargs (dict) – passed to Scenarios()