Commit a3ec1420 authored by tobias schroedter's avatar tobias schroedter

Pedestrians leaving/removed should now only be counted once. Solving

issue 3 (show statistics from GitHub).
parent c5f458f6
Pipeline #9034 failed with stages
in 14 seconds
...@@ -286,8 +286,8 @@ void Simulation::UpdateRoutesAndLocations() ...@@ -286,8 +286,8 @@ void Simulation::UpdateRoutesAndLocations()
{ {
//pedestrians to be deleted //pedestrians to be deleted
//you should better create this in the constructor and allocate it once. //you should better create this in the constructor and allocate it once.
vector<Pedestrian*> pedsToRemove; set<Pedestrian*> pedsToRemove;
pedsToRemove.reserve(500); //just reserve some space // pedsToRemove.reserve(500); //just reserve some space
// collect all pedestrians in the simulation. // collect all pedestrians in the simulation.
const vector<Pedestrian*>& allPeds = _building->GetAllPedestrians(); const vector<Pedestrian*>& allPeds = _building->GetAllPedestrians();
...@@ -305,12 +305,12 @@ void Simulation::UpdateRoutesAndLocations() ...@@ -305,12 +305,12 @@ void Simulation::UpdateRoutesAndLocations()
&& (room->GetCaption() == "outside")) { && (room->GetCaption() == "outside")) {
#pragma omp critical(Simulation_Update_pedsToRemove) #pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.push_back(ped); pedsToRemove.insert(ped);
} else if ((ped->GetFinalDestination() != FINAL_DEST_OUT) } else if ((ped->GetFinalDestination() != FINAL_DEST_OUT)
&& (goals.at(ped->GetFinalDestination())->Contains( && (goals.at(ped->GetFinalDestination())->Contains(
ped->GetPos()))) { ped->GetPos()))) {
#pragma omp critical(Simulation_Update_pedsToRemove) #pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.push_back(ped); pedsToRemove.insert(ped);
} }
// reposition in the case the pedestrians "accidently left the room" not via the intended exit. // reposition in the case the pedestrians "accidently left the room" not via the intended exit.
...@@ -326,8 +326,7 @@ void Simulation::UpdateRoutesAndLocations() ...@@ -326,8 +326,7 @@ void Simulation::UpdateRoutesAndLocations()
if (!assigned) { if (!assigned) {
#pragma omp critical(Simulation_Update_pedsToRemove) #pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.push_back(ped); pedsToRemove.insert(ped); //the agent left the old room
//the agent left the old room
//actualize the eggress time for that room //actualize the eggress time for that room
#pragma omp critical(SetEgressTime) #pragma omp critical(SetEgressTime)
allRooms.at(ped->GetRoomID())->SetEgressTime(ped->GetGlobalTime()); allRooms.at(ped->GetRoomID())->SetEgressTime(ped->GetGlobalTime());
...@@ -343,7 +342,7 @@ void Simulation::UpdateRoutesAndLocations() ...@@ -343,7 +342,7 @@ void Simulation::UpdateRoutesAndLocations()
ped->Relocate(f); ped->Relocate(f);
//exit(EXIT_FAILURE); //exit(EXIT_FAILURE);
#pragma omp critical(Simulation_Update_pedsToRemove) #pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.push_back(ped); pedsToRemove.insert(ped);
} }
} }
...@@ -356,10 +355,11 @@ void Simulation::UpdateRoutesAndLocations() ...@@ -356,10 +355,11 @@ void Simulation::UpdateRoutesAndLocations()
else else
#endif #endif
{ {
// remove the pedestrians that have left the building // remove the pedestrians that have left the building
for (unsigned int p = 0; p<pedsToRemove.size(); p++) { for (auto p : pedsToRemove){
Please register or sign in to reply
UpdateFlowAtDoors(*pedsToRemove[p]); UpdateFlowAtDoors(*p);
_building->DeletePedestrian(pedsToRemove[p]); _building->DeletePedestrian(p);
} }
pedsToRemove.clear(); pedsToRemove.clear();
} }
...@@ -605,7 +605,7 @@ void Simulation::UpdateFlowAtDoors(const Pedestrian& ped) const ...@@ -605,7 +605,7 @@ void Simulation::UpdateFlowAtDoors(const Pedestrian& ped) const
} }
} }
//#pragma omp critical //#pragma omp critical
trans->IncreaseDoorUsage(1, ped.GetGlobalTime()); trans->IncreaseDoorUsage(1, ped.GetGlobalTime(), ped.GetID());
} }
} }
} }
......
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