'''
Set the parameters for Poliosim.
'''
import numpy as np
__all__ = ['strain_map', 'make_pars']
[docs]def strain_map(key=None, reverse=False):
''' Map from strain number to string '''
mapping = {'WPV': 0, 'S1': 1, 'S2': 2, 'S3': 3}
if reverse:
mapping = {v:k for k,v in mapping.items()}
if key:
return mapping[key]
else:
return mapping
def calculate_quarantine_subtarget(people, quarantine_candidate_inds):
''' Trace/quarantine everyone below the age cutoff '''
inds = quarantine_candidate_inds
vals = people.age[quarantine_candidate_inds] < people.pars['quar_age']
return {'inds': inds, 'vals': vals}
[docs]def make_pars(set_prognoses=False, **kwargs):
'''
Create the parameters for the simulation. Typically, this function is used
internally rather than called by the user; e.g. typical use would be to do
sim = ps.Sim() and then inspect sim.pars, rather than calling this function
directly.
Args:
set_prognoses (bool): whether or not to create prognoses (else, added when the population is created)
kwargs (dict): any additional kwargs are interpreted as parameter names
Returns:
pars (dict): the parameters of the simulation
'''
pars = {}
# Population parameters
pars['pop_size'] = 10e3 # Number of agents, i.e., people susceptible to SARS-CoV-2
pars['pop_infected'] = 10 # Number of initial infections
pars['pop_type'] = 'hybrid' # What type of population data to use -- random (fastest), synthpops (best), hybrid (compromise), or clustered (not recommended)
pars['location'] = 'KP' # What location to load data from -- default Pakistan
# Simulation parameters
pars['start_day'] = '2020-01-01' # Start day of the simulation
pars['end_day'] = None # End day of the simulation
pars['n_days'] = 365 # Number of days to run, if end_day isn't specified
pars['rand_seed'] = 1 # Random seed, if None, don't reset
pars['verbose'] = 0.1 # Whether or not to display information during the run -- options are 0 (silent), 1 (default), 2 (everything)
# Rescaling parameters
pars['pop_scale'] = 1 # Factor by which to scale the population -- e.g. pop_scale=10 with pop_size=100e3 means a population of 1 million
pars['rescale'] = False# Enable dynamic rescaling of the population -- starts with pop_scale=1 and scales up dynamically as the epidemic grows
pars['rescale_threshold'] = 0.05 # Fraction susceptible population that will trigger rescaling if rescaling
pars['rescale_factor'] = 1.2 # Factor by which the population is rescaled on each step
# Basic disease transmission
pars['beta'] = 2.3e-4 # Polio: Fecal-oral dose. Was 5e-7. UP/Bihar: 2.3e-4; last factor is for age fix # TODO: refactor
pars['scale_beta'] = 0.65 # Scale factor
pars['contacts'] = None # The number of contacts per layer; set by reset_layer_pars() below
pars['dynam_layer'] = None # Which layers are dynamic; set by reset_layer_pars() below
pars['beta_layer'] = None # Transmissibility per layer; set by reset_layer_pars() below
pars['n_imports'] = 0 # Average daily number of imported cases (actual number is drawn from Poisson distribution)
# Immunity model
pars['immunity_mode'] = 1 # 1: Wes & co immunity model. 0: immunity(t) = 1.0
pars['max_paralysis_immunity'] = 8.0
# Efficacy of protection measures
pars['asymp_factor'] = 1.0 # Multiply beta by this factor for asymptomatic cases; no statistically significant difference in transmissibility: https://www.sciencedirect.com/science/article/pii/S1201971220302502
pars['iso_factor'] = None # Multiply beta by this factor for diganosed cases to represent isolation; set by reset_layer_pars() below
pars['quar_factor'] = None # Quarantine multiplier on transmissibility and susceptibility; set by reset_layer_pars() below
pars['quar_period'] = 100 # Number of days to quarantine for; assumption based on standard policies
# Duration parameters: time for disease progression
pars['dur'] = {
'exp2inf': dict(dist='uniform', par1=1.0, par2=1.0), # Assume shedding starts day after infection
'inf2sym': dict(dist='lognormal_int', par1=12.0, par2=4.0) # Assume symptoms occur ~10 days after infection
}
# Severity parameters: probabilities of symptom progression
pars['rel_symp_prob'] = 1.0 # Scale factor for proportion of symptomatic cases
pars['prognoses'] = None # The actual arrays of prognoses by age; this is populated later
# Events and interventions
pars['interventions'] = [] # The interventions present in this simulation; populated by the user
pars['analyzers'] = [] # Custom analysis functions; populated by the user
pars['timelimit'] = None # Time limit for the simulation (seconds)
pars['stopping_func'] = None # A function to call to stop the sim partway through
pars['quarantine_subtarget'] = calculate_quarantine_subtarget # Supplied by the user; see people.py
pars['uuid'] = None # Supplied by the user; used to identify things in post-processing.
pars['user_measurements'] = None # Supplied by the user; dict of stuff to keep around e.g. for post-processing.
pars['mix_matrix'] = None
pars['selectors'] = None
pars['sabin_scale_parameters'] = np.array([2.3, 14, 8, 18], dtype=np.float32)
# Set layer parameters
pars['beta_layer'] = dict(h=1.0, s=0.5, w=0.5, c=0.5) # Per-population beta weights; relative
pars['contacts'] = dict(h=2.0, s=20, w=16, c=20) # Number of contacts per person per day, estimated
pars['dynam_layer'] = dict(h=0, s=0, w=0, c=0) # Which layers are dynamic -- none by default
pars['iso_factor'] = dict(h=0.3, s=0.1, w=0.1, c=0.1) # Multiply beta by this factor for people in isolation
pars['quar_factor'] = dict(h=0.6, s=0.2, w=0.2, c=0.2) # Multiply beta by this factor for people in quarantine
# Prognoses
pars['prognoses'] = dict(
age_cutoffs = np.array([0, 1, 2, 3, 4, 5, 15, 30, 45, 90]),
trans_ORs = np.array([1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]), # Odds ratios for relative transmissibility -- no evidence of differences
symp_probs = np.array([0.005, 0.005, 0.005, 0.005, 0.005, 0.0, 0.0, 0.0, 0.00, 0.00]), # Overall probability of developing symptoms (based on https://www.medrxiv.org/content/10.1101/2020.03.24.20043018v1.full.pdf, scaled for overall symptomaticity)
)
# Additional parameters -- to be refactored
pars['reps'] = 1
pars['n_sims'] = 1
pars['pickup'] = 0
pars['quar_age'] = 100 # Maximum age for quarantine
pars['quar_period'] = 100 # Number of days to quarantine regardless of shedding duration
pars['trace_prob'] = 0.0 # Probability of tracing
pars['test_delay'] = 0 # Number of days for test results to be returned
pars['vx_coverage'] = 0.125 # Campaign coverage fraction
pars['ri_coverage'] = 0.0 # routine immunization coverage fraction
pars['ri_ages_years'] = [0.115, 0.192, 0.269] # The ages at which RI doses are administered (6, 10, and 14 wks)
pars['immunity_mode'] = 1 # Immunization/immunity mode, default is 1. Mode 0 = everyone starts with immunity = 1 Nab titer, and it stays there. Mode 1 = perform a series of campaigns, and use the wwong and co immunity model.
pars['age_mixed_community_layer'] = 0 # Do age-mixing (non-zero) or not (0) in the community layer. Default is 0. When using this option, you must also use age_mix_breakpoints and age_mix_matrix.
pars['age_mix_breakpoints'] = '5' # Comma separated list of ages that define the age buckets.
pars['age_mix_matrix'] = '10,10,0,20' # Flattened NxN age mix matrix in rows-first order. If there are b age_mix_breakpoints, then N = b+1.
pars['save_infection_report'] = 0 # Save infection report (non-zero) or not (0) in the output data. The infection report analyzes categories of who infects who, and is not the same as the infection log.
pars['infection_report_age_breakpoints'] = '5,15' # Comma separated list of age breakpoints for infection report. Default is "5,15".
pars['label'] = None # Set label for scenario.
pars['symptomatic_triggered_surveillance_mu'] = 0.0 # Mean number of surveillance samples to take upon each detection of one or more symptomatic cases in a given day. Default 0.0 = symptomatic triggered surveillance disabled.
pars['symptomatic_triggered_surveillance_sigma'] = 0.0 # Std deviation for number of surveillance samples to take upon each detection of one or more symptomatic cases in a given day. Default 0.0 = disabled.
pars['symptomatic_triggered_surveillance_test_sensitivity'] = 1.0 # Test sensitivity for surveillance samples.
pars['symptomatic_triggered_surveillance_test_delay'] = 0 # Surveillance samples test delay (days).
pars['datafile'] = None
# Update with any supplied parameter values and generate things that need to be generated
pars.update(kwargs)
return pars
# Define which parametrs need to be specified as a dictionary by layer -- define here so it's available at the module level for sim.py
layer_pars = ['beta_layer', 'contacts', 'dynam_layer', 'iso_factor', 'quar_factor']