Skip to content

Commit e94f87c

Browse files
committed
fix interim outputs not being created; don't output if INTERIM_OUTPUT_INTERVAL = 0
1 parent e069708 commit e94f87c

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

settings.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ DEFAULT_PERCENT_CONIFER = 50
2828
DEFAULT_PERCENT_DEAD_FIR = 30
2929
# maximum amount of time to take for simulation (seconds) (0 is unlimited)
3030
MAXIMUM_TIME = 0
31-
# amount of time between generating interim outputs (seconds)
32-
INTERIM_OUTPUT_INTERVAL = 240
31+
# amount of time between generating interim outputs (seconds) (0 is no interim outputs)
32+
INTERIM_OUTPUT_INTERVAL = 0
3333
# maximum number of simulations to do (0 is exactly 1 simulation per scenario)
3434
MAXIMUM_SIMULATIONS = 10000
3535
# maximum percent change in statistics between runs before results are consider stable [0 - 1]

src/cpp/fs/Model.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,15 @@ map<DurationSize, shared_ptr<ProbabilityMap>> Model::runIterations(
803803
constexpr auto CHECK_INTERVAL = std::chrono::seconds(1);
804804
bool keep_checking{true};
805805
const bool is_limited = 0 != Settings::maximumTimeSeconds();
806+
const bool with_interim = 0 != interim_save_interval_.count();
806807
if (!is_limited)
807808
{
808809
logging::note("No time limit being enforced since MAXIMUM_TIME = 0");
809810
}
811+
if (!with_interim)
812+
{
813+
logging::note("No interim outputs being generated since INTERIM_OUTPUT_INTERVAL = 0");
814+
}
810815
while (keep_checking)
811816
{
812817
this->last_checked_ = Clock::now();
@@ -815,6 +820,12 @@ map<DurationSize, shared_ptr<ProbabilityMap>> Model::runIterations(
815820
std::this_thread::sleep_for(CHECK_INTERVAL);
816821
// set bool so other things don't need to check clock
817822
is_out_of_time_ = is_limited && runTime().count() >= timeLimit().count();
823+
should_output_interim_ =
824+
with_interim && timeSinceLastSave().count() >= interimTimeLimit().count();
825+
if (should_output_interim_ && interim_changed_)
826+
{
827+
saveProbabilities(all_probabilities[0], start_day, true);
828+
}
818829
logging::verbose("Checking clock [%ld of %ld]", runTime(), timeLimit());
819830
keep_checking = (runs_left > 0 && !shouldStop());
820831
}

0 commit comments

Comments
 (0)