Runtime Bottleneck
@chraibi @Arne
It seems we have in every model a method called
::ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic)
What happens inside this method is:
for (int p = start; p <= end; ++p) {
Pedestrian* ped = allPeds[p];
Room* room = building->GetRoom(ped->GetRoomID());
SubRoom* subroom = room->GetSubRoom(ped->GetSubRoomID());
...
for (int i = 0; i < size; i++) {
Pedestrian* ped1 = neighbours[i];
//if they are in the same subroom
...
bool isVisible = building->IsVisible(p1, p2, emptyVector, false);
if (!isVisible)
continue;
if (ped->GetUniqueRoomID() == ped1->GetUniqueRoomID()) {
repPed = repPed + ForceRepPed(ped, ped1);
} else {
// or in neighbour subrooms
SubRoom* sb2=building->GetRoom(ped1->GetRoomID())->GetSubRoom(ped1->GetSubRoomID());
if(subroom->IsDirectlyConnectedWith(sb2)) {
repPed = repPed + ForceRepPed(ped, ped1);
}
}
}
...
This basically means: First we calculate if a pedestrian is visible, which is pretty expensive (enormous expensive) and then we do the simple check if they are in the same room/subroom or neighbour subroom and if not we don't do any calculation.
This is wrong way round... we should first check if these Pedestrians need a force update because they influence each other than calculating if they can see each other through the sub room