covid-sim
Loading...
Searching...
No Matches
Model.h
1#ifndef COVIDSIM_MODEL_H_INCLUDED_
2#define COVIDSIM_MODEL_H_INCLUDED_
3
4#include "Country.h"
5#include "MachineDefines.h"
6#include "Constants.h"
7#include "InfStat.h"
8
9
12
13#pragma pack(push, 2)
14
15struct Person
16{
17 int pcell; // place cell, Cells[person->pcell] holds this person
18 int mcell; // microcell, Mcells[person->mcell] holds this person
19 int hh; // Household[person->hh] holds this person
20 int infector; // If >=0, Hosts[person->infector] was who infected this person
21 int listpos; // Goes up to at least MAX_SEC_REC, also used as a temp variable?
22
23 int PlaceLinks[NUM_PLACE_TYPES];
24 float infectiousness, susc,ProbAbsent,ProbCare;
25
26 unsigned int esocdist_comply : 1;
27 unsigned int keyworker : 1; // also used to binary index cumI_keyworker[] and related arrays
28 unsigned int to_die : 1;
29 unsigned int detected : 1; //added hospitalisation flag: ggilani 28/10/2014, added flag to determined whether this person's infection is detected or not
30
31 unsigned char Travelling; // Range up to MAX_TRAVEL_TIME
32 unsigned char age;
33 unsigned char quar_comply; // can be 0, 1, or 2
34 unsigned char num_treats; // set to 0 and tested < 2. but never modified?
35 Severity Severity_Current, Severity_Final;
36
37 unsigned short int PlaceGroupLinks[NUM_PLACE_TYPES]; // These can definitely get > 255
38 short int infect_type; // INFECT_TYPE_MASK
39 InfStat inf;
40
41 unsigned short int detected_time; //added hospitalisation flag: ggilani 28/10/2014, added flag to determined whether this person's infection is detected or not
42 unsigned short int absent_start_time, absent_stop_time;
43 unsigned short int quar_start_time, isolation_start_time;
44 unsigned short int infection_time, latent_time; // Set in DoInfect function. infection time is time of infection; latent_time is a misnomer - it is the time at which person become infectious (i.e. infection time + latent period for this person). latent_time will also refer to time of onset with ILI or Mild symptomatic disease.
45 unsigned short int recovery_or_death_time; // set in DoIncub function
46 unsigned short int SARI_time, Critical_time, RecoveringFromCritical_time;
47 unsigned short int treat_start_time, treat_stop_time, vacc_start_time;
48 unsigned int digitalContactTraced : 1;
49 unsigned int index_case_dct : 2;
50 unsigned int digitalContactTracingUser : 1;
51 unsigned short int dct_start_time, dct_end_time, dct_trigger_time, dct_test_time; //digital contact tracing start and end time: ggilani 10/03/20
52 int ncontacts; //added this in to record total number of contacts each index case records: ggilani 13/04/20
53
54};
55
57{
58 int FirstPerson;
59 unsigned short int nh; // number people in household
60 float loc_x, loc_y;
61 unsigned short int nhr;
62};
63
64/*
65In the main InfectSweep loop, we cannot safely set
66Hosts[infectee].infector and Hosts[infectee].infect_type, as concurrent
67threads might be trying to set the values differently. We therefore
68make a queue of `infection`s in `inf_queue` containing the information
69we need, so that we can set the values after the main loop has finished.
70*/
72{
73 int infector;
74 int infectee;
75 short int infect_type;
76};
77
85{
86 int contact;
87 int index;
88 unsigned short int contact_time;
89};
90
96struct PopVar
97{
98 int S, L, I, R, D, cumI, cumR, cumD, cumC, cumTC, cumFC, cumDC, trigDC;
99 int cumH; //Added cumulative hospitalisation: ggilani 28/10/14
100 int cumCT, cumCC, DCT, cumDCT; //Added total and cumulative contact tracing: ggilani 15/06/17, and equivalents for digital contact tracing: ggilani 11/03/20
101 int cumC_country[MAX_COUNTRIES]; //added cumulative cases by country: ggilani 12/11/14
102 int cumHQ, cumAC, cumAA, cumAH, cumACS, cumAPC, cumAPA, cumAPCS;
104 int cumIa[NUM_AGE_GROUPS], cumCa[NUM_AGE_GROUPS], cumDa[NUM_AGE_GROUPS];
105 int cumI_adunit[MAX_ADUNITS], cumC_adunit[MAX_ADUNITS], cumD_adunit[MAX_ADUNITS], cumT_adunit[MAX_ADUNITS], cumH_adunit[MAX_ADUNITS], cumDC_adunit[MAX_ADUNITS]; //added cumulative hospitalisation per admin unit: ggilani 28/10/14, cumulative detected cases per adunit: ggilani 03/02/15
106 int cumCT_adunit[MAX_ADUNITS], cumCC_adunit[MAX_ADUNITS], trigDC_adunit[MAX_ADUNITS]; //added cumulative CT per admin unit: ggilani 15/06/17
107 int cumDCT_adunit[MAX_ADUNITS], DCT_adunit[MAX_ADUNITS]; //added cumulative and overall digital contact tracing per adunit: ggilani 11/03/20
108 int cumItype[INFECT_TYPE_MASK], cumI_keyworker[2], cumC_keyworker[2], cumT_keyworker[2];
109 Infection *inf_queue[MAX_NUM_THREADS]; // the queue (i.e. list) of infections. 1st index is thread, 2nd is person.
110 int n_queue[MAX_NUM_THREADS]; // number of infections in inf_queue
111 int* p_queue[NUM_PLACE_TYPES], *pg_queue[NUM_PLACE_TYPES], np_queue[NUM_PLACE_TYPES]; // np_queue is number of places in place queue (by place type), p_queue, and pg_queue is the actual place and place-group queue (i.e. list) of places. 1st index is place type, 2nd is place.
112 int NumPlacesClosed[NUM_PLACE_TYPES], n_mvacc, mvacc_cum;
113 float* cell_inf;
114 double sumRad2, maxRad2, cumT, cumV, cumVG, cumUT, cumTP, cumV_daily, cumVG_daily; //added cumVG, cumVG_daily
115 int* CellMemberArray, *CellSuscMemberArray;
116 int** InvAgeDist;
117 int* mvacc_queue;
118 int nct_queue[MAX_ADUNITS]; // queue for contact tracing: ggilani 12/06/17
119 ContactEvent* dct_queue[MAX_ADUNITS]; //queues for digital contact tracing: ggilani 14/04/20
120 int ndct_queue[MAX_ADUNITS]; //queues for digital contact tracing: ggilani 10/03/20
121 int contact_dist[MAX_CONTACTS+1]; //added this to store contact distribution: ggilani 13/04/20
122 double* origin_dest[MAX_ADUNITS]; //added intermediate storage for calculation of origin-destination matrix: ggilani 02/02/15
123
125 int Mild, ILI, SARI, Critical, CritRecov, /*cumulative incidence*/ cumMild, cumILI, cumSARI, cumCritical, cumCritRecov;
126 int Mild_adunit[MAX_ADUNITS], ILI_adunit[MAX_ADUNITS], SARI_adunit[MAX_ADUNITS], Critical_adunit[MAX_ADUNITS], CritRecov_adunit[MAX_ADUNITS];
128 int cumMild_adunit[MAX_ADUNITS], cumILI_adunit[MAX_ADUNITS], cumSARI_adunit[MAX_ADUNITS], cumCritical_adunit[MAX_ADUNITS], cumCritRecov_adunit[MAX_ADUNITS];
129 int Mild_age[NUM_AGE_GROUPS], ILI_age[NUM_AGE_GROUPS], SARI_age[NUM_AGE_GROUPS], Critical_age[NUM_AGE_GROUPS], CritRecov_age[NUM_AGE_GROUPS];
131 int cumMild_age[NUM_AGE_GROUPS], cumILI_age[NUM_AGE_GROUPS], cumSARI_age[NUM_AGE_GROUPS], cumCritical_age[NUM_AGE_GROUPS], cumCritRecov_age[NUM_AGE_GROUPS];
132
133 int cumDeath_ILI, cumDeath_SARI, cumDeath_Critical; // tracks cumulative deaths from ILI, SARI & Critical severities
134 int cumDeath_ILI_adunit[MAX_ADUNITS], cumDeath_SARI_adunit[MAX_ADUNITS], cumDeath_Critical_adunit[MAX_ADUNITS]; // tracks cumulative deaths from ILI, SARI & Critical severities
135 int cumDeath_ILI_age[NUM_AGE_GROUPS], cumDeath_SARI_age[NUM_AGE_GROUPS], cumDeath_Critical_age[NUM_AGE_GROUPS];
136
144
145};
146
157{
158 double t, S, L, I, R, D, incC, incTC, incFC, incI, incR, incD, incDC ;
159 double incH; //added incidence of hospitalisation: ggilani 28/10/14
160 double CT, incCT, incCC, DCT, incDCT; //added total numbers being contact traced and incidence of contact tracing: ggilani 15/06/17, and for digital contact tracing: ggilani 11/03/20
161 double incC_country[MAX_COUNTRIES]; //added incidence of cases
162 double cumT, cumUT, cumTP, cumV, cumTmax, cumVmax, cumDC, extinct, cumVG; //added cumVG
163 double incHQ, incAC, incAH, incAA, incACS, incAPC, incAPA, incAPCS;
164 double incIa[NUM_AGE_GROUPS], incCa[NUM_AGE_GROUPS], incDa[NUM_AGE_GROUPS];
165 double incItype[INFECT_TYPE_MASK], Rtype[INFECT_TYPE_MASK], Rage[NUM_AGE_GROUPS], Rdenom;
166 double rmsRad, maxRad, PropPlacesClosed[NUM_PLACE_TYPES], PropSocDist;
167 double incI_adunit[MAX_ADUNITS], incC_adunit[MAX_ADUNITS], cumT_adunit[MAX_ADUNITS], incD_adunit[MAX_ADUNITS], cumD_adunit[MAX_ADUNITS], incH_adunit[MAX_ADUNITS], incDC_adunit[MAX_ADUNITS]; //added incidence of hospitalisation per day: ggilani 28/10/14, incidence of detected cases per adunit,: ggilani 03/02/15
168 double incCT_adunit[MAX_ADUNITS], incCC_adunit[MAX_ADUNITS], incDCT_adunit[MAX_ADUNITS], DCT_adunit[MAX_ADUNITS]; //added incidence of contact tracing and number of people being contact traced per admin unit: ggilani 15/06/17
169 double incI_keyworker[2], incC_keyworker[2], cumT_keyworker[2];
170
172
173 double Mild, ILI, SARI, Critical, CritRecov; // Prevalence //// Must be: i) initialised to zero in SetUpModel. ii) outputted in SaveResults iii) outputted in SaveSummaryResults
174 double incMild, incILI, incSARI, incCritical, incCritRecov; // Incidence //// Must be: i) initialised to zero in SetUpModel. ii) calculated in RecordSample iii) outputted in SaveResults.
175 double cumMild, cumILI, cumSARI, cumCritical, cumCritRecov; // cumulative incidence //// Must be: i) initialised to zero in SetUpModel. ii) outputted in SaveResults
176 double incDeath_ILI, incDeath_SARI, incDeath_Critical; // tracks incidence of death from ILI, SARI & Critical severities
177 double cumDeath_ILI, cumDeath_SARI, cumDeath_Critical; // tracks cumulative deaths from ILI, SARI & Critical severities
179
181 double Mild_adunit[MAX_ADUNITS], ILI_adunit[MAX_ADUNITS], SARI_adunit[MAX_ADUNITS], Critical_adunit[MAX_ADUNITS], CritRecov_adunit[MAX_ADUNITS]; // Prevalence by admin unit
182 double incMild_adunit[MAX_ADUNITS], incILI_adunit[MAX_ADUNITS], incSARI_adunit[MAX_ADUNITS], incCritical_adunit[MAX_ADUNITS], incCritRecov_adunit[MAX_ADUNITS]; // incidence by admin unit
183 double cumMild_adunit[MAX_ADUNITS], cumILI_adunit[MAX_ADUNITS], cumSARI_adunit[MAX_ADUNITS], cumCritical_adunit[MAX_ADUNITS], cumCritRecov_adunit[MAX_ADUNITS]; // cumulative incidence by admin unit
184 double incDeath_ILI_adunit[MAX_ADUNITS], incDeath_SARI_adunit[MAX_ADUNITS], incDeath_Critical_adunit[MAX_ADUNITS]; // tracks incidence of death from ILI, SARI & Critical severities
185 double cumDeath_ILI_adunit[MAX_ADUNITS], cumDeath_SARI_adunit[MAX_ADUNITS], cumDeath_Critical_adunit[MAX_ADUNITS]; // tracks cumulative deaths from ILI, SARI & Critical severities
186
188 double Mild_age[NUM_AGE_GROUPS], ILI_age[NUM_AGE_GROUPS], SARI_age[NUM_AGE_GROUPS], Critical_age[NUM_AGE_GROUPS], CritRecov_age[NUM_AGE_GROUPS]; // Prevalence by admin unit
189 double incMild_age[NUM_AGE_GROUPS], incILI_age[NUM_AGE_GROUPS], incSARI_age[NUM_AGE_GROUPS], incCritical_age[NUM_AGE_GROUPS], incCritRecov_age[NUM_AGE_GROUPS]; // incidence by admin unit
190 double cumMild_age[NUM_AGE_GROUPS], cumILI_age[NUM_AGE_GROUPS], cumSARI_age[NUM_AGE_GROUPS], cumCritical_age[NUM_AGE_GROUPS], cumCritRecov_age[NUM_AGE_GROUPS]; // cumulative incidence by admin unit
191 double incDeath_ILI_age[NUM_AGE_GROUPS], incDeath_SARI_age[NUM_AGE_GROUPS], incDeath_Critical_age[NUM_AGE_GROUPS]; // tracks incidence of death from ILI, SARI & Critical severities
192 double cumDeath_ILI_age[NUM_AGE_GROUPS], cumDeath_SARI_age[NUM_AGE_GROUPS], cumDeath_Critical_age[NUM_AGE_GROUPS]; // tracks cumulative deaths from ILI, SARI & Critical severities
193
196
202
203};
204
211struct Events
212{
213 double infectee_x, infectee_y, t, t_infector;
214 int run, infectee_ind, infector_ind, type, infectee_adunit, listpos, infectee_cell, infector_cell, thread;
215};
216
217/*
218 HQ - quarantined households
219 AH - Quarantined (and perhaps sick) working adults
220 AC - Non-quarantined working adult cases absent thru sickness.
221 AA - Absent working adults who are caring for sick children (only assigned if no non-working, quarantine or sick adults available).
222 ACS - Children below care requirement cut-off age who are absent (sick or quarantined)
223
224 APC - Non-quarantined working adult cases absent due to closure of their workplace (excl teachers).
225 APA - Absent working adults who are caring for children at home due to school closure (only assigned if no non-working, quarantine or sick adults available).
226 ACS - Children below care requirement cut-off age who are absent due to school closure
227
228
229 AH x rq + AC + AA +(APC+APA) x rc = total adult absence
230 rq=ratio of quarantine time to duration of absence due to illness
231 rc=ratio of school/workplace closure duration of absence due to illness
232*/
233
238{
239 int id;
240 float prob;
241};
242
250{
251 int num_mcell, num_place, Inv_prop_traffic[129], Inv_DestMcells[1025], Inv_DestPlaces[1025];
252 unsigned short int num_connected, *conn_airports;
253 float total_traffic, loc_x, loc_y;
254 float* prop_traffic;
255 IndexList* DestMcells, *DestPlaces;
256};
257
266{
267 /* Note use of short int here limits max run time to USHRT_MAX*TimeStep - e.g. 65536*0.25=16384 days=44 yrs.
268 Global search and replace of 'unsigned short int' with 'int' would remove this limit, but use more memory.
269 */
270 int n /*Number of people in microcell*/, adunit;
271 int* members;
272 unsigned short int country;
273
274 int* places[NUM_PLACE_TYPES];
275 unsigned short int np[NUM_PLACE_TYPES];
276 unsigned short int moverest, placeclose, socdist, keyworkerproph, move_trig, place_trig, socdist_trig, keyworkerproph_trig;
277 unsigned short int move_start_time, move_end_time;
278 unsigned short int place_end_time, socdist_end_time, keyworkerproph_end_time;
279 unsigned short int treat, vacc, treat_trig, vacc_trig;
280 unsigned short int treat_start_time, treat_end_time;
281 unsigned short int vacc_start_time;
282 IndexList* AirportList;
283};
284
292struct Cell
293{
294 int n, S, L, I, R, D, cumTC, S0, tot_treat, tot_vacc;
295 int* members, *susceptible, *latent, *infected;
296 int* InvCDF;
297 float tot_prob, *cum_trans, *max_trans;
298 short int CurInterv[MAX_INTERVENTION_TYPES];
299};
300
311struct Place
312{
313 int n, mcell;
314 unsigned short int ng, treat, control_trig, country;
315 unsigned short int close_start_time, close_end_time, treat_end_time;
316 unsigned short int* AvailByAge;
317 unsigned short int Absent[MAX_ABSENT_TIME], AbsentLastUpdateTime;
318 float loc_x, loc_y;
319 float ProbClose;
320 int* group_start, *group_size, *members;
321};
322
329{
330 int InterventionType, DoAUThresh, NoStartAfterMin,dummy; //dummy for 8 byte alignment
331 double StartTime, StopTime, MinDuration, RepeatInterval, TimeOffset;
332 double StartThresholdHigh, StartThresholdLow, StopThreshold, Level, LevelCellVar, LevelAUVar, LevelCountryVar, ControlParam, LevelClustering;
333 unsigned int MaxRounds, MaxResource;
334};
335
340{
341 int id, cnt_id, NI, n; //added n - number of people in admin unit: ggilani 05/01/15
342 Intervention InterventionList[MAX_INTERVENTIONS_PER_ADUNIT];
343 char cnt_name[96], ad_name[200];
344 int NP, place_close_trig;
345 double CaseIsolationTimeStart, HQuarantineTimeStart, DigitalContactTracingTimeStart;
346 double SocialDistanceTimeStart, PlaceCloseTimeStart; //added these to admin unit in the hope of getting specific start times for Italy: ggilani 16/03/20
347 //adding in admin level delays and durations for admin units: ggilani 17/03/20
348 double SocialDistanceDelay, HQuarantineDelay, CaseIsolationDelay, PlaceCloseDelay, DCTDelay;
349 double SocialDistanceDuration, HQuarantineDuration, CaseIsolationPolicyDuration, PlaceCloseDuration, DCTDuration;
350 int* dct, ndct; //arrays for admin unit based digital contact tracing: ggilani 10/03/20
351 double* origin_dest; //storage for origin-destination matrix between admin units: ggilani 28/01/15
352};
353
354#pragma pack(pop)
355
356extern Person* Hosts;
357extern Household* Households;
358extern PopVar State, StateT[MAX_NUM_THREADS];
359extern Cell* Cells, ** CellLookup;
360extern Microcell* Mcells, ** McellLookup;
361extern Place** Places;
362extern AdminUnit AdUnits[MAX_ADUNITS];
363
367extern Results* TimeSeries, *TSMean, *TSVar, *TSMeanNE, *TSVarNE, *TSMeanE, *TSVarE;
368
369extern Airport* Airports;
370extern Events* InfEventLog;
371extern int nEvents;
372
373
374extern double inftype[INFECT_TYPE_MASK], inftype_av[INFECT_TYPE_MASK], infcountry[MAX_COUNTRIES], infcountry_av[MAX_COUNTRIES], infcountry_num[MAX_COUNTRIES];
375extern double indivR0[MAX_SEC_REC][MAX_GEN_REC], indivR0_av[MAX_SEC_REC][MAX_GEN_REC];
376extern double inf_household[MAX_HOUSEHOLD_SIZE + 1][MAX_HOUSEHOLD_SIZE + 1], denom_household[MAX_HOUSEHOLD_SIZE + 1];
377extern double inf_household_av[MAX_HOUSEHOLD_SIZE + 1][MAX_HOUSEHOLD_SIZE + 1], AgeDist[NUM_AGE_GROUPS], AgeDist2[NUM_AGE_GROUPS];
378extern double case_household[MAX_HOUSEHOLD_SIZE + 1][MAX_HOUSEHOLD_SIZE + 1], case_household_av[MAX_HOUSEHOLD_SIZE + 1][MAX_HOUSEHOLD_SIZE + 1];
379extern double PropPlaces[NUM_AGE_GROUPS * AGE_GROUP_WIDTH][NUM_PLACE_TYPES];
380extern double PropPlacesC[NUM_AGE_GROUPS * AGE_GROUP_WIDTH][NUM_PLACE_TYPES], AirTravelDist[MAX_DIST];
381extern double PeakHeightSum, PeakHeightSS, PeakTimeSum, PeakTimeSS;
382
383extern int DoInitUpdateProbs;
384
385#endif // COVIDSIM_MODEL_H_INCLUDED_
A political entity that administers a geographical area.
Definition Model.h:340
Airport state.
Definition Model.h:250
Holds microcells.
Definition Model.h:293
Contact event used for tracking contact tracing events.
Definition Model.h:85
Used for computing spatial interactions more efficiently.
Definition Model.h:238
Deprecated intervention mechanism.
Definition Model.h:329
The basic unit of the simulation and is associated to a geographical location.
Definition Model.h:266
Definition Model.h:16
Represents an institution that people may belong to.
Definition Model.h:312
The global state of the model.
Definition Model.h:97
int cumMild_adunit[MAX_ADUNITS]
cum incidence quantities. (+ by admin unit)
Definition Model.h:128
int cumMild_age[NUM_AGE_GROUPS]
cum incidence quantities. (+ by age group)
Definition Model.h:131
Recorded time-series variables (typically populated from the POPVAR state)
Definition Model.h:157
double Mild
Definition Model.h:173