Commit a9a9159e authored by Mohcine Chraibi's avatar Mohcine Chraibi

Condition to Stop simulation

Stop simulation
- if no ped is still living
- if no sources are used (so no zombies anymore)
- if time is left (t<t_max)

Compare to  Commit 77c3e589
parent 81a12dde
......@@ -62,6 +62,7 @@ Simulation::Simulation(const Configuration* args)
_iod = new IODispatcher();
_fps = 1;
_em = nullptr;
_gotSources = false;
// _config = args;
}
......@@ -218,6 +219,7 @@ bool Simulation::InitArgs()
// Initialize the agents sources that have been collected in the pedestrians distributor
_agentSrcManager.SetBuilding(_building.get());
_gotSources = distributor->GetAgentsSources().size(); // did we have any sources? false if no sources
for (const auto& src: distributor->GetAgentsSources()) {
_agentSrcManager.AddSource(src);
//src->Dump();
......@@ -225,6 +227,7 @@ bool Simulation::InitArgs()
//perform customs initialisation, like computing the phi for the gcfm
//this should be called after the routing engine has been initialised
// because a direction is needed for this initialisation.
......@@ -480,10 +483,9 @@ int Simulation::RunBody(double maxSimTime)
_nPeds = _building->GetAllPedestrians().size();
int initialnPeds = _nPeds;
// main program loop
while ((_nPeds || !_agentSrcManager.IsCompleted()) && t<maxSimTime) {
while ((_nPeds || (!_agentSrcManager.IsCompleted()&& _gotSources) ) && t<maxSimTime) {
t = 0+(frameNr-1)*_deltaT;
//process the queue for incoming pedestrians
//process the queue for incoming pedestriansg
ProcessAgentsQueue();
if (t>Pedestrian::GetMinPremovementTime()) {
......
......@@ -88,6 +88,7 @@ private:
/// hybrid simulation manager
//HybridSimulationManager
int _periodic;
bool _gotSources; // is true if we got some sources. Otherwise, false.
public:
/**
* Constructor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment