def bypass(): do_plot = True # Whether to plot results n_seeds = 6 # Number of seeds to run each simulation with rand_seed = 1 # Overwrite the default random seed bypass_popfile = 'trans_r0_medium.ppl' pop_size = int(100e3) entry = { "index": 376.0, "mismatch": 0.03221581045452142, "pars": { "pop_infected": 0, "change_beta": 0.5313884845187986, "symp_prob": 0.08250498122080606 } } params = sc.dcp(entry['pars']) if rand_seed is None: params['rand_seed'] = int(entry['index']) else: params['rand_seed'] = rand_seed # Ensure the population file exists if not os.path.exists(bypass_popfile): print(f'Population file {bypass_popfile} not found, recreating...') cvsch.make_population(pop_size=pop_size, rand_seed=params['rand_seed'], max_pop_seeds=5, popfile=bypass_popfile, do_save=True) scen = generate_scenarios()['as_normal'] # Create the sim people = sc.loadobj(bypass_popfile) base_sim = cs.create_sim(params, pop_size=pop_size, load_pop=False, people=people, verbose=0.1) # Run the sims sims = [] for seed in range(n_seeds): sim = sc.dcp(base_sim) sim.set_seed(seed=sim['rand_seed'] + seed) sim.label = f'Sim {seed}' sim['interventions'] += [cvsch.schools_manager(scen), seed_schools()] sim['beta_layer'] = dict( h=0.0, s=0.0, w=0.0, c=0.0, l=0.0 ) # Turn off transmission in other layers, looking for in-school R0 sims.append(sim) msim = cv.MultiSim(sims) msim.run(keep_people=True) return msim
def longway(): pop_size = 2.25e5 calibfile = os.path.join( folder, 'pars_cases_begin=75_cases_end=75_re=1.0_prevalence=0.002_yield=0.024_tests=225_pop_size=225000.json' ) par_list = sc.loadjson(calibfile)[par_inds[0]:par_inds[1]] scen = generate_scenarios()['as_normal'] for stype, cfg in scen.items(): if cfg: cfg['start_day'] = '2020-09-07' # Move school start earlier # Configure and run the sims sims = [] for eidx, entry in enumerate(par_list): par = sc.dcp(entry['pars']) par['rand_seed'] = int(entry['index']) # Clunky, but check that the population exists pop_seed = par['rand_seed'] % 5 popfile = os.path.join( folder, 'inputs', f'kc_synthpops_clustered_{int(pop_size)}_withstaff_seed') + str( pop_seed) + '.ppl' if not os.path.exists(popfile): print(f'Population file {popfile} not found, recreating...') cvsch.make_population(pop_size=pop_size, rand_seed=par['rand_seed'], max_pop_seeds=5, popfile=popfile, do_save=True) par['pop_infected'] = 0 # Do NOT seed infections par['beta_layer'] = dict( h=0.0, s=0.0, w=0.0, c=0.0, l=0.0 ) # Turn off transmission in other layers, looking for in-school R0 sim = cs.create_sim(par, pop_size=pop_size, folder=folder) delay = sim.day('2020-09-16') # Pick a Monday sim['interventions'] += [ cvsch.schools_manager(scen), seed_schools(delay=delay, n_infections=1, choose_students=False) ] sims.append(sim) msim = cv.MultiSim(sims) msim.run(keep_people=True) return msim
# Modify scen for stype, spec in scen.items(): if spec is not None: spec['screen_prob'] = 0 return scen def no_tracing(sim, scen, test): # Modify scen for stype, spec in scen.items(): if spec is not None: spec['trace_prob'] = 0 return scen if __name__ == '__main__': scenarios = t_s.generate_scenarios() #scenarios = {k:v for k,v in scenarios.items() if k in ['with_countermeasures', 'all_hybrid', 'k5', 'all_remote']} scenarios = {k:v for k,v in scenarios.items() if k in ['with_countermeasures']} testing = t_s.generate_testing() #testing = {k:v for k,v in testing.items() if k in ['None', 'PCR every 2w', 'Antigen every 1w teach&staff, PCR f/u', 'Antigen every 2w, PCR f/u']} testing = {k:v for k,v in testing.items() if k in ['None', 'Antigen every 2w, PCR f/u']} sensitivity = { # Baseline 'baseline': [baseline], # For K-5 in particular, masks could be challenging - what if we remove the 25% NPI boost? # --> Change beta in the scenario 'NPI': [baseline, no_NPI_reduction],
other_edges = edges_this_school.loc[ (~edges_this_school['p1_student']) | (~edges_this_school['p2_student'])] rewired_edges_this_school = pd.concat( [rewired_student_to_student_edges, other_edges]) school_contacts.append(rewired_edges_this_school) all_school_contacts = pd.concat(school_contacts) sim.people.contacts['s'] = cv.Layer().from_df(all_school_contacts) sm = cvsch.schools_manager(scen) sim['interventions'] += [sm] if __name__ == '__main__': scenarios = generate_scenarios() #scenarios = {k:v for k,v in scenarios.items() if k in ['with_countermeasures', 'all_hybrid', 'k5', 'all_remote']} scenarios = {k: v for k, v in scenarios.items() if k in ['k5']} testing = generate_testing() testing = { k: v for k, v in testing.items() if k in [ 'None', 'PCR every 2w', #'Antigen every 2w, PCR f/u', 'Antigen every 2w, no f/u', 'Antigen every 1w, PCR f/u', #'Antigen every 1w teach&staff, PCR f/u', ] }