Skip to content

Commit

Permalink
allow us to specify a date to start NTDMC output from
Browse files Browse the repository at this point in the history
  • Loading branch information
mattg3004 committed Jan 7, 2025
1 parent accc859 commit b6b7dbe
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
24 changes: 18 additions & 6 deletions src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ extern Statistics stats;
void Model::runScenarios(ScenariosList &scenarios, Population &popln,
Vector &vectors, Worm &worms, int replicates,
double timestep, int index, int outputEndgame,
int outputEndgameDate, int reduceImpViaXml,
int outputEndgameDate, int outputNTDMC,
int outputNTDMCDate, int reduceImpViaXml,
std::string randParamsfile, std::string RandomSeedFile,
std::string RandomCovPropFile, std::string opDir) {

Expand Down Expand Up @@ -146,9 +147,11 @@ void Model::runScenarios(ScenariosList &scenarios, Population &popln,

// evolve, saving any specified months along the way
for (int y = 0; y < sc.getNumMonthsToSave(); y++)

evolveAndSave(y, popln, vectors, worms, sc, currentOutput, rep, k_vals,
v_to_h_vals, popln.getUpdateParams(), outputEndgame,
outputEndgameDate, reduceImpViaXml, opDir, cov_prop);
outputEndgameDate, outputNTDMC, outputNTDMCDate,
reduceImpViaXml, opDir, cov_prop);

// done for this scenario, save the prevalence values for this replicate
if (!_DEBUG)
Expand Down Expand Up @@ -215,6 +218,7 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors,
int rep, std::vector<double> &k_vals,
std::vector<double> &v_to_h_vals, int updateParams,
int outputEndgame, int outputEndgameDate,
int outputNTDMC, int outputNTDMCDate,
int reduceImpViaXml, std::string opDir,
double cov_prop) {

Expand All @@ -237,6 +241,7 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors,
// simulations from the scenario file.
int BASEYEAR = 2000;
outputEndgameDate = (outputEndgameDate - BASEYEAR) * 12;
outputNTDMCDate = (outputNTDMCDate - BASEYEAR) * 12;
int popSize = popln.getSizeOfPop();
double mfprev_aimp_old =
popln.getMFPrev(sc, 0, 0, outputEndgameDate, rep, popSize, folderName);
Expand All @@ -254,13 +259,16 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors,
double LymphodemaShape = popln.getLymphodemaShape();
double HydroceleShape = popln.getHydroceleShape();

if (outputEndgame == 1) {
if ((outputEndgame == 1) && (y == 0)) {
sc.InitIHMEData(rep, folderName);
sc.InitNTDMCData(rep, folderName);
sc.InitPreTASData(rep, folderName);
sc.InitTASData(rep, folderName);
}

if ((outputNTDMC == 1) && (y == 0)) {
sc.InitNTDMCData(rep, folderName);
}

int vec_control = 0;

int minAge;
Expand Down Expand Up @@ -313,8 +321,7 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors,
// year we want to do the endgame output for, then don't do this.
if ((t % 12 == 0) && (outputEndgame == 1) && (t >= outputEndgameDate)) {
sc.writePrevByAge(popln, t, rep, folderName);
sc.writeRoadmapTarget(popln, t, rep, popln.DoMDA, popln.TAS_Pass,
neededTASPass, folderName);

sc.writeNumberByAge(popln, t, rep, folderName, "not survey");
sc.writeSequelaeByAge(popln, t, LymphodemaTotalWorms, LymphodemaShape,
HydroceleTotalWorms, HydroceleShape, rep,
Expand All @@ -324,6 +331,11 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors,
folderName);
}

if ((t % 12 == 0) && (outputNTDMC == 1) && (t >= outputNTDMCDate)) {
sc.writeRoadmapTarget(popln, t, rep, popln.DoMDA, popln.TAS_Pass,
neededTASPass, folderName);
}

// If we haven't done a survey this year we still want to output this fact
// for endgame. This is because the decision to do the survey is dynamic and
// may occur in some simulations but not in others. to make sure that
Expand Down
12 changes: 7 additions & 5 deletions src/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class Model {
void runScenarios(ScenariosList &scenarios, Population &popln,
Vector &vectors, Worm &worms, int replicates,
double timestep, int index, int outputEndgame,
int outputEndgameDate, int reduceImpViaXml,
std::string randParamsfile, std::string RandomSeedFile,
std::string RandomCovPropFile, std::string opDir);
int outputEndgameDate, int outputNTDMC, int outputNTDMCDate,
int reduceImpViaXml, std::string randParamsfile,
std::string RandomSeedFile, std::string RandomCovPropFile,
std::string opDir);
bool
shouldReduceImportationViaPrevalance(int t, int reduceImpViaXml,
int switchImportationReducingMethodTime);
Expand All @@ -47,8 +48,9 @@ class Model {
Scenario &sc, Output &currentOutput, int rep,
std::vector<double> &k_vals,
std::vector<double> &v_to_h_vals, int updateParams,
int outputEndgame, int outputEndgameDate,
int reduceImpViaXml, std::string opDir, double cov_prop);
int outputEndgame, int outputEndgameDate, int outputNTDMC,
int outputNTDMCDate, int reduceImpViaXml,
std::string opDir, double cov_prop);
void getRandomParameters(int index, std::vector<double> &k_vals,
std::vector<double> &v_to_h_vals,
std::vector<double> &aImp_vals,
Expand Down
1 change: 1 addition & 0 deletions src/Scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ void Scenario::InitNTDMCData(int rep, std::string folder) {
if (stat(fname2.c_str(), &buffer) != 0) {
fs::create_directories(fname2);
}

std::ofstream outfile;
outfile.open(fname);

Expand Down
12 changes: 9 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ int main(int argc, char **argv) {
// xml file rather than impact of MDA on the prevalence
int outputEndgame = 1;
int outputEndgameDate = 2000;
int outputNTDMC = 1;
int outputNTDMCDate = 2000;
int reduceImpViaXml = 0;

int index = 0;
Expand Down Expand Up @@ -112,6 +114,10 @@ int main(int argc, char **argv) {
outputEndgame = atoi(argv[i + 1]);
else if (!strcmp(argv[i], "-D"))
outputEndgameDate = atoi(argv[i + 1]);
else if (!strcmp(argv[i], "-m"))
outputNTDMC = atoi(argv[i + 1]);
else if (!strcmp(argv[i], "-N"))
outputNTDMCDate = atoi(argv[i + 1]);
else if (!strcmp(argv[i], "-x"))
reduceImpViaXml = atoi(argv[i + 1]);
else {
Expand Down Expand Up @@ -193,9 +199,9 @@ int main(int argc, char **argv) {
// Run
Model model;
model.runScenarios(Scenarios, hostPopulation, vectors, worms, replicates, dt,
index, outputEndgame, outputEndgameDate, reduceImpViaXml,
randParamsfile, RandomSeedFile, CoverageReductionFile,
opDir);
index, outputEndgame, outputEndgameDate, outputNTDMC,
outputNTDMCDate, reduceImpViaXml, randParamsfile,
RandomSeedFile, CoverageReductionFile, opDir);

gettimeofday(&tv2, NULL);
double timesofar = (double)(tv2.tv_usec - tv1.tv_usec) / 1000000.0 +
Expand Down

0 comments on commit b6b7dbe

Please sign in to comment.