From b6b7dbe375e766bcd74285dec5d065fa265ce020 Mon Sep 17 00:00:00 2001 From: mattg3004 Date: Tue, 7 Jan 2025 11:12:46 +0800 Subject: [PATCH] allow us to specify a date to start NTDMC output from --- src/Model.cpp | 24 ++++++++++++++++++------ src/Model.hpp | 12 +++++++----- src/Scenario.cpp | 1 + src/main.cpp | 12 +++++++++--- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/Model.cpp b/src/Model.cpp index 524b4ee..29c02c9 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -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) { @@ -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) @@ -215,6 +218,7 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors, int rep, std::vector &k_vals, std::vector &v_to_h_vals, int updateParams, int outputEndgame, int outputEndgameDate, + int outputNTDMC, int outputNTDMCDate, int reduceImpViaXml, std::string opDir, double cov_prop) { @@ -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); @@ -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; @@ -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, @@ -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 diff --git a/src/Model.hpp b/src/Model.hpp index f23176b..e774aa7 100644 --- a/src/Model.hpp +++ b/src/Model.hpp @@ -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); @@ -47,8 +48,9 @@ class Model { Scenario &sc, Output ¤tOutput, int rep, std::vector &k_vals, std::vector &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 &k_vals, std::vector &v_to_h_vals, std::vector &aImp_vals, diff --git a/src/Scenario.cpp b/src/Scenario.cpp index 0e411ff..281f14f 100644 --- a/src/Scenario.cpp +++ b/src/Scenario.cpp @@ -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); diff --git a/src/main.cpp b/src/main.cpp index 1ab6f5b..12ea9b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; @@ -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 { @@ -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 +