def vaccin_model(initial_states, scenario, effectivity=None, injection_day=0, injection_ratio=0, Nc_fun=None, N_vacc_fun=vacc_strategy, levels=levels): """ Function to initialize the model given a certain vaccination strategy """ params = model_parameters.get_COVID19_SEIRD_parameters() params.update({ 'l': 5, 'tau': 5, 'prev_home': 0.5, 'prev_schools': 0.5, 'prev_work': 0.5, 'prev_rest': 0.5, 'scenario': scenario, 'injection_day': injection_day, 'injection_ratio': injection_ratio }) tdp = {} if Nc_fun is not None: tdp.update({'Nc': Nc_fun}) if N_vacc_fun is not None: tdp.update({'N_vacc': N_vacc_fun}) params.update({ 'd': d, 'NH': NH, 'e': np.array([effectivity] * levels) }) return models.COVID19_SEIRD(initial_states, params, time_dependent_parameters=tdp)
# Measures start_measures = pd.to_datetime('2020-03-15') if t < start_measures: return param elif start_measures < t <= start_measures + l_days: return ramp_fun(param, effectivity * param, t, start_measures, l) else: return param * effectivity # -------------------- # Initialize the model # -------------------- # Load the model parameters dictionary params = model_parameters.get_COVID19_SEIRD_parameters(VOC=False, vaccination=False) # Add the time-dependant parameter function arguments params.update({'l': 15, 'effectivity': 0.5}) # Define initial states initial_states = {"S": initN, "E": np.ones(9), "I": np.ones(9)} # Initialize model model = models.COVID19_SEIRD(initial_states, params, time_dependent_parameters={'Nc': compliance_func}) # ----------------------- # Define helper functions # ----------------------- from covid19model.optimization.utils import assign_PSO, plot_PSO, perturbate_PSO
# Extract build contact matrix function from covid19model.models.time_dependant_parameter_fncs import make_contact_matrix_function, ramp_fun policies_WAVE1 = make_contact_matrix_function(df_google, Nc_all).policies_WAVE1 # --------------------------------------------------- # Function to add poisson draws and sampling function # --------------------------------------------------- from covid19model.models.utils import output_to_visuals, draw_fcn_WAVE1 # -------------------- # Initialize the model # -------------------- # Load the model parameters dictionary params = model_parameters.get_COVID19_SEIRD_parameters(VOC=False) # Add the time-dependant parameter function arguments params.update({ 'l': 21, 'prev_schools': 0, 'prev_work': 0.5, 'prev_rest': 0.5, 'prev_home': 0.5 }) # Define initial states initial_states = {"S": initN, "E": np.ones(9), "I": np.ones(9)} # Initialize model model = models.COVID19_SEIRD(initial_states, params, time_dependent_parameters={'Nc': policies_WAVE1})
# -------------------------------------- # Time-dependant social contact function # -------------------------------------- # Extract build contact matrix function from covid19model.models.time_dependant_parameter_fncs import make_contact_matrix_function, delayed_ramp_fun, ramp_fun contact_matrix_4prev = make_contact_matrix_function(df_google, Nc_all) policies_WAVE2_full_relaxation = make_contact_matrix_function( df_google, Nc_all).policies_WAVE2_full_relaxation # -------------------- # Initialize the model # -------------------- # Load the model parameters dictionary params = model_parameters.get_COVID19_SEIRD_parameters(vaccination=True) # Add the time-dependant parameter function arguments # Social policies params.update({ 'l': 21, 'prev_schools': 0, 'prev_work': 0.5, 'prev_rest': 0.5, 'prev_home': 0.5, 'relaxdate': '2021-07-01', 'l_relax': 31 }) # VOC params.update({'t_sig': '2021-08-01'}) # No new Indian variant currently # Vaccination params.update({
param_dict['prev_rest'] = samples_dict['prev_rest'][idx] return param_dict results = pd.DataFrame(columns=['Date']) print('2) Starting scenario loop\n') for scenario in scenarios: print('\t# scenario ' + scenario) # -------------------- # Initialize the model # -------------------- # Load the model parameters using `get_COVID19_SEIRD_parameters()`. params = model_parameters.get_COVID19_SEIRD_parameters() # Add the time-dependant parameter function arguments params.update({ 'l': 5, 'tau': 5, 'prev_home': 0.5, 'prev_schools': 0.5, 'prev_work': 0.5, 'prev_rest': 0.5, 'scenario': scenario, 's': np.ones(9) }) # Initialize model = models.COVID19_SEIRD( initial_states, params,
from covid19model.models.time_dependant_parameter_fncs import make_contact_matrix_function, make_mobility_update_function # Define contact matrix functions based on 4 prevention parameters (effectivity parameters) policies_wave1 = make_contact_matrix_function( df_google, Nc_all).policies_WAVE1 # with delayed-ramp function # Mobility update function from class __call__ and function wrapper to get the right signature mobility_wrapper_function = make_mobility_update_function( proximus_mobility_data, proximus_mobility_data_avg).mobility_wrapper_func # --------------------- # Load model parameters # --------------------- # Load the model parameters dictionary params = model_parameters.get_COVID19_SEIRD_parameters(spatial=agg, VOC=False) # Add the time-dependant parameter function arguments params.update({ 'l': 5, # will be varied over in the full PSO/MCMC. Unimportant for pre-lockdown simulation 'prev_home': 0.5, # will be varied over in the full PSO/MCMC. Unimportant for pre-lockdown simulation 'prev_schools': 0, # fixed for wave 1 'prev_work': 0.5, # will be varied over in the full PSO/MCMC. Unimportant for pre-lockdown simulation 'prev_rest': 0.5, # will be varied over in the full PSO/MCMC. Unimportant for pre-lockdown simulation 'tau': 0.1 # tau has little to no influence. Fix it at low value in delayed_ramp_func }) # Add parameters for the daily update of proximus mobility