Commit d6a408b2 authored by f.mack's avatar f.mack

Parallelized GradientModel::Init()

parent 8c0e7191
......@@ -120,15 +120,20 @@ bool GradientModel::Init (Building* building)
std::set<std::pair<int, int>> roomsDoorsSet;
roomsDoorsSet.clear();
// @todo f.mack parallelize? yes, using pedsToRemove should be fine
std::vector<Pedestrian*> pedsToRemove;
pedsToRemove.clear();
bool error_occurred = false;
#pragma omp parallel for
for(unsigned int p=0;p<allPeds.size();p++) {
Pedestrian* ped = allPeds[p];
double cosPhi, sinPhi;
//a destination could not be found for that pedestrian
if (ped->FindRoute() == -1) {
Log->Write(
"ERROR:\tGradientModel::Init() cannot initialise route. ped %d is deleted.\n",ped->GetID());
building->DeletePedestrian(ped);
"ERROR:\tGradientModel::Init() cannot initialise route. ped %d is scheduled for deletion.\n",ped->GetID());
//building->DeletePedestrian(ped);
#pragma omp critical(GradientModel_Init_pedsToRemove)
pedsToRemove.emplace_back(ped);
continue;
}
......@@ -145,8 +150,12 @@ bool GradientModel::Init (Building* building)
Log->Write(
"ERROR: \allPeds::Init() cannot initialise phi! "
"dist to target is 0\n");
return false;
#pragma omp critical(error_occurred)
error_occurred = true;
//return false;
}
// This skips the rest of the initialization if any pedestrian could not be initialized
if (error_occurred) continue;
ped->InitV0(target);
......@@ -161,6 +170,11 @@ bool GradientModel::Init (Building* building)
}
}
for (auto ped : pedsToRemove) {
building->DeletePedestrian(ped);
}
if (error_occurred) return false;
// @todo f.mack if it works, also implement for the others
if (auto dirLocff = dynamic_cast<DirectionLocalFloorfield*>(_direction.get())) {
std::map<int, std::vector<int>> doorsInRoom;
......
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