Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
phelps-sg committed May 13, 2020
2 parents ebae1c0 + 78164e8 commit 1f296a7
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 614 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# VS
*~
*.xls
x64
Expand All @@ -9,9 +9,17 @@ x64
*.bin
wpop_*.txt
out/
build
build/
build-*/
build_*/
.project
*.vcxproj.user
tests/*-output/

# VScode
.vscode/

# Executables
*.exe
*.out
*.app
5 changes: 5 additions & 0 deletions data/admin_units/Russia_admin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
[Fix population size at specified value]
1

[Longitude cut line]
0.0
# Russia goes from around 19 degrees to -170 dgrees longitude, so need
# different cut line to default of -180.0

[Number of countries to include]
1

Expand Down
Binary file added data/populations/wpop_nga_adm1.txt.gz
Binary file not shown.
5 changes: 5 additions & 0 deletions data/run_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def parse_args():
united_states = [ "United_States" ]
canada = [ "Canada" ]
usa_territories = ["Alaska", "Hawaii", "Guam", "Virgin_Islands_US", "Puerto_Rico", "American_Samoa"]
nigeria = ["Nigeria"]

# Determine whether we need to build the tool or use a user supplied one:
if args.covidsim is not None:
Expand Down Expand Up @@ -127,6 +128,8 @@ def parse_args():
wpop_file_root = "usacan"
elif args.country in usa_territories:
wpop_file_root = "us_terr"
elif args.country in nigeria:
wpop_file_root = "nga_adm1"
else:
wpop_file_root = "eur"

Expand Down Expand Up @@ -157,6 +160,8 @@ def parse_args():
# Configure pre-parameter file. This file doesn't change between runs:
if args.country in united_states:
pp_file = os.path.join(args.paramdir, "preUS_R0=2.0.txt")
elif args.country in nigeria:
pp_file = os.path.join(args.paramdir, "preNGA_R0=2.0.txt")
else:
pp_file = os.path.join(args.paramdir, "preUK_R0=2.0.txt")
if not os.path.exists(pp_file):
Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# CMakeLists.txt for src directory

# Set up the IDE
set(MAIN_SRC_FILES CovidSim.cpp binio.cpp Rand.cpp Error.cpp Dist.cpp Kernels.cpp Bitmap.cpp SetupModel.cpp CalcInfSusc.cpp Sweep.cpp Update.cpp)
set(MAIN_HDR_FILES CovidSim.h binio.h Rand.h Constants.h Country.h MachineDefines.h Error.h Dist.h Kernels.h Bitmap.h Model.h Param.h SetupModel.h ModelMacros.h InfStat.h CalcInfSusc.h Sweep.h Update.h)
source_group(covidsim\\main FILES ${MAIN_SRC_FILES} ${MAIN_HDR_FILES})

# CovidSim target
add_executable(CovidSim CovidSim.cpp CovidSim.h binio.cpp binio.h Rand.cpp Rand.h Constants.h Country.h MachineDefines.h Error.cpp Error.h Dist.cpp Dist.h Kernels.cpp Kernels.h Bitmap.cpp Bitmap.h Model.h Param.h SetupModel.cpp SetupModel.h ModelMacros.h InfStat.h CalcInfSusc.cpp CalcInfSusc.h Sweep.cpp Sweep.h Update.cpp Update.h)
add_executable(CovidSim ${MAIN_SRC_FILES} ${MAIN_HDR_FILES})
target_include_directories(CovidSim PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(USE_OPENMP)
target_link_libraries(CovidSim PUBLIC OpenMP::OpenMP_CXX)
Expand Down
63 changes: 61 additions & 2 deletions src/Constants.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,67 @@
#ifndef COVIDSIM_CONSTANTS_H_INCLUDED_
#define COVIDSIM_CONSTANTS_H_INCLUDED_

#define PI 3.1415926535
#define EARTHRADIUS 6366707.0
/**
* Math constant defined as the ratio of a circle's circumference to its diameter.
*
* TODO: since all calculations using this constant are being automatically
* type-casted to double, should the precision be extended for more accuracy in
* the simulations?
*
* Eventually could be replaced with C++20's std::numbers::pi.
* https://en.cppreference.com/w/cpp/header/numbers
*/
constexpr double PI = 3.1415926535; // full double precision: 3.14159265358979323846

/**
* An arc minute of latitude along any line of longitude in meters.
*
* Also known as the International Nautical Mile.
*
* @see https://en.wikipedia.org/wiki/Nautical_mile
*/
constexpr int NMI = 1852;

/**
* The number of arc minutes in one degree.
*
* @see https://en.wikipedia.org/wiki/Minute_and_second_of_arc
*/
constexpr int ARCMINUTES_PER_DEGREE = 60;

/**
* The number of degrees in a complete rotation.
*
* @see https://en.wikipedia.org/wiki/Turn_(angle)
*/
constexpr int DEGREES_PER_TURN = 360;

/**
* The earth's circumference in meters.
*
* The units of cancellation:
* meters/minute * minutes/degree * degrees = meters
*/
constexpr int EARTH_CIRCUMFERENCE = NMI * ARCMINUTES_PER_DEGREE * DEGREES_PER_TURN;

/**
* The earth's diameter in meters.
*/
constexpr double EARTH_DIAMETER = EARTH_CIRCUMFERENCE / PI;

/**
* The Earth's radius in meters.
*
* The previous hardcoded value used 6366707 which was derived from the
* following formula:
*
* Earth's radius (m) = Earth's circumference / 2 * Pi
*
* where Earth's circumference can be derived with the following formula:
*
* Earth's circumference (m) = NMI * ARCMINUTES_PER_DEGREE * DEGREES_PER_TURN
*/
constexpr double EARTHRADIUS = EARTH_DIAMETER / 2;

#define OUTPUT_DIST_SCALE 1000
#define MAX_PLACE_SIZE 20000
Expand Down
3 changes: 3 additions & 0 deletions src/CovidSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ void ReadParams(char* ParamFile, char* PreParamFile)
if (!(ParamFile_dat = fopen(ParamFile, "rb"))) ERR_CRITICAL("Unable to open parameter file\n");
PreParamFile_dat = fopen(PreParamFile, "rb");
if (!(AdminFile_dat = fopen(AdunitFile, "rb"))) AdminFile_dat = ParamFile_dat;
if (!GetInputParameter2(ParamFile_dat, AdminFile_dat, "Longitude cut line", "%lf", (void*) & (P.LongitudeCutLine), 1, 1, 0)) {
P.LongitudeCutLine = -360.0;
}
AgeSuscScale = 1.0;
GetInputParameter(ParamFile_dat, PreParamFile_dat, "Update timestep", "%lf", (void*) & (P.TimeStep), 1, 1, 0);
GetInputParameter(ParamFile_dat, PreParamFile_dat, "Sampling timestep", "%lf", (void*) & (P.SampleStep), 1, 1, 0);
Expand Down
2 changes: 0 additions & 2 deletions src/CovidSim.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include "MachineDefines.h"

#define KMP_LIBRARY throughput

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
5 changes: 1 addition & 4 deletions src/InfStat.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
#define InfStat_Dead_WasSymp -5 //// Dead was symptomatic
#define InfStat_Dead 5 //// Dead (will use this for abs() values) so code reads correctly


#define NUM_SYMPTO_SEVERITY_CLASSES 4

// SeverityClass defintions / labels (numbers arbitrary but must be different to each other).
#define Severity_Asymptomatic -1 //// Flag value.
#define Severity_Mild 0
#define Severity_ILI 1
#define Severity_SARI 2
#define Severity_Critical 3
#define Severity_RecoveringFromCritical 4 //// Recovering from Critical (not recovered yet). Not included in NUM_SYMPTO_SEVERITY_CLASSES but could change. Also doesn't count as person.Severity_Final
#define Severity_RecoveringFromCritical 4 //// Recovering from Critical (not recovered yet).
#define Severity_Dead 5 //// label to avoid double counting. Not sure you need.
#define Severity_Recovered 6 //// label to avoid double counting. Not sure you need.

Expand Down
4 changes: 2 additions & 2 deletions src/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ typedef struct CONTACTEVENT {
typedef struct POPVAR {

int S, L, I, R, D, cumI, cumR, cumD, cumC, cumTC, cumFC, cumDC, trigDC;
int H, cumH; //Added total and cumulative hospitalisation: ggilani 28/10/14
int cumH; //Added cumulative hospitalisation: ggilani 28/10/14
int CT, cumCT, CC, cumCC, DCT, cumDCT; //Added total and cumulative contact tracing: ggilani 15/06/17, and equivalents for digital contact tracing: ggilani 11/03/20
int cumC_country[MAX_COUNTRIES]; //added cumulative cases by country: ggilani 12/11/14
int cumHQ, cumAC, cumAA, cumAH, cumACS, cumAPC, cumAPA, cumAPCS;
Expand Down Expand Up @@ -147,7 +147,7 @@ typedef struct POPVAR {
typedef struct RESULTS {

double t, S, L, I, R, D, incC, incTC, incFC, incI, incR, incD, incDC ;
double H, incH; //added total hospitalisation and incidence of hospitalisation: ggilani 28/10/14
double incH; //added incidence of hospitalisation: ggilani 28/10/14
double CT, incCT, CC, 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
double incC_country[MAX_COUNTRIES]; //added incidence of cases
double cumT, cumUT, cumTP, cumV, cumTmax, cumVmax, cumDC, extinct, cumVG; //added cumVG
Expand Down
1 change: 1 addition & 0 deletions src/Param.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typedef struct PARAM {
long nextSetupSeed1, nextSetupSeed2; // The next RNG seeds to use when we need to reinitialise the RNG for setup
long nextRunSeed1, nextRunSeed2; // The next RNG seeds to use when we need to reinitialise the RNG for the model
int ResetSeeds,KeepSameSeeds, ResetSeedsPostIntervention, ResetSeedsFlag, TimeToResetSeeds;
double LongitudeCutLine; // Longitude to image earth is cut at to produce a flat map. Default -360 degrees (effectively -180). Use to ensure countries have a contiguous boundary
double SpatialBoundingBox[4], LocationInitialInfection[MAX_NUM_SEED_LOCATIONS][2], InitialInfectionsAdminUnitWeight[MAX_NUM_SEED_LOCATIONS], TimeStepsPerDay;
double FalsePositiveRate, FalsePositivePerCapitaIncidence, FalsePositiveAgeRate[NUM_AGE_GROUPS];
double latent_icdf[CDF_RES + 1], infectious_icdf[CDF_RES + 1], infectious_prof[INFPROF_RES + 1], infectiousness[MAX_INFECTIOUS_STEPS];
Expand Down
Loading

0 comments on commit 1f296a7

Please sign in to comment.