Commit d4c5734f authored by Ulrich Kemloh's avatar Ulrich Kemloh

Olny update the position when the velocity is above a threshold

fixed mismatching distributed number of pedestrians when using sources
parent 1cd14921
......@@ -125,9 +125,6 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
int partSize;
partSize = (int) (nSize / nThreads);
//int debugPed = -69;//10;
//building->GetGrid()->HighlightNeighborhood(-9, building);
#pragma omp parallel default(shared) num_threads(nThreads)
{
......@@ -147,15 +144,6 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
Room* room = building->GetRoom(ped->GetRoomID());
SubRoom* subroom = room->GetSubRoom(ped->GetSubRoomID());
// if(debugPed != ped->GetID())
// {
// Point p1 = ped->GetPos();
// Point p2 = ped->GetPos();
// fprintf(stderr, "%f %f %f %f %f %d %d %d\n", time, p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY(), -1, ped->GetID(), ped->GetID());
// }
double normVi = ped->GetV().ScalarProduct(ped->GetV()); //squared
double HighVel = (ped->GetV0Norm() + delta) * (ped->GetV0Norm() + delta); //(v0+delta)^2
if (normVi > HighVel && ped->GetV0Norm() > 0) {
......@@ -173,28 +161,11 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
Point repPed = Point(0,0);
vector<Pedestrian*> neighbours;
building->GetGrid()->GetNeighbourhood(ped,neighbours);
//if(ped->GetID()==61) building->GetGrid()->HighlightNeighborhood(ped,building);
int size = (int) neighbours.size();
// double B_ij=0;
// int count_Bij=0;
// if(debugPed == ped->GetID())
// {
// printf("\n\n nsiZe=%d\n",size);
// }
for (int i = 0; i < size; i++) {
Pedestrian* ped1 = neighbours[i];
//-------------- TESTING ---------
// Point distp12 = ped1->GetPos() - ped->GetPos();
// double Distance = distp12.Norm();
// double tmp;
// tmp = 1.0 - Distance/(0.25 + 0.25);
// B_ij += exp(-_bPed*exp(-_cPed*tmp));
// if (B_ij > J_EPS)
// count_Bij += 1;
//--------------------------------
//if they are in the same subroom
Point p1 = ped->GetPos();
Point p2 = ped1->GetPos();
......@@ -207,12 +178,6 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
bool isVisible = building->IsVisible(p1, p2, emptyVector, false);
if (!isVisible)
continue;
// if(debugPed == ped->GetID())
// {
// fprintf(stderr, "%f %f %f %f %f %d %d %d\n", current, p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY(), isVisible, ped->GetID(), ped1->GetID());
// printf("t=%.2f, ped:%d ped1:%d p1(%.2f, %.2f), p2(%.2f, %.2f) isVisibile = %d\n", current, ped->GetID(), ped1->GetID(), p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY(), isVisible);
// }
if (ped->GetUniqueRoomID() == ped1->GetUniqueRoomID()) {
repPed = repPed + ForceRepPed(ped, ped1);
} else {
......@@ -228,11 +193,6 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
Point fd = ForceDriv(ped, room);
Point acc = (fd + repPed + repWall) / ped->GetMass();
// if(1 || ped->GetID() == 976 ) {
// printf("Pos1 =[%f, %f]\n", ped->GetPos().GetX(), ped->GetPos().GetY());
// printf("acc= %f %f, fd= %f, %f, repPed = %f %f, repWall= %f, %f\n", acc.GetX(), acc.GetY(), fd.GetX(), fd.GetY(), repPed.GetX(), repPed.GetY(), repWall.GetX(), repWall.GetY());
// getc(stdin);
// }
result_acc.push_back(acc);
}
......@@ -241,40 +201,32 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
for (int p = start; p <= end; ++p) {
Pedestrian* ped = allPeds[p];
Point vToAdd = result_acc[p - start] * deltaT;
//----------------- update new pos and new vel -----------------
Point v_neu = ped->GetV() + vToAdd;
// printf("v_neu=[%f, %f], v=[%f, %f], toAdd=[%f, %f]\n", v_neu.GetX(), v_neu.GetY(), ped->GetV().GetX(), ped->GetV().GetY(), vToAdd.GetX(), vToAdd.GetY());
// if(ped->GetID() == 2 )
// v_neu = Point(0,0);
Point v_neu = ped->GetV() + result_acc[p - start] * deltaT;
Point pos_neu = ped->GetPos() + v_neu * deltaT;
//---------------------------------------------------------------
if(v_neu.Norm() > ped->GetV0Norm()+0.2 ) { // Stop pedestrians
if( (v_neu.Norm() > ped->GetV0Norm()+0.2 )) { // Stop pedestrians if the velocity is too high
Log->Write("WARNING: \tped %d is stopped because v=%f (v0=%f)", ped->GetID(), v_neu.Norm(), ped->GetV0Norm());
v_neu = v_neu*0.01;
pos_neu = ped->GetPos();
}
// //--------------------------------------------------------------------------------------------------
// //Jam is based on the current velocity
//Jam is based on the current velocity
if ( v_neu.Norm() >= ped->GetV0Norm()*0.5) {
ped->ResetTimeInJam();
} else {
ped->UpdateTimeInJam();
}
//--------------------------------------------------------------------------------------------------
//fprintf(stderr, "\n----\n%f %f %f %f %f %f\n----\n",ped->GetV().GetX(), ped->GetV().GetY(), ped->GetV0().GetX(),ped->GetV0().GetY(), ped->GetPos().GetX(), ped->GetPos().GetY());
ped->SetPos(pos_neu);
//only update the position if the velocity is above a threshold
if (v_neu.Norm() >= J_EPS_V*0.7)
{
ped->SetPos(pos_neu);
ped->SetPhiPed();
}
ped->SetV(v_neu);
ped->SetPhiPed();
// if(ped->GetID() == 976 ) {
// printf("toadd [%f, %f] m=%f\n", vToAdd.GetX(), vToAdd.GetY(), ped->GetMass());
// printf("pos_neu= %f %f v_neu %f %f\n", pos_neu.GetX(), pos_neu.GetY(), v_neu.GetX(), v_neu.GetY());
// }
}
}//end parallel
}
......
......@@ -362,7 +362,7 @@ bool PedDistributor::Distribute(Building* building) const
for(int i=0;i<source->GetMaxAgents();i++)
{
//source->AddToPool(dist->GenerateAgent(building, &pid,emptyPositions));
nPeds_is++;
//nPeds_is++;
}
}
}
......@@ -375,7 +375,7 @@ bool PedDistributor::Distribute(Building* building) const
for(int i=0;i<source->GetMaxAgents();i++)
{
//source->AddToPool(dist->GenerateAgent(building, &pid,emptyPositions));
nPeds_is++;
//nPeds_is++;
}
}
}
......
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