Commit 46f887fe authored by Ulrich Kemloh's avatar Ulrich Kemloh

fixed an issue in the statistics where the pedestians were assigned a

wrong door.
parent 84f0531d
......@@ -242,11 +242,10 @@ bool Simulation::InitArgs(const ArgumentParser& args)
return false;
//other initializations
const vector<Pedestrian*>& allPeds = _building->GetAllPedestrians();
for (Pedestrian *ped : allPeds) {
for (auto&& ped: _building->GetAllPedestrians()) {
ped->Setdt(_deltaT);
}
_nPeds = allPeds.size();
_nPeds = _building->GetAllPedestrians().size();
//_building->WriteToErrorLog();
//get the seed
......@@ -352,6 +351,14 @@ void Simulation::UpdateRoutesAndLocations()
//actualize the egress time for that iroom
old_room->SetEgressTime(ped->GetGlobalTime());
//the pedestrian did not used the door to exit the room
//todo: optimize with distance square
//if(ped->GetDistanceToNextTarget()>0.5)
//{
// Log->Write("WARNING:\t pedestrian [%d] left the room in an unusual way. Please check",ped->GetID());
// Log->Write(" \t distance to previous target is %f",ped->GetDistanceToNextTarget());
//}
//also statistic for internal doors
UpdateFlowAtDoors(*ped);
......@@ -566,21 +573,41 @@ void Simulation::UpdateFlowAtDoors(const Pedestrian& ped) const
Transition* trans =_building->GetTransitionByUID(ped.GetExitIndex());
if(trans)
{
//check if the pedestrian left the door correctly
if(ped.GetExitLine()->DistTo(ped.GetPos())>0.5)
{
Log->Write("WARNING:\t pedestrian [%d] left the room in an unusual way. Please check",ped.GetID());
Log->Write(" :\t distance to last door is %f. That should be smaller.", ped.GetExitLine()->DistTo(ped.GetPos()));
Log->Write(" :\t correcting the door statistics");
//ped.Dump(ped.GetID());
//checking the history and picking the nearest previous destination
double biggest=0.3;
bool success=false;
for(const auto & dest:ped.GetLastDestinations())
{
if(dest!=-1)
{
Transition* trans_tmp =_building->GetTransitionByUID(dest);
if(trans_tmp&&trans_tmp->DistTo(ped.GetPos())<biggest)
{
biggest=trans_tmp->DistTo(ped.GetPos());
trans=trans_tmp;
Log->Write(" :\t Best match found at door %d",dest);
success=true;//at least one door was found
}
}
}
if(success==false)
{
Log->Write("ERROR :\t correcting the door statistics");
exit(EXIT_SUCCESS);
}
}
trans->IncreaseDoorUsage(1, ped.GetGlobalTime());
}
// if(ped.GetExitIndex()==0)
// {
// cout<<"exi 1t: "<<endl;exit(0);
// }
//
// if(trans->GetUniqueID()==0)
// {
// cout<<"exit 2: "<<endl;exit(0);
// }
// if(trans->GetID()==0)
// {
// cout<<"exit 3: "<<endl;exit(0);
// }
}
}
......
......@@ -117,6 +117,21 @@ public:
*/
void UpdateRoutesAndLocations();
/**
* Update the routes (intermediate destinations) of the pedestrians.
* Based on the route choice algorithm used, the next doors or the next decision points is set.
* TODO:
*/
void UpdateRoutes();
/**
* Update the location of the agents and remove the agents from the simulation who have left the building.
* Locations includes room/subrooms.
* TODO:
*/
void UpdateLocations();
/**
* Perform some initialisation for the simulation.
* such as writing the headers for the trajectories.
......
......@@ -1365,11 +1365,11 @@ Pedestrian* Building::GetPedestrian(int pedID) const
Transition* Building::GetTransitionByUID(int uid) const
{
//eventually
map<int, Transition*>::const_iterator itr;
for(itr = _transitions.begin(); itr != _transitions.end(); ++itr) {
if (itr->second->GetUniqueID()== uid)
return itr->second;
for(auto && trans: _transitions)
{
if(trans.second->GetUniqueID()==uid)
return trans.second;
}
return nullptr;
}
......
......@@ -727,7 +727,7 @@ void QuickestPathRouter::Redirect(Pedestrian* ped)
if(relevantAPs.size()==0)
{
Log->Write("WARNING:\t Cannot redirect the pedestrian [%d]", ped->GetID());
//Log->Write("WARNING:\t Cannot redirect the pedestrian [%d]", ped->GetID());
return;
}
......@@ -778,7 +778,7 @@ void QuickestPathRouter::Redirect(Pedestrian* ped)
if(quickest==-1)
{
Log->Write("WARNING:\t Cannot redirect the pedestrian [%d]", ped->GetID());
//Log->Write("WARNING:\t Cannot redirect the pedestrian [%d]", ped->GetID());
return;
}
......
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