def __init__(self, ps: ParamStore, camp: str, profile: pd.DataFrame, profile_override_dict={}): self.ps = ps self.camp = camp disease_params = ps.get_disease_params() camp_params = ps.get_camp_params(camp) # ------------------------------------------------------------ # disease params parameter_csv = disease_params model_params = parameter_csv[parameter_csv['Type'] == 'Model Parameter'] model_params = model_params.loc[:, ['Name', 'Value']] control_data = parameter_csv[parameter_csv['Type'] == 'Control'] self.model_params = model_params profile.set_index('Parameter', inplace=True) self.number_of_people_in_isoboxes = int( profile.loc['number_of_people_in_isoboxes', 'Value']) self.number_of_people_in_one_isobox = int( profile.loc['number_of_people_in_one_isobox', 'Value']) self.number_of_isoboxes = self.number_of_people_in_isoboxes / \ self.number_of_people_in_one_isobox self.number_of_people_in_tents = int( profile.loc['number_of_people_in_tents', 'Value']) self.number_of_people_in_one_tent = int( profile.loc['number_of_people_in_one_tent', 'Value']) self.number_of_tents = self.number_of_people_in_tents / \ self.number_of_people_in_one_tent self.total_population = self.number_of_people_in_isoboxes + \ self.number_of_people_in_tents # float(profile.loc['permanently_asymptomatic_cases','Value']) self.permanently_asymptomatic_cases = 0.179 self.age_and_gender = abm.read_age_gender(self.total_population) # float(profile.loc['area_covered_by_isoboxes','Value']) self.area_covered_by_isoboxes = 0.5 # float(profile.loc['relative_strength_of_interaction','Value']) self.relative_strength_of_interaction = 0.2 # float(profile.loc['smaller_movement_radius','Value']) self.smaller_movement_radius = 0.02 # float(profile.loc['larger_movement_radius','Value']) self.larger_movement_radius = 0.1 # float(profile.loc['overlapping_rages_radius','Value']) self.overlapping_rages_radius = 0.02 self.number_of_steps = int(profile.loc['number_of_steps', 'Value']) self.number_of_states = 14 self.track_states = np.zeros( (self.number_of_steps, self.number_of_states)) # self.ACTIVATE_INTERVENTION = profile.loc['ACTIVATE_INTERVENTION', 'Value'] # int(profile.loc['total_number_of_hospitalized','Value']) self.total_number_of_hospitalized = 0 self.num_toilet_visit = int(profile.loc['num_toilet_visit', 'Value']) self.num_toilet_contact = int(profile.loc['num_toilet_contact', 'Value']) self.num_food_visit = int(profile.loc['num_food_visit', 'Value']) self.num_food_contact = int(profile.loc['num_food_contact', 'Value']) self.pct_food_visit = float(profile.loc['pct_food_visit', 'Value']) # float(profile.loc['transmission_reduction','Value']) self.transmission_reduction = 1 # float(profile.loc['probability_infecting_person_in_household_per_day','Value']) self.probability_infecting_person_in_household_per_day = 0.33 # float(profile.loc['probability_infecting_person_in_foodline_per_day','Value']) self.probability_infecting_person_in_foodline_per_day = 0.407 # float(profile.loc['probability_infecting_person_in_toilet_per_day','Value']) self.probability_infecting_person_in_toilet_per_day = 0.099 # float(profile.loc['probability_infecting_person_in_moving_per_day','Value']) self.probability_infecting_person_in_moving_per_day = 0.017 # float(profile.loc['probability_spotting_symptoms_per_day','Value']) self.probability_spotting_symptoms_per_day = 0.05 self.clearday = int(profile.loc['clearday', 'Value']) tb = profile.loc['toilets_blocks', 'Value'].split(',') self.toilets_blocks = (int(tb[0]), int(tb[1])) fb = profile.loc['foodline_blocks', 'Value'].split(',') self.foodline_blocks = (int(fb[0]), int(fb[1])) self.population = abm.form_population_matrix( self.total_population, self.number_of_isoboxes, self.number_of_people_in_isoboxes, self.number_of_tents, self.number_of_people_in_tents, self.permanently_asymptomatic_cases, self.age_and_gender) self.households_location = abm.place_households( self.population[:, 0].astype(int), self.area_covered_by_isoboxes, self.number_of_isoboxes) self.toilets_location, self.toilets_numbers, self.toilets_sharing = \ abm.position_toilet(self.households_location, self.toilets_blocks[0], self.toilets_blocks[1]) self.foodpoints_location, self.foodpoints_numbers, self.foodpoints_sharing = \ abm.position_foodline(self.households_location, self.foodline_blocks[0], self.foodline_blocks[1]) self.ethnical_corellations = abm.create_ethnic_groups( self.households_location, self.relative_strength_of_interaction) self.local_interaction_space = abm.interaction_neighbours( self.households_location, self.smaller_movement_radius, self.larger_movement_radius, self.overlapping_rages_radius, self.ethnical_corellations) # The probability that a person's disease state will change from mild->recovered (0.37) # Liu et al 2020 The Lancet. self.mild_rec = np.random.uniform( 0, 1, self.total_population) > math.exp(0.2 * math.log(0.1)) # The probability that a person's disease state will change from severe->recovered (0.071) # Cai et al. self.sev_rec = np.random.uniform( 0, 1, self.total_population) > math.exp(math.log(63 / 153) / 12) # Get random numbers to determine health states self.pick_sick = np.random.uniform(0, 1, self.total_population) self.ethnic_group1 = float(profile.loc['ethnic_group1', 'Value']) self.ethnic_group2 = float(profile.loc['ethnic_group2', 'Value']) self.ethnic_group3 = float(profile.loc['ethnic_group3', 'Value']) self.ethnic_group4 = float(profile.loc['ethnic_group4', 'Value']) self.ethnic_group5 = float(profile.loc['ethnic_group5', 'Value']) self.ethnic_group6 = float(profile.loc['ethnic_group6', 'Value']) self.ethnic_group7 = float(profile.loc['ethnic_group7', 'Value']) self.ethnic_others = float(profile.loc['ethnic_others', 'Value']) self.percentage_of_toilet_queue_cleared_at_each_step = \ float(profile.loc['percentage_of_toilet_queue_cleared_at_each_step', 'Value']) self.infection_radius = float(profile.loc['infection_radius', 'Value']) self.pct_female = float(profile.loc['pct_female', 'Value']) # Age proportions by age slot i.e. 0-9, 10-19, 20-29, ... 80-89, 90+ self.pct_0_9 = float(profile.loc['pct_0_9', 'Value']) self.pct_10_19 = float(profile.loc['pct_10_19', 'Value']) self.pct_20_29 = float(profile.loc['pct_20_29', 'Value']) self.pct_30_39 = float(profile.loc['pct_30_39', 'Value']) self.pct_40_49 = float(profile.loc['pct_40_49', 'Value']) self.pct_50_59 = float(profile.loc['pct_50_59', 'Value']) self.pct_60_69 = float(profile.loc['pct_60_69', 'Value']) self.pct_70_79 = float(profile.loc['pct_70_79', 'Value']) self.pct_80_89 = float(profile.loc['pct_80_89', 'Value']) self.pct_90 = float(profile.loc['pct_90', 'Value']) self.validate() self.control_dict = {}
def __init__(self, ps: ParamStore, camp: str, profile: pd.DataFrame, profile_override_dict={}): self.ps = ps self.camp = camp disease_params = ps.get_disease_params() camp_params = ps.get_camp_params(camp) # ------------------------------------------------------------ # disease params parameter_csv = disease_params model_params = parameter_csv[parameter_csv['Type'] == 'Model Parameter'] model_params = model_params.loc[:, ['Name', 'Value']] control_data = parameter_csv[parameter_csv['Type'] == 'Control'] self.model_params = model_params profile.set_index('Parameter', inplace=True) self.number_of_people_in_isoboxes = int( profile.loc['number_of_people_in_isoboxes', 'Value']) self.number_of_people_in_one_isobox = int( profile.loc['number_of_people_in_one_isobox', 'Value']) self.number_of_isoboxes = self.number_of_people_in_isoboxes / self.number_of_people_in_one_isobox self.number_of_people_in_tents = int( profile.loc['number_of_people_in_tents', 'Value']) self.number_of_people_in_one_tent = int( profile.loc['number_of_people_in_one_tent', 'Value']) self.number_of_tents = self.number_of_people_in_tents / self.number_of_people_in_one_tent self.total_population = self.number_of_people_in_isoboxes + self.number_of_people_in_tents self.permanently_asymptomatic_cases = float( profile.loc['permanently_asymptomatic_cases', 'Value']) self.age_and_gender = abm.read_age_gender(self.total_population) self.area_covered_by_isoboxes = float( profile.loc['area_covered_by_isoboxes', 'Value']) self.relative_strength_of_interaction = float( profile.loc['relative_strength_of_interaction', 'Value']) self.smaller_movement_radius = float( profile.loc['smaller_movement_radius', 'Value']) self.larger_movement_radius = float( profile.loc['larger_movement_radius', 'Value']) self.overlapping_rages_radius = float( profile.loc['overlapping_rages_radius', 'Value']) self.number_of_steps = int(profile.loc['number_of_steps', 'Value']) self.number_of_states = 14 self.track_states = np.zeros( (self.number_of_steps, self.number_of_states)) self.ACTIVATE_INTERVENTION = profile.loc['ACTIVATE_INTERVENTION', 'Value'] self.total_number_of_hospitalized = int( profile.loc['total_number_of_hospitalized', 'Value']) self.num_toilet_visit = int(profile.loc['num_toilet_visit', 'Value']) self.num_toilet_contact = int(profile.loc['num_toilet_contact', 'Value']) self.num_food_visit = int(profile.loc['num_food_visit', 'Value']) self.num_food_contact = int(profile.loc['num_food_contact', 'Value']) self.pct_food_visit = float(profile.loc['pct_food_visit', 'Value']) self.transmission_reduction = float( profile.loc['transmission_reduction', 'Value']) self.probability_infecting_person_in_household_per_day = float( profile.loc['probability_infecting_person_in_household_per_day', 'Value']) self.probability_infecting_person_in_foodline_per_day = float( profile.loc['probability_infecting_person_in_foodline_per_day', 'Value']) self.probability_infecting_person_in_toilet_per_day = float( profile.loc['probability_infecting_person_in_toilet_per_day', 'Value']) self.probability_infecting_person_in_moving_per_day = float( profile.loc['probability_infecting_person_in_moving_per_day', 'Value']) self.probability_spotting_symptoms_per_day = float( profile.loc['probability_spotting_symptoms_per_day', 'Value']) self.clearday = int(profile.loc['clearday', 'Value']) tb = profile.loc['toilets_blocks', 'Value'].split(',') self.toilets_blocks = (int(tb[0]), int(tb[1])) fb = profile.loc['foodline_blocks', 'Value'].split(',') self.foodline_blocks = (int(fb[0]), int(fb[1])) self.population = abm.form_population_matrix( self.total_population, self.number_of_isoboxes, self.number_of_people_in_isoboxes, self.number_of_tents, self.number_of_people_in_tents, self.permanently_asymptomatic_cases, self.age_and_gender) self.households_location = abm.place_households( self.population[:, 0].astype(int), self.area_covered_by_isoboxes, self.number_of_isoboxes) self.toilets_location, self.toilets_numbers, self.toilets_sharing = \ abm.position_toilet(self.households_location , self.toilets_blocks[0], self.toilets_blocks[1]) self.foodpoints_location, self.foodpoints_numbers, self.foodpoints_sharing = \ abm.position_foodline(self.households_location, self.foodline_blocks[0], self.foodline_blocks[1]) self.ethnical_corellations = abm.create_ethnic_groups( self.households_location, self.relative_strength_of_interaction) self.local_interaction_space = abm.interaction_neighbours( self.households_location, self.smaller_movement_radius, self.larger_movement_radius, self.overlapping_rages_radius, self.ethnical_corellations) self.control_dict = {}
def __init__(self, ps: ParamStore, camp: str, profile: pd.DataFrame, profile_override_dict={}): self.ps = ps self.camp = camp self.age_limits = np.array([0, 10, 20, 30, 40, 50, 60, 70, 80], dtype=int) disease_params = ps.get_disease_params() self.camp_params = ps.get_camp_params(camp) # ------------------------------------------------------------ # disease params parameter_csv = disease_params model_params = parameter_csv[parameter_csv['Type'] == 'Model Parameter'] model_params = model_params.loc[:, ['Name', 'Value']] control_data = parameter_csv[parameter_csv['Type'] == 'Control'] self.model_params = model_params # print() R_0_list = np.asarray(model_params[model_params['Name'] == 'R0'].Value) latent_rate = 1 / (np.float( model_params[model_params['Name'] == 'latent period'].Value)) removal_rate = 1 / (np.float( model_params[model_params['Name'] == 'infectious period'].Value)) hosp_rate = 1 / (np.float( model_params[model_params['Name'] == 'hosp period'].Value)) death_rate = 1 / (np.float( model_params[model_params['Name'] == 'death period'].Value)) death_rate_with_ICU = 1 / (np.float(model_params[ model_params['Name'] == 'death period with ICU'].Value)) quarant_rate = 1 / (np.float( model_params[model_params['Name'] == 'quarantine period'].Value)) death_prob_with_ICU = np.float( model_params[model_params['Name'] == 'death prob with ICU'].Value) number_compartments = int( model_params[model_params['Name'] == 'number_compartments'].Value) beta_list = [R_0 * removal_rate for R_0 in R_0_list] # R_0 mu/N, N=1 shield_decrease = np.float( control_data[control_data['Name'] == 'Reduction in contact between groups'].Value) shield_increase = np.float(control_data[ control_data['Name'] == 'Increase in contact within group'].Value) better_hygiene = np.float( control_data.Value[control_data.Name == 'Better hygiene']) AsymptInfectiousFactor = np.float(model_params[ model_params['Name'] == 'infectiousness of asymptomatic'].Value) self.R_0_list = R_0_list self.beta_list = beta_list self.shield_increase = shield_increase self.shield_decrease = shield_decrease self.better_hygiene = better_hygiene self.number_compartments = number_compartments self.AsymptInfectiousFactor = AsymptInfectiousFactor self.latent_rate = latent_rate self.removal_rate = removal_rate self.hosp_rate = hosp_rate self.quarant_rate = quarant_rate self.death_rate = death_rate self.death_rate_with_ICU = death_rate_with_ICU self.death_prob_with_ICU = death_prob_with_ICU categs = pd.read_csv(pu.cm_params_path('categories.csv'), delimiter=';', skipinitialspace=True) self.calculated_categories = categs['category'].to_list() categs['index'] = np.arange(self.number_compartments) change_categs = pd.read_csv(pu.cm_params_path('change_categories.csv'), delimiter=';', skipinitialspace=True) self.change_in_categories = change_categs['category'].to_list() change_categs['index'] = np.arange(len(categs), 2 * self.number_compartments) new_infected_category = { 'category': 'Ninf', 'shortname': 'New Infected', 'longname': 'Change in total active infections', 'colour': 'rgb(255,125,100)', 'colour_name': '', 'index': 2 * self.number_compartments } all_categs = pd.concat( [categs, change_categs, pd.DataFrame([new_infected_category])]) all_categs['fill_colour'] = all_categs.apply( lambda row: 'rgba' + row['colour'][3:-1] + ',0.1)', axis=1) self.categories: dict = all_categs.set_index( all_categs['category']).transpose().to_dict() self.population_frame, self.population = self.prepare_population_frame( self.camp_params) self.control_dict, self.icu_count = self.load_control_dict( profile, profile_override_dict) self.infection_matrix, self.im_beta_list, self.largest_eigenvalue = self.generate_infection_matrix( ) self.generated_disease_vectors = self.ps.get_generated_disease_param_vectors( )
def __init__(self, ps: ParamStore, camp: str, profile: pd.DataFrame, profile_override_dict={}): self.ps = ps if profile is not None: self.profile_name = profile['Profile'].iloc[0] else: self.profile_name = 'None' # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Camp parameters # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% self.camp = camp self.camp_params = ps.get_camp_params_network_model(self.camp) # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Model Parameters # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% profile.set_index('Parameter', inplace=True) # Sample the population age, and parameter rates self.total_population = int( self.camp_params.Total_population.dropna().sum()) # n_pop self.sample_pop = sample_population( self.total_population, "ai4good/models/nm/data/augmented_population.csv") # Tents self.number_of_tents = int(profile.loc['number_of_tents', 'Value']) # n_tents self.total_population_in_tents = int( profile.loc['total_population_in_tents', 'Value']) # pop_tents self.number_of_people_in_one_tent = int( profile.loc['number_of_people_in_one_tent', 'Value']) # pop_per_tent # The radius of nearby structures whose inhabitants a person has connections with self.neighbor_proximity = int(profile.loc['neighbor_proximity', 'Value']) # Edge weight for friendship connections self.neighbor_weight = float(profile.loc['neighbor_weight', 'Value']) # Edge weight for connections in the food queue self.food_weight = float(profile.loc['food_weight', 'Value']) # Edge weight for connections within each structure self.household_weight = float(profile.loc['household_weight', 'Value']) # Others self.number_of_ethnic_groups = int( profile.loc['number_of_ethnic_groups', 'Value']) # n_ethnic_groups # Isoboxes self.number_of_people_in_isoboxes = int( profile.loc['number_of_people_in_isoboxes', 'Value']) # pop_isoboxes self.number_of_people_in_one_isobox = int( profile.loc['number_of_people_in_one_isobox', 'Value']) # pop_per_isobox self.t_steps = int(profile.loc['number_of_steps', 'Value']) # Grid info for isoboxes dimensions_of_isoboxes = profile.loc['dimensions_of_isoboxes', 'Value'].split(',') self.dims_isoboxes = (int(dimensions_of_isoboxes[0]), int(dimensions_of_isoboxes[1])) # Grid info for tents dimensions_of_block1 = profile.loc['dimensions_of_block1', 'Value'].split(',') self.dims_block1 = (int(dimensions_of_block1[0]), int(dimensions_of_block1[1])) dimensions_of_block2 = profile.loc['dimensions_of_block2', 'Value'].split(',') self.dims_block2 = (int(dimensions_of_block2[0]), int(dimensions_of_block2[1])) dimensions_of_block3 = profile.loc['dimensions_of_block3', 'Value'].split(',') self.dims_block3 = (int(dimensions_of_block3[0]), int(dimensions_of_block3[1])) self.n_isoboxes = self.dims_isoboxes[0] * self.dims_isoboxes[1] # Define the maximum population per structures (tents and isoboxes) drawn from a poisson distribution max_pop_per_struct_isoboxes = list( poisson.rvs(mu=self.number_of_people_in_one_isobox, size=self.n_isoboxes)) max_pop_per_struct_block1 = list( poisson.rvs(mu=self.number_of_people_in_one_tent, size=self.dims_block1[0] * self.dims_block1[1])) max_pop_per_struct_block2 = list( poisson.rvs(mu=self.number_of_people_in_one_tent, size=self.dims_block2[0] * self.dims_block2[1])) max_pop_per_struct_block3 = list( poisson.rvs(mu=self.number_of_people_in_one_tent, size=self.dims_block3[0] * self.dims_block3[1])) self.max_pop_per_struct = max_pop_per_struct_isoboxes \ + max_pop_per_struct_block1 \ + max_pop_per_struct_block2 \ + max_pop_per_struct_block3 self.n_structs = len(self.max_pop_per_struct) self.grid_isoboxes = create_grid(self.dims_isoboxes[0], self.dims_isoboxes[1], 0) self.grid_block1 = create_grid(self.dims_block1[0], self.dims_block1[1], self.grid_isoboxes[-1][-1] + 1) self.grid_block2 = create_grid(self.dims_block2[0], self.dims_block2[1], self.grid_block1[-1][-1] + 1) self.grid_block3 = create_grid(self.dims_block3[0], self.dims_block3[1], self.grid_block2[-1][-1] + 1) # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Distribution based parameters # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% disease_params = ps.get_disease_params_network_model() model_params = disease_params.loc[:, ['Name', 'Value']] self.latentPeriod_mean = np.float( model_params[model_params['Name'] == 'latent_period_mean'].Value) self.latentPeriod_coeffvar = np.float(model_params[ model_params['Name'] == 'latent_period_standard_deviation'].Value) self.presymptomaticPeriod_mean = np.float(model_params[ model_params['Name'] == 'presymptomatic_period_mean'].Value) self.presymptomaticPeriod_coeffvar = np.float( model_params[model_params['Name'] == 'presymptomatic_period_standard_deviation'].Value) self.symptomaticPeriod_mean = np.float(model_params[ model_params['Name'] == 'symptomatic_period_mean'].Value) self.symptomaticPeriod_coeffvar = np.float( model_params[model_params['Name'] == 'symptomatic_period_standard_deviation'].Value) self.onsetToHospitalizationPeriod_mean = np.float( model_params[model_params['Name'] == 'onset_to_hospitalization_period_mean'].Value) self.onsetToHospitalizationPeriod_coeffvar = np.float(model_params[ model_params['Name'] == 'onset_to_hospitalization_period_standard_deviation'].Value) self.hospitalizationToDischargePeriod_mean = np.float( model_params[model_params['Name'] == 'hospitalization_to_discharge_period_mean'].Value) self.hospitalizationToDischargePeriod_coeffvar = np.float(model_params[ model_params['Name'] == 'hospitalization_to_discharge_period_standard_deviation'].Value) self.hospitalizationToDeathPeriod_mean = np.float( model_params[model_params['Name'] == 'hospitalization_to_death_period_mean'].Value) self.hospitalizationToDeathPeriod_coeffvar = np.float(model_params[ model_params['Name'] == 'hospitalization_to_death_period_standard_deviation'].Value) self.R0_mean = np.float( model_params[model_params['Name'] == 'R0_mean'].Value) self.R0_coeffvar = np.float(model_params[ model_params['Name'] == 'R0_standard_deviation'].Value) self.sigma = 1 / \ gamma_dist(self.latentPeriod_mean, self.latentPeriod_coeffvar, self.total_population) self.lamda = 1 / \ gamma_dist(self.presymptomaticPeriod_mean, self.presymptomaticPeriod_coeffvar, self.total_population) self.gamma = 1 / \ gamma_dist(self.symptomaticPeriod_mean, self.symptomaticPeriod_coeffvar, self.total_population) self.eta = 1 / gamma_dist(self.onsetToHospitalizationPeriod_mean, self.onsetToHospitalizationPeriod_coeffvar, self.total_population) self.gamma_H = 1 / gamma_dist( self.hospitalizationToDischargePeriod_mean, self.hospitalizationToDischargePeriod_coeffvar, self.total_population) self.mu_H = 1 / gamma_dist(self.hospitalizationToDeathPeriod_mean, self.hospitalizationToDeathPeriod_coeffvar, self.total_population) self.R0 = gamma_dist(self.R0_mean, self.R0_coeffvar, self.total_population) self.infectiousPeriod = 1 / self.lamda + 1 / self.gamma self.beta = 1 / self.infectiousPeriod * self.R0 self.beta_pairwise_mode = 'infected' self.delta_pairwise_mode = 'mean' # Constant parameters self.p_global_interaction = 0.2 self.init_exposed = int(self.total_population / 100) self.init_infected = int(self.total_population / 100) self.transmission_mean = self.beta.mean() self.progressionToInfectious_mean = self.sigma.mean() self.progressionToSymptomatic_mean = self.lamda.mean() self.recovery_mean = self.gamma.mean() self.hospitalization_mean = self.eta.mean() # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Reduced interaction parameters # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% self.reduction_rate = np.float( model_params[model_params['Name'] == 'reduction_rate'].Value) self.beta_q = self.beta * (self.reduction_rate / self.R0_mean) self.q_global_interactions = np.float( model_params[model_params['Name'] == 'q_globalintxn'].Value) self.q_start = int(profile.loc['quarantine_start', 'Value']) self.m_start = int(profile.loc['masks_start', 'Value']) self.q_end = int(profile.loc['quarantine_end', 'Value']) self.m_end = int(profile.loc['masks_end', 'Value'])
def __init__(self, ps: ParamStore, camp: str, profile: pd.DataFrame, profile_override_dict): self.ps = ps self.camp = camp disease_params = ps.get_disease_params() camp_params = ps.get_camp_params(camp) parameter_csv = disease_params model_params = parameter_csv[parameter_csv['Type'] == 'Model Parameter'] model_params = model_params.loc[:, ['Name', VALUE]] self.model_params = model_params profile.set_index('Parameter', inplace=True) ############################################################################################################### # Parameters about the simulation # Number of days of simulation self.number_of_steps = int(profile.loc['number_of_steps', VALUE]) # If a susceptible and an infectious individual interact during wandering, then the infection is transmitted # with some probability. This param can be updated by using the `transmission_reduction` parameter self.prob_spread_wander = float(profile.loc['prob_spread_wander', VALUE]) # Probability of infection spread when two agents interact in household self.prob_spread_house = float(profile.loc['prob_spread_house', VALUE]) # Probability of infection spread when two agents interact while waiting in toilet queue self.prob_spread_toilet = float(profile.loc['prob_spread_toilet', VALUE]) # Probability of infection spread when two agents interact while waiting in food line queue self.prob_spread_foodline = float(profile.loc['prob_spread_foodline', VALUE]) ############################################################################################################### # Parameters about the camp # Number of agents for simulation self.num_people = int(camp_params.loc[camp_params.Age == '0-9', 'Total_population'].item()) # Total number of people in the iso-boxes self.number_of_people_in_isoboxes = int( profile.loc['number_of_people_in_isoboxes', VALUE]) # Iso-box capacity self.number_of_people_in_one_isobox = int( profile.loc['number_of_people_in_one_isobox', VALUE]) # Total number of people in the tents self.number_of_people_in_tents = int( profile.loc['number_of_people_in_tents', VALUE]) # Tent capacity self.number_of_people_in_one_tent = int( profile.loc['number_of_people_in_one_tent', VALUE]) # Proportion of area covered by iso-boxes self.area_covered_by_isoboxes = float( profile.loc['area_covered_by_isoboxes', VALUE]) # Average number of toilets visit per day self.num_toilet_visit = int(profile.loc['num_toilet_visit', VALUE]) # Average number of food line visits per day self.num_food_visit = int(profile.loc['num_food_visit', VALUE]) # Probability that agent will attend food line on any given day. For Moria, person attends once every 4 days, so # probability value would be 0.75 self.pct_food_visit = float(profile.loc['pct_food_visit', VALUE]) # Grid size for toilet placement tb = profile.loc['toilets_blocks', VALUE].split(',') self.toilets_blocks = (int(tb[0]), int(tb[1])) # Grid size for food line placement fb = profile.loc['foodline_blocks', VALUE].split(',') self.foodline_blocks = (int(fb[0]), int(fb[1])) # Ethnic groups and their proportions in the camp self.ethnic_groups = [ # Currently, all agents have same ethnicity, this will be added as input from camp later on ['ethnic_group1', 1.0] ] # Radius around a person where infection spread can happen. If people engage more in the camp, then this value # will be higher (e.g. more handshakes etc.) try: # TODO: add to parameters after confirming with Gaia and Vera self.infection_radius = float(profile.loc['infection_radius', VALUE]) except KeyError: self.infection_radius = 0.01 # for 1x1 km sq. camp, this is 1 meter. ############################################################################################################### # Parameters about the agents # Probability that agent >16 yrs old becomes asymptomatic self.permanently_asymptomatic_cases = float( profile.loc['permanently_asymptomatic_cases', VALUE]) # Age and gender data (read from file) self.age_and_gender = self.read_age_gender( self.number_of_people_in_isoboxes + self.number_of_people_in_tents) # Home range for agents who are either 1)female or 2)less than 10 yrs old self.smaller_movement_radius = float( profile.loc['smaller_movement_radius', VALUE]) # Home range for rest of the agents self.larger_movement_radius = float( profile.loc['larger_movement_radius', VALUE]) # Account for relative encounter rate between agents of same ethnicity self.relative_strength_of_interaction = float( profile.loc['relative_strength_of_interaction', VALUE]) ############################################################################################################### # Parameters relevant for interventions # Factor to scale probability of spread (by wearing masks, etc.) self.transmission_reduction = float( profile.loc['transmission_reduction', VALUE]) # Probability that camp managers can detect symptomatic people in the camp so as to isolate them self.probability_spotting_symptoms_per_day = Parameters.get_float( profile, "probability_spotting_symptoms_per_day") # Number of days needed to be cleared of isolation self.clear_day = int(profile.loc['clearday', VALUE]) # Probability that people will violate lockdown self.prop_violating_lockdown = Parameters.get_float( profile, "prop_violating_lockdown") # New home range of agents following lockdown self.lockdown_home_range = Parameters.get_float( profile, "lockdown_home_range") self.percentage_of_toilet_queue_cleared_at_each_step = 1.0 # TODO: add to the new list of parameters # float(profile.loc['percentage_of_toilet_queue_cleared_at_each_step', VALUE]) ############################################################################################################### # Camp params self.prob_symp2sevr = [ camp_params.loc[ # 0-9 camp_params.Age == '0-9', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 10-19 camp_params.Age == '10-19', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 20-29 camp_params.Age == '20-29', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 30-39 camp_params.Age == '30-39', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 40-49 camp_params.Age == '40-49', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 50-59 camp_params.Age == '50-59', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 60-69 camp_params.Age == '60-69', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 70-79 camp_params.Age == '70+', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 80-89 camp_params.Age == '70+', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), camp_params.loc[ # 90+ camp_params.Age == '70+', 'Rough prob symptomatic case becomes critical (just multiplying)'] .item(), ] self.prob_symp2sevr = np.array([float(p) for p in self.prob_symp2sevr]) self.prob_symp2mild = np.array([(1.0 - p) for p in self.prob_symp2sevr]) self.validate()
def __init__(self, ps: ParamStore, camp: str, profile: pd.DataFrame, profile_override_dict={}): self.ps = ps self.camp = camp disease_params = ps.get_disease_params() camp_params = ps.get_camp_params(camp) # ------------------------------------------------------------ # disease params parameter_csv = disease_params model_params = parameter_csv[parameter_csv['Type'] == 'Model Parameter'] model_params = model_params.loc[:, ['Name', 'Value']] control_data = parameter_csv[parameter_csv['Type'] == 'Control'] self.model_params = model_params # print() R_0_list = np.asarray(model_params[model_params['Name'] == 'R0'].Value) latent_rate = 1 / (np.float( model_params[model_params['Name'] == 'latent period'].Value)) removal_rate = 1 / (np.float( model_params[model_params['Name'] == 'infectious period'].Value)) hosp_rate = 1 / (np.float( model_params[model_params['Name'] == 'hosp period'].Value)) death_rate = 1 / (np.float( model_params[model_params['Name'] == 'death period'].Value)) death_rate_with_ICU = 1 / (np.float(model_params[ model_params['Name'] == 'death period with ICU'].Value)) quarant_rate = 1 / (np.float( model_params[model_params['Name'] == 'quarantine period'].Value)) death_prob_with_ICU = np.float( model_params[model_params['Name'] == 'death prob with ICU'].Value) number_compartments = int( model_params[model_params['Name'] == 'number_compartments'].Value) beta_list = [R_0 * removal_rate for R_0 in R_0_list] # R_0 mu/N, N=1 shield_decrease = np.float( control_data[control_data['Name'] == 'Reduction in contact between groups'].Value) shield_increase = np.float(control_data[ control_data['Name'] == 'Increase in contact within group'].Value) better_hygiene = np.float( control_data.Value[control_data.Name == 'Better hygiene']) AsymptInfectiousFactor = np.float(model_params[ model_params['Name'] == 'infectiousness of asymptomatic'].Value) self.R_0_list = R_0_list self.beta_list = beta_list self.shield_increase = shield_increase self.shield_decrease = shield_decrease self.better_hygiene = better_hygiene self.number_compartments = number_compartments self.AsymptInfectiousFactor = AsymptInfectiousFactor self.latent_rate = latent_rate self.removal_rate = removal_rate self.hosp_rate = hosp_rate self.quarant_rate = quarant_rate self.death_rate = death_rate self.death_rate_with_ICU = death_rate_with_ICU self.death_prob_with_ICU = death_prob_with_ICU self.S_ind = 0 self.E_ind = 1 self.I_ind = 2 self.A_ind = 3 self.R_ind = 4 self.H_ind = 5 self.C_ind = 6 self.D_ind = 7 self.O_ind = 8 self.Q_ind = 9 self.U_ind = 10 self.index = { 'S': self.S_ind, 'E': self.E_ind, 'I': self.I_ind, 'A': self.A_ind, 'R': self.R_ind, 'H': self.H_ind, 'C': self.C_ind, 'D': self.D_ind, 'O': self.O_ind, 'Q': self.Q_ind, 'U': self.U_ind, 'CS': self.number_compartments + self.S_ind, 'CE': self.number_compartments + self.E_ind, 'CI': self.number_compartments + self.I_ind, 'CA': self.number_compartments + self.A_ind, 'CR': self.number_compartments + self.R_ind, 'CH': self.number_compartments + self.H_ind, 'CC': self.number_compartments + self.C_ind, 'CD': self.number_compartments + self.D_ind, 'CO': self.number_compartments + self.O_ind, 'CQ': self.number_compartments + self.Q_ind, 'CU': self.number_compartments + self.U_ind, 'Ninf': 2 * self.number_compartments } self.calculated_categories = [ 'S', 'E', 'I', 'A', 'R', 'H', 'C', 'D', 'O', 'Q', 'U' ] self.change_in_categories = [ 'C' + ii for ii in self.calculated_categories ] # gives daily change for each category self.longname = { 'S': 'Susceptible', 'E': 'Exposed', 'I': 'Infected (symptomatic)', 'A': 'Asymptomatically Infected', 'R': 'Recovered', 'H': 'Hospitalised', 'C': 'Critical', 'D': 'Deaths', 'O': 'Offsite', 'Q': 'Quarantined', 'U': 'No ICU Care', 'CS': 'Change in Susceptible', 'CE': 'Change in Exposed', 'CI': 'Change in Infected (symptomatic)', 'CA': 'Change in Asymptomatically Infected', 'CR': 'Change in Recovered', 'CH': 'Change in Hospitalised', 'CC': 'Change in Critical', 'CD': 'Change in Deaths', 'CO': 'Change in Offsite', 'CQ': 'Change in Quarantined', 'CU': 'Change in No ICU Care', 'Ninf': 'Change in total active infections', # sum of E, I, A } self.shortname = { 'S': 'Sus.', 'E': 'Exp.', 'I': 'Inf. (symp.)', 'A': 'Asym.', 'R': 'Rec.', 'H': 'Hosp.', 'C': 'Crit.', 'D': 'Deaths', 'O': 'Offsite', 'Q': 'Quar.', 'U': 'No ICU', 'CS': 'Change in Sus.', 'CE': 'Change in Exp.', 'CI': 'Change in Inf. (symp.)', 'CA': 'Change in Asym.', 'CR': 'Change in Rec.', 'CH': 'Change in Hosp.', 'CC': 'Change in Crit.', 'CD': 'Change in Deaths', 'CO': 'Change in Offsite', 'CQ': 'Change in Quar.', 'CU': 'Change in No ICU', 'Ninf': 'New Infected', # newly exposed to the disease = - change in susceptibles } self.colour = { 'S': 'rgb(0,0,255)', #'blue', 'E': 'rgb(255,150,255)', #'pink', 'I': 'rgb(255,150,50)', #'orange', 'A': 'rgb(255,50,50)', #'dunno', 'R': 'rgb(0,255,0)', #'green', 'H': 'rgb(255,0,0)', #'red', 'C': 'rgb(50,50,50)', #'black', 'D': 'rgb(130,0,255)', #'purple', 'O': 'rgb(130,100,150)', #'dunno', 'Q': 'rgb(150,130,100)', #'dunno', 'U': 'rgb(150,100,150)', #'dunno', 'CS': 'rgb(0,0,255)', #'blue', 'CE': 'rgb(255,150,255)', #'pink', 'CI': 'rgb(255,150,50)', #'orange', 'CA': 'rgb(255,50,50)', #'dunno', 'CR': 'rgb(0,255,0)', #'green', 'CH': 'rgb(255,0,0)', #'red', 'CC': 'rgb(50,50,50)', #'black', 'CD': 'rgb(130,0,255)', #'purple', 'CO': 'rgb(130,100,150)', #'dunno', 'CQ': 'rgb(150,130,100)', #'dunno', 'CU': 'rgb(150,100,150)', #'dunno', 'Ninf': 'rgb(255,125,100)', # } self.categories = {} for key in self.longname.keys(): self.categories[key] = dict(longname=self.longname[key], shortname=self.shortname[key], colour=self.colour[key], fill_colour='rgba' + self.colour[key][3:-1] + ',0.1)', index=self.index[key]) self.population_frame, self.population = self.prepare_population_frame( camp_params) self.control_dict, self.icu_count = self.load_control_dict( profile, profile_override_dict) self.infection_matrix, self.im_beta_list, self.largest_eigenvalue = self.generate_infection_matrix( ) self.generated_disease_vectors = self.ps.get_generated_disease_param_vectors( )