Skip to content

Commit

Permalink
Fix baseline and intervention out files clobbering.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesturner246 committed Nov 27, 2023
1 parent be8f71b commit ca6fac5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/HealthGPS/healthgps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ void HealthGPS::initialise_population() {
std::vector<core::Identifier> keys = {
"Age", "Gender", "Sector", "Income", "Carbohydrate", "Fat",
"Protein", "Sodium", "PhysicalActivity", "EnergyIntake", "Height", "Weight"};
std::ofstream file(fmt::format("initialise_{}.csv", context_.time_now()));
std::string scenario =
context_.scenario().type() == ScenarioType::baseline ? "baseline" : "intervention";
std::ofstream file(fmt::format("initialise_{}_{}.csv", scenario, context_.time_now()));

for (const auto &key : keys) {
file << key.to_string() << ",";
Expand Down Expand Up @@ -204,7 +206,9 @@ void HealthGPS::update_population() {
std::vector<core::Identifier> keys = {
"Age", "Gender", "Sector", "Income", "Carbohydrate", "Fat",
"Protein", "Sodium", "PhysicalActivity", "EnergyIntake", "Height", "Weight"};
std::ofstream file(fmt::format("update_{}.csv", context_.time_now()));
std::string scenario =
context_.scenario().type() == ScenarioType::baseline ? "baseline" : "intervention";
std::ofstream file(fmt::format("update_{}_{}.csv", scenario, context_.time_now()));

for (const auto &key : keys) {
file << key.to_string() << ",";
Expand Down

0 comments on commit ca6fac5

Please sign in to comment.