Commit 9fd03ad6 authored by Mohcine Chraibi's avatar Mohcine Chraibi

Merge branch '270-statistics' into 'develop'

Resolve "Statistics about deleted agents"

Closes #270

See merge request !24
parents 1db2aa23 3c5f575c
Pipeline #9702 canceled with stages
......@@ -52,6 +52,18 @@ int OutputHandler::GetErrors()
return _nErrors;
}
void OutputHandler::incrementDeletedAgents()
{
_nDeletedAgents += 1;
}
int OutputHandler::GetDeletedAgents()
{
return _nDeletedAgents;
}
void OutputHandler::Write(const string& str)
{
cout << endl << str;
......
......@@ -24,7 +24,7 @@
*
*
**/
#ifndef OUTPUT_HANDLER_H_
#define OUTPUT_HANDLER_H_
......@@ -44,14 +44,17 @@ class OutputHandler {
protected:
int _nWarnings;
int _nErrors;
int _nDeletedAgents;
public:
OutputHandler() { _nWarnings = 0; _nErrors = 0; };
OutputHandler() { _nWarnings = 0; _nErrors = 0; _nDeletedAgents = 0;};
virtual ~OutputHandler() {};
int GetWarnings();
void incrementWarnings();
int GetErrors();
void incrementErrors();
int GetDeletedAgents();
void incrementDeletedAgents();
void ProgressBar(double TotalPeds, double NowPeds, double simTime);
virtual void Write(const std::string& str);
......
......@@ -340,12 +340,15 @@ void Simulation::UpdateRoutesAndLocations()
if (ped->FindRoute() == -1) {
//a destination could not be found for that pedestrian
Log->Write("ERROR: \tCould not find a route for pedestrian %d",ped->GetID());
ped->FindRoute(); //debug only, plz remove
//ped->FindRoute(); //debug only, plz remove
std::function<void(const Pedestrian&)> f = std::bind(&Simulation::UpdateFlowAtDoors, this, std::placeholders::_1);
ped->Relocate(f);
//exit(EXIT_FAILURE);
#pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove.insert(ped);
{
pedsToRemove.push_back(ped);
Log->incrementDeletedAgents();
}
}
}
......
......@@ -123,6 +123,7 @@ int main(int argc, char** argv)
summary << "Number of Threads : " << configuration->GetMaxOpenMPThreads() << std::endl;
summary << "Warnings : " << Log->GetWarnings() << std::endl;
summary << "Errors : " << Log->GetErrors() << std::endl;
summary << "Deleted Agents : " << Log->GetDeletedAgents() << std::endl;
Log->Write(summary.str().c_str());
//force an output to the screen if the log is not the standard output
......
......@@ -105,6 +105,7 @@ bool GCFMModel::Init (Building* building)
//a destination could not be found for that pedestrian
if (ped->FindRoute() == -1) {
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
p--;
peds_size--;
continue;
......@@ -122,7 +123,7 @@ bool GCFMModel::Init (Building* building)
"dist to target is 0\n");
return false;
}
ped->InitV0(target);
ped->InitV0(target);
JEllipse E = ped->GetEllipse();
E.SetCosPhi(cosPhi);
E.SetSinPhi(sinPhi);
......@@ -145,7 +146,7 @@ void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui
int partSize;
partSize = ((int)nSize > nThreads)? (int) (nSize / nThreads):(int)nSize;
if(partSize == (int)nSize)
nThreads = 1; // not worthy to parallelize
nThreads = 1; // not worthy to parallelize
int debugPed = -10;
//building->GetGrid()->HighlightNeighborhood(debugPed, building);
......@@ -155,7 +156,7 @@ void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui
result_acc.reserve(2200);
const int threadID = omp_get_thread_num();
int start = threadID*partSize;
int end;
end = (threadID < nThreads - 1) ? (threadID + 1) * partSize - 1: (int) (nSize - 1);
......@@ -176,6 +177,7 @@ void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current, periodic);
// remove the pedestrian and abort
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
Log->Write("\tERROR: one ped was removed due to high velocity");
//exit(EXIT_FAILURE);
}
......@@ -489,7 +491,7 @@ inline Point GCFMModel::ForceRepWall(Pedestrian* ped, const Line& w) const
}
return F; //line --> l != 0
}
/* abstoßende Punktkraft zwischen ped und Punkt p
......@@ -509,7 +511,7 @@ Point GCFMModel::ForceRepStatPoint(Pedestrian* ped, const Point& p, double l, do
Point dist = p - ped->GetPos(); // x- and y-coordinate of the distance between ped and p
double d = dist.Norm(); // distance between the centre of ped and point p
Point e_ij; // x- and y-coordinate of the normalized vector between ped and p
double tmp;
double bla;
Point r;
......@@ -534,7 +536,7 @@ Point GCFMModel::ForceRepStatPoint(Pedestrian* ped, const Point& p, double l, do
//interpolierte Kraft
// double a = 6., b= 25.;
// double dist_eff = d - (r - E.GetCenter()).Norm();
// double dist_eff = d - (r - E.GetCenter()).Norm();
// if(ped->GetID() == -9 )
// printf("dist=%f\n", dist_eff);
......
......@@ -107,6 +107,7 @@ bool GompertzModel::Init(Building *building) {
Log->Write(
"ERROR:\tGompertzModel::Init() cannot initialise route. ped %d is deleted.\n", ped->GetID());
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
--p;
--peds_size;
continue;
......@@ -147,7 +148,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building
int partSize;
partSize = ((int)nSize > nThreads)? (int) (nSize / nThreads):(int)nSize;
if(partSize == (int)nSize)
nThreads = 1; // not worthy to parallelize
nThreads = 1; // not worthy to parallelize
#pragma omp parallel default(shared) num_threads(nThreads)
{
......@@ -175,6 +176,7 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building
// remove the pedestrian and abort
Log->Write("\tERROR: ped [%d] was removed due to high velocity", ped->GetID());
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
//continue; //FIXME tolerate first
exit(EXIT_FAILURE);
}
......@@ -565,4 +567,3 @@ double GompertzModel::GetbWall() const {
double GompertzModel::GetcWall() const {
return _cWall;
}
......@@ -228,6 +228,7 @@ void GradientModel::ComputeNextTimeStep(double current, double deltaT, Building*
// remove the pedestrian and abort
Log->Write("\tERROR: ped [%d] was removed due to high velocity",ped->GetID());
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
//continue; //FIXME tolerate first
exit(EXIT_FAILURE);
}
......@@ -641,4 +642,3 @@ double GradientModel::GetcWall() const
{
return _cWall;
}
......@@ -105,6 +105,7 @@ bool KrauszModel::Init (Building* building)
//a destination could not be found for that pedestrian
if (ped->FindRoute() == -1) {
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
--p;
--peds_size;
continue;
......@@ -176,6 +177,7 @@ void KrauszModel::ComputeNextTimeStep(double current, double deltaT, Building* b
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current, periodic);
// remove the pedestrian and abort
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
Log->Write("\tERROR: one ped was removed due to high velocity");
//exit(EXIT_FAILURE);
}
......
......@@ -109,6 +109,7 @@ bool VelocityModel::Init (Building* building)
Log->Write(
"ERROR:\tVelocityModel::Init() cannot initialise route. ped %d is deleted in Room %d %d.\n",ped->GetID(), ped->GetRoomID(), ped->GetSubRoomID());
building->DeletePedestrian(ped);
Log->incrementDeletedAgents();
p--;
peds_size--;
continue;
......@@ -252,6 +253,7 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
size == 0 ) // size length of peds neighbour vector
{
Log->Write("WARNING:\tped %d with vmean %f has been deleted in room [%i]/[%i] after time %f s (current=%f\n", ped->GetID(), ped->GetMeanVelOverRecTime(), ped->GetRoomID(), ped->GetSubRoomID(), ped->GetGlobalTime(), current);
Log->incrementDeletedAgents();
#pragma omp critical(VelocityModel_ComputeNextTimeStep_pedsToRemove)
pedsToRemove.push_back(ped);
}
......
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