FRED
|
00001 /* 00002 Copyright 2009 by the University of Pittsburgh 00003 Licensed under the Academic Free License version 3.0 00004 See the file "LICENSE" for more information 00005 */ 00006 00007 // 00008 // 00009 // File: Place.h 00010 // 00011 00012 #ifndef _FRED_PLACE_H 00013 #define _FRED_PLACE_H 00014 00015 #define HOUSEHOLD 'H' 00016 #define NEIGHBORHOOD 'N' 00017 #define SCHOOL 'S' 00018 #define CLASSROOM 'C' 00019 #define WORKPLACE 'W' 00020 #define OFFICE 'O' 00021 #define HOSPITAL 'M' 00022 #define COMMUNITY 'X' 00023 00024 #include <vector> 00025 using namespace std; 00026 00027 #include "Population.h" 00028 #include "Global.h" 00029 class Cell; 00030 class Person; 00031 00032 00033 class Place { 00034 public: 00035 Place() {} 00036 ~Place() {} 00037 00049 void setup(int loc_id, const char *lab, double lon, double lat, Place *cont, Population *pop); 00050 00054 virtual void prepare(); 00055 00060 void update(int day); 00061 00067 virtual void print(int disease_id); 00068 00075 virtual void enroll(Person * per); 00076 00083 virtual void unenroll(Person * per); 00084 00092 virtual void add_susceptible(int disease_id, Person * per); 00093 00101 virtual void add_infectious(int disease_id, Person * per); 00102 00108 void print_susceptibles(int disease_id); 00109 00115 void print_infectious(int disease_id); 00116 00123 virtual void spread_infection(int day, int disease_id); 00124 00131 bool is_open(int day); 00132 00138 bool is_infectious(int disease_id) { return I[disease_id] > 0; } 00139 00147 void modifyIncidenceCount(int disease_id, vector<int> strain, int incr); 00148 00156 void modifyPrevalenceCount(int disease_id, vector<int> strain, int incr); 00157 00161 void print_stats(int day, int disease_id); 00162 00168 virtual void get_parameters(int disease_id) = 0; 00169 00177 virtual int get_group(int disease_id, Person * per) = 0; 00178 00187 virtual double get_transmission_prob(int disease_id, Person * i, Person * s) = 0; 00188 00195 virtual double get_contacts_per_day(int disease_id) = 0; // access functions 00196 00204 virtual bool should_be_open(int day, int disease_id) = 0; 00205 00210 int get_id() { return id; } 00211 00217 char * get_label() { return label; } 00218 00224 char get_type() { return type; } 00225 00226 bool is_workplace() { return type == 'W'; } 00227 00233 double get_latitude() { return latitude; } 00234 00240 double get_longitude() { return longitude; } 00241 00248 int get_S(int disease_id) { return S[disease_id]; } 00249 00256 int get_I(int disease_id) { return (int) (infectious[disease_id].size()); } 00257 00264 int get_symptomatic(int disease_id) { return Sympt[disease_id]; } 00265 00271 int get_size() { return N; } 00272 00278 int get_close_date() { return close_date; } 00279 00285 int get_open_date() { return open_date; } 00286 00292 Population *get_population() { return population; } 00293 00301 int get_daily_cases(int disease_id) { return cases[disease_id]; } 00302 00310 int get_daily_deaths(int disease_id) { return deaths[disease_id]; } 00311 00319 int get_total_cases(int disease_id) { return total_cases[disease_id]; } 00320 00328 int get_total_deaths(int disease_id) { return total_deaths[disease_id]; } 00329 00337 double get_incidence_rate(int disease_id) { return (double) total_cases[disease_id] / (double) N; } 00338 00344 void set_id(int n) { id = n; } 00345 00351 void set_type(char t) { type = t; } 00352 00358 void set_latitude(double x) { latitude = x; } 00359 00365 void set_longitude(double x) { longitude = x; } 00366 00372 void set_close_date(int day) { close_date = day; } 00373 00379 void set_open_date(int day) { open_date = day; } 00380 00386 void set_population(Population *p) { population = p; } 00387 00393 void set_container(Place *cont) { container = cont; } 00394 00395 Place * get_container() { return container; } 00396 00400 void add_case() { cases++; } 00401 00405 void add_deaths() { deaths++; } 00406 00412 Cell * get_grid_cell() { return grid_cell; } 00413 00419 void set_grid_cell(Cell *p) { grid_cell = p; } 00420 00421 Place * select_neighborhood(double community_prob, double community_distance, double local_prob); 00422 00423 int get_days_infectious() { return days_infectious; } 00424 00425 double get_attack_rate() { return(N?(double)total_infections/(double)N:0.0); } 00426 00427 protected: 00428 int id; // place id 00429 char label[32]; // external id 00430 char type; // HOME, WORK, SCHOOL, COMMUNITY 00431 Place *container; // id of container place 00432 double latitude; // geo location 00433 double longitude; // geo location 00434 int N; // total number of potential visitors 00435 vector <Person *> *susceptibles; // list of susceptible visitors 00436 vector <Person *> *infectious; // list of infectious visitors 00437 int *S; // susceptible count 00438 int *I; // infectious count 00439 int *Sympt; // symptomatics count 00440 int close_date; // this place will be closed during: 00441 int open_date; // [close_date, open_date) 00442 int * cases; // symptomatic cases today 00443 int * deaths; // deaths today 00444 int * total_cases; // total symptomatic cases 00445 int * total_deaths; // total deaths 00446 Population *population; 00447 Cell * grid_cell; // geo grid_cell for this place 00448 vector< map<int, int> > incidence; 00449 vector< map<int, int> > prevalence; 00450 int days_infectious; 00451 int total_infections; 00452 00453 double get_contact_rate(int day, int disease_id); 00454 int get_contact_count(Person * infector, int disease_id, int day, double contact_rate); 00455 void attempt_transmission(double transmission_prob, Person * infector, Person * infectee, int disease_id, int day); 00456 00457 // disease parameters 00458 double *beta; // place-independent transmissibility per contact 00459 }; 00460 00461 #endif // _FRED_PLACE_H