From 95793bf79043f74646b0eee1f4a15be57d5db9de Mon Sep 17 00:00:00 2001 From: mattg3004 Date: Tue, 14 Jan 2025 11:08:32 +0800 Subject: [PATCH] address PR comments --- src/Model.cpp | 27 +++++++++++++++------------ src/Model.hpp | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Model.cpp b/src/Model.cpp index e049579..241a840 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -28,7 +28,7 @@ void Model::runScenarios(ScenariosList &scenarios, Population &popln, Vector &vectors, Worm &worms, int replicates, double timestep, int index, int outputEndgame, int outputEndgameDate, bool outputNTDMC, - int outputNTDMCDate, int reduceImpViaXml, + std::optional outputNTDMCDate, int reduceImpViaXml, std::string randParamsfile, std::string RandomSeedFile, std::string RandomCovPropFile, std::string opDir) { @@ -146,13 +146,13 @@ void Model::runScenarios(ScenariosList &scenarios, Population &popln, } // evolve, saving any specified months along the way - for (int y = 0; y < sc.getNumMonthsToSave(); y++) - + 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, outputNTDMC, outputNTDMCDate, reduceImpViaXml, opDir, cov_prop); - + } + // done for this scenario, save the prevalence values for this replicate if (!_DEBUG) sc.printResults(rep, currentOutput, popln); @@ -218,7 +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, - bool outputNTDMC, int outputNTDMCDate, + bool outputNTDMC, std::optional outputNTDMCDate, int reduceImpViaXml, std::string opDir, double cov_prop) { @@ -241,7 +241,9 @@ 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; + if(outputNTDMCDate.hasValue()){ + outputNTDMCDateFromYear = (outputNTDMCDate.value - BASEYEAR) * 12; + } int popSize = popln.getSizeOfPop(); double mfprev_aimp_old = popln.getMFPrev(sc, 0, 0, outputEndgameDate, rep, popSize, folderName); @@ -258,15 +260,16 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors, int HydroceleTotalWorms = popln.getHydroceleTotalWorms(); double LymphodemaShape = popln.getLymphodemaShape(); double HydroceleShape = popln.getHydroceleShape(); - // if y != 0, then this is a simulation of a scenario which has already - // started and hence, we don't want to reinitialise the outputs + + // Only initalize outputs if we are at the start of a simulation, when y==0 + // (rather than reinitializing for a scenario that has already started) if ((outputEndgame == 1) && (y == 0)) { sc.InitIHMEData(rep, folderName); sc.InitPreTASData(rep, folderName); sc.InitTASData(rep, folderName); } - // if y != 0, then this is a simulation of a scenario which has already - // started and hence, we don't want to reinitialise the outputs + // Only initalize outputs if we are at the start of a simulation, when y==0 + // (rather than reinitializing for a scenario that has already started) if ((outputNTDMC == true) && (y == 0)) { sc.InitNTDMCData(rep, folderName); } @@ -332,8 +335,8 @@ void Model::evolveAndSave(int y, Population &popln, Vector &vectors, sc.writeSurveyByAge(popln, t, popln.preTAS_Pass, popln.TAS_Pass, rep, folderName); } - - if ((t % 12 == 0) && (outputNTDMC == true) && (t >= outputNTDMCDate)) { + + if ((t % 12 == 0) && (outputNTDMC == true) && (t >= outputNTDMCDateFromYear)) { sc.writeRoadmapTarget(popln, t, rep, popln.DoMDA, popln.TAS_Pass, neededTASPass, folderName); } diff --git a/src/Model.hpp b/src/Model.hpp index 6411a57..32dd4ec 100644 --- a/src/Model.hpp +++ b/src/Model.hpp @@ -29,7 +29,7 @@ class Model { Vector &vectors, Worm &worms, int replicates, double timestep, int index, int outputEndgame, int outputEndgameDate, bool outputNTDMC, - int outputNTDMCDate, int reduceImpViaXml, + std::optional outputNTDMCDate, int reduceImpViaXml, std::string randParamsfile, std::string RandomSeedFile, std::string RandomCovPropFile, std::string opDir); bool