From f563b9c9a05b3e47070bfa4775a0e18ace8797a6 Mon Sep 17 00:00:00 2001 From: Matthijs Bijman Date: Mon, 27 Feb 2017 15:33:48 +0100 Subject: Experiments are now finished if no machines are present --- Simulator/include/simulation/Experiment.h | 8 +++++++- Simulator/src/database/Database.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Simulator/include/simulation/Experiment.h b/Simulator/include/simulation/Experiment.h index 54a861e6..2e77b924 100644 --- a/Simulator/include/simulation/Experiment.h +++ b/Simulator/include/simulation/Experiment.h @@ -32,6 +32,12 @@ namespace Simulation auto machineAccumulator = path.getCurrentSection(currentTick).getMachines(); + if (machineAccumulator.size() == 0) + { + finished = true; + return; + } + // Schedule the workload over each machine scheduler->schedule(machineAccumulator, workloadPool.getWorkloads(currentTick)); @@ -159,7 +165,7 @@ namespace Simulation /** * \brief The number of ticks that have passed. */ - uint32_t currentTick; + uint32_t currentTick = 0; /** * \brief The pool of workloads in this simulation, to be distributed by the scheduler. diff --git a/Simulator/src/database/Database.cpp b/Simulator/src/database/Database.cpp index d1bb2af5..f9ef6f7e 100644 --- a/Simulator/src/database/Database.cpp +++ b/Simulator/src/database/Database.cpp @@ -78,7 +78,7 @@ namespace Database history.clearHistory(); - uint32_t lastSimulatedTick = experiment.getCurrentTick() - 1; + uint32_t lastSimulatedTick = experiment.getCurrentTick() != 0 ? experiment.getCurrentTick() - 1 : 0; QueryExecuter<> writeLastSimulatedTick(db); writeLastSimulatedTick.setQuery(Queries::WRITE_EXPERIMENT_LAST_SIMULATED_TICK) .bindParams(lastSimulatedTick, experiment.getId()) -- cgit v1.2.3