Skip to content

Commit

Permalink
Moved Person to their own files, and updated usages.
Browse files Browse the repository at this point in the history
  • Loading branch information
CloneDeath committed May 26, 2020
1 parent d54febe commit 8a56310
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 59 deletions.
2 changes: 2 additions & 0 deletions covid-sim.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<ClCompile Include="src\Models\Cell.cpp" />
<ClCompile Include="src\Models\Microcell.cpp" />
<ClCompile Include="src\Models\Airport.cpp" />
<ClCompile Include="src\Models\Person.cpp" />
<ClCompile Include="src\Coordinates\MicroCellPosition.cpp" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -134,6 +135,7 @@
<ClInclude Include="src\Models\Microcell.h" />
<ClInclude Include="src\Models\Airport.h" />
<ClInclude Include="src\Models\Place.h" />
<ClInclude Include="src\Models\Person.h" />
<ClInclude Include="src\Coordinates\MicroCellPosition.h" />
<ClInclude Include="src\Coordinates\Vector2.h" />
<ClInclude Include="src\Coordinates\Size.h" />
Expand Down
16 changes: 0 additions & 16 deletions src/Dist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@ double dist2UTM(double x1, double y1, double x2, double y2)
return 4 * EARTHRADIUS * EARTHRADIUS * pos.y;
}

double dist2(Person* a, Person* b)
{
if (P.DoUTM_coords)
return Households[a->hh].distance_squared_to(Households[b->hh]);
else
{
Vector2<float> delta = (Households[a->hh].loc - Households[b->hh].loc).abs();
if (P.DoPeriodicBoundaries)
{
if (delta.x > P.in_degrees_.width * 0.5) delta.x = P.in_degrees_.width - delta.x;
if (delta.y > P.in_degrees_.height * 0.5) delta.y = P.in_degrees_.height - delta.y;
}
return delta.length_squared();
}
}

double dist2_raw(double ax, double ay, double bx, double by)
{
if (P.DoUTM_coords)
Expand Down
2 changes: 0 additions & 2 deletions src/Dist.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

extern double sinx[361], cosx[361], asin2sqx[1001];
double dist2UTM(double, double, double, double);
double dist2(Person*, Person*);
double dist2_mm(Microcell*, Microcell*);
double dist2_raw(double, double, double, double);

#endif // COVIDSIM_DIST_H_INCLUDED_
42 changes: 1 addition & 41 deletions src/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,13 @@
#include "Models/Cell.h"
#include "Models/Microcell.h"
#include "Models/Airport.h"
#include "Models/Person.h"

//// need to test that inequalities in IncubRecoverySweep can be replaced if you initialize to USHRT_MAX, rather than zero.
//// need to output quantities by admin unit

#pragma pack(push, 2)

struct Person
{
int pcell; // place cell, Cells[person->pcell] holds this person
int mcell; // microcell, Mcells[person->mcell] holds this person
int hh; // Household[person->hh] holds this person
int infector; // If >=0, Hosts[person->infector] was who infected this person
int listpos; // Goes up to at least MAX_SEC_REC, also used as a temp variable?

int PlaceLinks[NUM_PLACE_TYPES]; //// indexed by i) place type. Value is the number of that place type (e.g. school no. 17; office no. 310 etc.) Place[i][person->PlaceLinks[i]], can be up to P.Nplace[i]
float infectiousness, susc,ProbAbsent,ProbCare;

unsigned int esocdist_comply : 1;
unsigned int keyworker : 1; // also used to binary index cumI_keyworker[] and related arrays
unsigned int to_die : 1;
unsigned int detected : 1; //added hospitalisation flag: ggilani 28/10/2014, added flag to determined whether this person's infection is detected or not

unsigned char Travelling; // Range up to MAX_TRAVEL_TIME
unsigned char age;
unsigned char quar_comply; // can be 0, 1, or 2
unsigned char num_treats; // set to 0 and tested < 2. but never modified?
Severity Severity_Current, Severity_Final; //// Note we allow Severity_Final to take values: Severity_Mild, Severity_ILI, Severity_SARI, Severity_Critical (not e.g. Severity_Dead or Severity_RecoveringFromCritical)

unsigned short int PlaceGroupLinks[NUM_PLACE_TYPES]; // These can definitely get > 255
short int infect_type; // INFECT_TYPE_MASK
InfStat inf;

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
unsigned short int absent_start_time, absent_stop_time;
unsigned short int quar_start_time, isolation_start_time;
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.
unsigned short int recovery_or_death_time; // set in DoIncub function
unsigned short int SARI_time, Critical_time, RecoveringFromCritical_time; //// /*mild_time, ILI_time,*/ Time of infectiousness onset same for asymptomatic, Mild, and ILI infection so don't need mild_time etc.
unsigned short int treat_start_time, treat_stop_time, vacc_start_time; //// set in TreatSweep function.
unsigned int digitalContactTraced : 1;
unsigned int index_case_dct : 2;
unsigned int digitalContactTracingUser : 1;
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
int ncontacts; //added this in to record total number of contacts each index case records: ggilani 13/04/20

};

/*
In the main InfectSweep loop, we cannot safely set
Hosts[infectee].infector and Hosts[infectee].infect_type, as concurrent
Expand Down
2 changes: 2 additions & 0 deletions src/Models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ target_sources(CovidSim
Microcell.cpp
Microcell.h
Place.h
Person.cpp
Person.h
)
11 changes: 11 additions & 0 deletions src/Models/Person.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "Person.h"

#include "../Model.h"

double Person::distance_to(const Person *other) const {
return std::sqrt(this->distance_squared_to(other));
}

double Person::distance_squared_to(const Person *other) const {
return Households[this->hh].distance_squared_to(Households[other->hh]);
}
47 changes: 47 additions & 0 deletions src/Models/Person.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include "../Country.h"
#include "../InfStat.h"

struct Person
{
int pcell; // place cell, Cells[person->pcell] holds this person
int mcell; // microcell, Mcells[person->mcell] holds this person
int hh; // Household[person->hh] holds this person
int infector; // If >=0, Hosts[person->infector] was who infected this person
int listpos; // Goes up to at least MAX_SEC_REC, also used as a temp variable?

int PlaceLinks[NUM_PLACE_TYPES]; //// indexed by i) place type. Value is the number of that place type (e.g. school no. 17; office no. 310 etc.) Place[i][person->PlaceLinks[i]], can be up to P.Nplace[i]
float infectiousness, susc,ProbAbsent,ProbCare;

unsigned int esocdist_comply : 1;
unsigned int keyworker : 1; // also used to binary index cumI_keyworker[] and related arrays
unsigned int to_die : 1;
unsigned int detected : 1; //added hospitalisation flag: ggilani 28/10/2014, added flag to determined whether this person's infection is detected or not

unsigned char Travelling; // Range up to MAX_TRAVEL_TIME
unsigned char age;
unsigned char quar_comply; // can be 0, 1, or 2
unsigned char num_treats; // set to 0 and tested < 2. but never modified?
Severity Severity_Current, Severity_Final; //// Note we allow Severity_Final to take values: Severity_Mild, Severity_ILI, Severity_SARI, Severity_Critical (not e.g. Severity_Dead or Severity_RecoveringFromCritical)

unsigned short int PlaceGroupLinks[NUM_PLACE_TYPES]; // These can definitely get > 255
short int infect_type; // INFECT_TYPE_MASK
InfStat inf;

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
unsigned short int absent_start_time, absent_stop_time;
unsigned short int quar_start_time, isolation_start_time;
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.
unsigned short int recovery_or_death_time; // set in DoIncub function
unsigned short int SARI_time, Critical_time, RecoveringFromCritical_time; //// /*mild_time, ILI_time,*/ Time of infectiousness onset same for asymptomatic, Mild, and ILI infection so don't need mild_time etc.
unsigned short int treat_start_time, treat_stop_time, vacc_start_time; //// set in TreatSweep function.
unsigned int digitalContactTraced : 1;
unsigned int index_case_dct : 2;
unsigned int digitalContactTracingUser : 1;
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
int ncontacts; //added this in to record total number of contacts each index case records: ggilani 13/04/20

double distance_to(const Person* other) const;
double distance_squared_to(const Person* other) const;
};

0 comments on commit 8a56310

Please sign in to comment.