relocate agents, if they have invalid room-/subroom information Refactor
What should be done
In Simulation::UpdateRoutesAndLocations()
there is the following code:
std::function<void(const Pedestrian&)> f = std::bind(&Simulation::UpdateFlowAtDoors, this, std::placeholders::_1);
assigned = ped->Relocate(f);
which is working with the part in the Pedestrian
class:
for (auto&it_room : allRooms)
{
auto& room = it_room.second;
auto subrooms = room->GetAllSubRooms();
map<int, std::shared_ptr<SubRoom> >::iterator sub =
std::find_if(subrooms.begin(), subrooms.end(), [&] (std::pair<int, std::shared_ptr<SubRoom>> iterator) {
return ((iterator.second->IsDirectlyConnectedWith(allRooms[_roomID]->GetSubRoom(_subRoomID))) && iterator.second->IsInSubRoom(this));
});
if(sub != subrooms.end()) {
flowupdater(*this); //@todo: ar.graf : this call should move into a critical region? check plz
ClearMentalMap(); // reset the destination
const int oldRoomID = _roomID;
SetRoomID(room->GetID(), room->GetCaption());
SetSubRoomID(sub->second->GetSubRoomID());
SetSubRoomUID(sub->second->GetUID());
_router->FindExit(this);
if(oldRoomID != room->GetID()){
//the agent left the old room
//actualize the egress time for that room
#pragma omp critical(SetEgressTime)
allRooms.at(GetRoomID())->SetEgressTime(GetGlobalTime()); //set Egresstime to old room //@todo: ar.graf : GetRoomID() yields NEW room
}
status = true;
break;
}
}
It seems to me, that the correction of the room-information somehow does not work. In the following call to the router, there are still pedestrian objects, that hold wrong room-subroom information.
I think it's worth to refactor this part of the code and make it easier and functional.
Why?
Right now, it is not working and we want to change this part anyway. The call to the router every timestep seems to much. If we find a mechanic, that will only call the router once in a while or the router will be called every timestep, but only executes once in a while, will be up for discussion.