Skip to content

Commit

Permalink
Merge pull request #414 from zdroid/covidsim_switch
Browse files Browse the repository at this point in the history
Replace P.clPx with P.clP[x]
  • Loading branch information
weshinsley authored Jun 27, 2020
2 parents 0d18bfd + ebe5af9 commit bdd4fea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 67 deletions.
81 changes: 17 additions & 64 deletions src/CovidSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ int main(int argc, char* argv[])
args.add_custom_option("BM", parse_bmp_option, "Bitmap format to use [PNG,BMP]");
args.add_integer_option("c", P.MaxNumThreads, "Number of threads to use");
args.add_integer_option("C", P.PlaceCloseIndepThresh, "Sets the P.PlaceCloseIndepThresh parameter");
args.add_double_option("CLP1", P.clP1, "Overwrites #1 wildcard in parameter file");
args.add_double_option("CLP2", P.clP2, "Overwrites #2 wildcard in parameter file");
args.add_double_option("CLP3", P.clP3, "Overwrites #3 wildcard in parameter file");
args.add_double_option("CLP4", P.clP4, "Overwrites #4 wildcard in parameter file");
args.add_double_option("CLP5", P.clP5, "Overwrites #5 wildcard in parameter file");
args.add_double_option("CLP6", P.clP6, "Overwrites #6 wildcard in parameter file");
args.add_double_option("CLP1", P.clP[0], "Overwrites #1 wildcard in parameter file");
args.add_double_option("CLP2", P.clP[1], "Overwrites #2 wildcard in parameter file");
args.add_double_option("CLP3", P.clP[2], "Overwrites #3 wildcard in parameter file");
args.add_double_option("CLP4", P.clP[3], "Overwrites #4 wildcard in parameter file");
args.add_double_option("CLP5", P.clP[4], "Overwrites #5 wildcard in parameter file");
args.add_double_option("CLP6", P.clP[5], "Overwrites #6 wildcard in parameter file");
args.add_string_option("d", parse_read_file, reg_demog_file, "Regional demography file");
args.add_string_option("D", parse_read_file, density_file, "Population density file");
args.add_custom_option("I", parse_intervention_file_option, "Intervention file");
Expand Down Expand Up @@ -5517,66 +5517,19 @@ int GetInputParameter3(FILE* dat, const char* SItemName, const char* ItemType, v
if (NumItem == 1)
{
if(fscanf(dat, "%s", match) != 1) { ERR_CRITICAL_FMT("fscanf failed for %s\n", SItemName); }
if ((match[0] == '#') && (match[1] == '1'))
{
FindFlag++;
if (n == 1)
* ((double*)ItemPtr) = P.clP1;
else if (n == 2)
* ((int*)ItemPtr) = (int)P.clP1;
else if (n == 3)
sscanf(match, "%s", (char*)ItemPtr);
}
else if ((match[0] == '#') && (match[1] == '2'))
{
FindFlag++;
if (n == 1)
* ((double*)ItemPtr) = P.clP2;
else if (n == 2)
* ((int*)ItemPtr) = (int)P.clP2;
else if (n == 3)
sscanf(match, "%s", (char*)ItemPtr);
}
else if((match[0] == '#') && (match[1] == '3'))
if (match[0] == '#') {
int match_id = match[1] - '1';
if ((match_id >= 1) && (match_id <= 6))
{
FindFlag++;
if(n == 1)
* ((double*)ItemPtr) = P.clP3;
else if(n == 2)
* ((int*)ItemPtr) = (int)P.clP3;
else if(n == 3)
sscanf(match, "%s", (char*)ItemPtr);
}
else if((match[0] == '#') && (match[1] == '4'))
{
FindFlag++;
if(n == 1)
* ((double*)ItemPtr) = P.clP4;
else if(n == 2)
* ((int*)ItemPtr) = (int)P.clP4;
else if(n == 3)
sscanf(match, "%s", (char*)ItemPtr);
}
else if((match[0] == '#') && (match[1] == '5'))
{
FindFlag++;
if(n == 1)
* ((double*)ItemPtr) = P.clP5;
else if(n == 2)
* ((int*)ItemPtr) = (int)P.clP5;
else if(n == 3)
sscanf(match, "%s", (char*)ItemPtr);
}
else if((match[0] == '#') && (match[1] == '6'))
{
FindFlag++;
if(n == 1)
* ((double*)ItemPtr) = P.clP6;
else if(n == 2)
* ((int*)ItemPtr) = (int)P.clP6;
else if(n == 3)
sscanf(match, "%s", (char*)ItemPtr);
FindFlag++;
if (n == 1)
* ((double*)ItemPtr) = P.clP[match_id];
else if (n == 2)
* ((int*)ItemPtr) = (int)P.clP[match_id];
else if (n == 3)
sscanf(match, "%s", (char*)ItemPtr);
}
}
else if ((match[0] != '[') && (!feof(dat)))
{
FindFlag++;
Expand Down
6 changes: 3 additions & 3 deletions src/Param.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct Param
CovidSim::TBD1::KernelStruct AirportKernel;
unsigned int BinFileLen;
int DoBin;
double SnapshotSaveTime, SnapshotLoadTime, clP1, clP2, clP3, clP4, clP5, clP6;
double SnapshotSaveTime, SnapshotLoadTime, clP[6];
int NC; // Number of cells
int NMC; // Number of microcells
int NMCL; // Number of microcells wide/high a cell is; i.e. NMC = NC * NMCL * NMCL
Expand Down Expand Up @@ -274,11 +274,11 @@ struct Param
double SeedingScaling; // Scaling of number of seeding infections by location. (internal parameter not specified by user/command line/(pre-parameter files. Value determined through calibration.)
int CaseOrDeathThresholdBeforeAlert; // Number of deaths accummulated before alert (if TriggerAlertOnDeaths == 1) OR "Number of detected cases needed before outbreak alert triggered" (if TriggerAlertOnDeaths == 0)
int CaseOrDeathThresholdBeforeAlert_Fixed; // CaseOrDeathThresholdBeforeAlert adjusted during calibration. Need to record fixed version in order to reset so that calibration works for multiple realisations
int TriggerAlertOnDeaths; // Trigger alert on deaths (if true then cumulative deaths used for calibration, if false then cumulative ICU cases used for calibration).
int TriggerAlertOnDeaths; // Trigger alert on deaths (if true then cumulative deaths used for calibration, if false then cumulative ICU cases used for calibration).
int WindowToEvaluateTriggerAlert; // Number of days to accummulate cases/deaths before alert
int DoAlertTriggerAfterInterv; // Alert trigger starts after interventions, i.e. were there interventions before date specified in DateTriggerReached_CalTime / "Day of year trigger is reached"?
int AlertTriggerAfterIntervThreshold; // initialized to CaseOrDeathThresholdBeforeAlert (i.e. number cases or deaths accumulated before alert).

int StopCalibration;
int ModelCalibIteration;

Expand Down

0 comments on commit bdd4fea

Please sign in to comment.