Commit da927a2e authored by Mohcine Chraibi's avatar Mohcine Chraibi

Reorder initialisations in Pedestrian

and silence some warnings
parent 32de34d5
......@@ -116,7 +116,7 @@ string TrajectoriesJPSV04::WritePed(Pedestrian* ped)
void TrajectoriesJPSV04::WriteHeader(long nPeds, double fps, Building* building, int seed)
{
//nPeds=building->GetAllPedestrians().size();
building->GetCaption();
string tmp;
tmp =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" "<trajectories>\n";
......@@ -446,7 +446,7 @@ void TrajectoriesVTK::WriteFooter()
void TrajectoriesJPSV06::WriteHeader(long nPeds, double fps, Building* building, int seed)
{
//nPeds=building->GetAllPedestrians().size();
building->GetCaption();
string tmp;
tmp =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" "<trajectories>\n";
......@@ -600,7 +600,7 @@ void TrajectoriesXML_MESH::WriteGeometry(Building* building)
void TrajectoriesJPSV05::WriteHeader(long nPeds, double fps, Building* building, int seed)
{
//nPeds=building->GetAllPedestrians().size();
building->GetCaption();
string tmp;
tmp = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" "<trajectories>\n";
char agents[CLENGTH] = "";
......
This diff is collapsed.
......@@ -61,12 +61,12 @@ class Configuration;
class Building {
private:
const Configuration* _configuration;
std::shared_ptr<RoutingEngine> _routingEngine;
std::string _caption;
std::string _geometryFilename;
std::shared_ptr<RoutingEngine> _routingEngine;
LCGrid* _linkedCellGrid;
std::vector<Pedestrian*> _allPedestians;
std::map<int, std::shared_ptr<Room> > _rooms;
std::map<int, Crossing*> _crossings;
std::map<int, Transition*> _transitions;
......@@ -228,7 +228,7 @@ public:
* @param filename the relative location of the file
* @return true if everything went fine.
*/
bool SaveGeometry(const std::string& filename);
// bool SaveGeometry(const std::string& filename);
void WriteToErrorLog() const;
......@@ -247,7 +247,6 @@ public:
private:
void StringExplode(std::string str, std::string separator, std::vector<std::string>* results);
const Configuration* _configuration;
};
#endif /* _BUILDING_H */
......@@ -12,7 +12,7 @@ public:
virtual void LoadBuilding(Building* building) = 0;
virtual bool LoadTrafficInfo(Building* building) = 0;
virtual ~GeometryReader(){};
};
#endif //JPSCORE_GEOMETRYREADER_H
......@@ -852,12 +852,12 @@ string NormalSubRoom::WriteSubRoom() const
s.append("\t\t</wall>\n");
}
const Point& pos = obst->GetCentroid();
const Point& obst_pos = obst->GetCentroid();
//add the obstacle caption
char tmp1[CLENGTH];
sprintf(tmp1, "\t\t<label centerX=\"%.2f\" centerY=\"%.2f\" centerZ=\"%.2f\" text=\"%d\" color=\"100\" />\n"
, pos._x * FAKTOR, pos._y * FAKTOR,GetElevation(pos)*FAKTOR ,obst->GetId());
, obst_pos._x * FAKTOR, obst_pos._y * FAKTOR,GetElevation(obst_pos)*FAKTOR ,obst->GetId());
s.append(tmp1);
}
......
......@@ -47,7 +47,7 @@
<!--persons information and distribution -->
<agents operational_model_id="3">
<agents_distribution>
<group group_id="1" agent_parameter_id="1" room_id="0" subroom_id="2" number="60" goal_id="0" router_id="1" />
<group group_id="1" agent_parameter_id="1" room_id="0" subroom_id="2" number="5" goal_id="0" router_id="1" />
</agents_distribution>
<!-- frequency in persons/minute -->
......@@ -98,8 +98,8 @@
<stepsize>0.01</stepsize>
<exit_crossing_strategy>3</exit_crossing_strategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped a="5" D="0.1"/>
<force_wall a="5" D="0.1"/>
<force_ped a="6" D="0.15"/>
<force_wall a="7" D="0.14"/>
</model_parameters>
<agent_parameters agent_parameter_id="1">
<v0 mu="1.34" sigma="0.001" />
......
......@@ -174,8 +174,8 @@ void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui
double tmp = (ped->GetV0Norm() + delta) * (ped->GetV0Norm() + delta);
if (normVi > tmp && ped->GetV0Norm() > 0) {
fprintf(stderr, "GCFMModel::calculateForce() WARNING: actual velocity (%f) of iped %d "
"is bigger than desired velocity (%f) at time: %fs\n",
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current);
"is bigger than desired velocity (%f) at time: %fs (periodic=%d)\n",
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current, periodic);
// remove the pedestrian and abort
building->DeletePedestrian(ped);
Log->Write("\tERROR: one ped was removed due to high velocity");
......@@ -188,8 +188,8 @@ void GCFMModel::ComputeNextTimeStep(double current, double deltaT, Building* bui
//if(ped->GetID()==61) building->GetGrid()->HighlightNeighborhood(ped,building);
vector<SubRoom*> emptyVector;
int nSize=neighbours.size();
for (int i = 0; i < nSize; i++) {
int neighborsSize = neighbours.size();
for (int i = 0; i < neighborsSize; i++) {
Pedestrian* ped1 = neighbours[i];
Point p1 = ped->GetPos();
Point p2 = ped1->GetPos();
......@@ -275,7 +275,6 @@ inline Point GCFMModel::ForceDriv(Pedestrian* ped, Room* room) const
const Point& v0 = ped->GetV0(target);
F_driv = ((v0 * ped->GetV0Norm() - ped->GetV()) * ped->GetMass()) / ped->GetTau();
} else {
const Point& v0 = ped->GetV0();
F_driv = ((lastE0 * ped->GetV0Norm() - ped->GetV()) * ped->GetMass()) / ped->GetTau();
ped->SetLastE0(lastE0);
}
......@@ -401,10 +400,10 @@ Point GCFMModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const
F_rep = ep12 * px;
}
if (F_rep._x != F_rep._x || F_rep._y != F_rep._y) {
char tmp[CLENGTH];
sprintf(tmp, "\nNAN return ----> p1=%d p2=%d Frepx=%f, Frepy=%f\n", ped1->GetID(),
char tmp1[CLENGTH];
sprintf(tmp1, "\nNAN return ----> p1=%d p2=%d Frepx=%f, Frepy=%f\n", ped1->GetID(),
ped2->GetID(), F_rep._x, F_rep._y);
Log->Write(tmp);
Log->Write(tmp1);
Log->Write("ERROR:\t fix this as soon as possible");
printf("K_ij=%f\n", K_ij);
//return Point(0,0); // FIXME: should never happen
......
......@@ -173,8 +173,8 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building
double HighVel = (ped->GetV0Norm() + delta) * (ped->GetV0Norm() + delta); //(v0+delta)^2
if (normVi > HighVel && ped->GetV0Norm() > 0) {
fprintf(stderr, "GompertzModel::calculateForce_LC() WARNING: actual velocity (%f) of iped %d "
"is bigger than desired velocity (%f) at time: %fs\n",
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current);
"is bigger than desired velocity (%f) at time: %fs (periodic=%d)\n",
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current, periodic);
// remove the pedestrian and abort
Log->Write("\tERROR: ped [%d] was removed due to high velocity", ped->GetID());
......
......@@ -210,8 +210,8 @@ void GradientModel::ComputeNextTimeStep(double current, double deltaT, Building*
double HighVel = (ped->GetV0Norm() + delta) * (ped->GetV0Norm() + delta); //(v0+delta)^2
if (normVi > HighVel && ped->GetV0Norm() > 0) { //@todo: ar.graf disabled check
fprintf(stderr, "GradientModel::calculateForce_LC() WARNING: actual velocity (%f) of iped %d "
"is bigger than desired velocity (%f) at time: %fs\n",
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current);
"is bigger than desired velocity (%f) at time: %fs (periodic=%d)\n",
sqrt(normVi), ped->GetID(), ped->GetV0Norm(), current, periodic);
// remove the pedestrian and abort
Log->Write("\tERROR: ped [%d] was removed due to high velocity",ped->GetID());
......
......@@ -33,13 +33,13 @@
using namespace std;
ODESolver::ODESolver(ForceModel *model) : model(model)
ODESolver::ODESolver(ForceModel *tmodel) : model(tmodel)
{
}
EulerSolver::EulerSolver(ForceModel *model) : ODESolver(model)
EulerSolver::EulerSolver(ForceModel *tmodel) : ODESolver(tmodel)
{
}
......
......@@ -42,7 +42,7 @@ class ODESolver {
protected:
ForceModel *model;
public:
ODESolver(ForceModel* model);
ODESolver(ForceModel* tmodel);
virtual ~ODESolver() {};
virtual void solveODE(double t, double tp, Building* building) const = 0;
};
......@@ -54,7 +54,7 @@ public:
class EulerSolver : public ODESolver {
public:
EulerSolver(ForceModel *model);
EulerSolver(ForceModel *tmodel);
virtual void solveODE(double t, double tp, Building* building) const;
};
......
......@@ -146,7 +146,6 @@ bool VelocityModel::Init (Building* building)
void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic)
{
double delta = 0.5;
// collect all pedestrians in the simulation.
const vector< Pedestrian* >& allPeds = building->GetAllPedestrians();
......@@ -187,10 +186,6 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
//if they are in the same subroom
Point p1 = ped->GetPos();
Point p2 = ped1->GetPos();
// if(ped->GetID() == -1){
// printf("---\nid: %d\t (%f), ped1 %d\t pos1 %f %f\n", threadID, ped->GetGlobalTime(), ped->GetID(), p1._x, p1._y);
// printf("id: %d\t (%f), ped2 %d\t pos2 %f %f\n---\n", threadID, ped1->GetGlobalTime(), ped1->GetID(), p2._x, p2._y);
// }
//subrooms to consider when looking for neighbour for the 3d visibility
vector<SubRoom*> emptyVector;
emptyVector.push_back(subroom);
......@@ -245,7 +240,7 @@ void VelocityModel::ComputeNextTimeStep(double current, double deltaT, Building*
// stuck peds get removed. Warning is thrown. low speed due to jam is omitted.
if(ped->GetGlobalTime() > 30 + ped->GetPremovementTime()&& ped->GetMeanVelOverRecTime() < 0.01 && 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\n", ped->GetID(), ped->GetMeanVelOverRecTime(), ped->GetRoomID(), ped->GetSubRoomID(), ped->GetGlobalTime());
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);
building->DeletePedestrian(ped);
}
......@@ -321,6 +316,7 @@ double VelocityModel::OptimalSpeed(Pedestrian* ped, double spacing, double winke
speed = (speed>0)?speed:0;
speed = (speed<v0)?speed:v0;
// (1-winkel)*speed;
//todo use winkel
return speed;
}
......
......@@ -45,75 +45,85 @@ AgentColorMode Pedestrian::_colorMode=BY_VELOCITY;
Pedestrian::Pedestrian()
{
_roomID = -1;
_subRoomID = -1;
_subRoomUID = -1;
_oldRoomID = -1;
_oldSubRoomID = -1;
_ticksInThisRoom = 0;
_exitIndex = -1;
_id = _agentsCreated;//default id
_exitIndex = -1;
_group = -1;
_desiredFinalDestination = FINAL_DEST_OUT;
_height = 170;
_age = 30;
_premovement = 0;
_riskTolerance = 0;
_gender = "female";
_mass = 1;
_tau = 0.5;
_T = 1.0;
_newOrientationFlag = false;
_newOrientationDelay = 0; //0 seconds, in steps
_tmpFirstOrientation = true;
_turninAngle = 0.0;
_ellipse = JEllipse();
//_navLine = new NavLine(); //FIXME? argraf : rather nullptr and Setter includes correct uid (done below)
_navLine = nullptr;
_router = NULL;
_building = NULL;
_reroutingThreshold = 0.0; // new orientation after 10 seconds, value is incremented
_timeBeforeRerouting = 0.0;
_reroutingEnabled = false;
_timeInJam = 0.0;
_patienceTime = 5.0;// time after which the ped feels to be in jam
_desiredFinalDestination = FINAL_DEST_OUT;
_mentalMap = map<int, int>();
_destHistory = vector<int>();
_deltaT = 0.01;
_updateRate = _deltaT;
_ellipse = JEllipse();
_V0 = Point(0,0);
_lastPosition = Point(0,0);
_lastCellPosition = -1;
_recordingTime = 20; //seconds
//_knownDoors = map<int, NavLineState>();
_knownDoors.clear();
_height = 170;
_age = 30;
_gender = "male";
_trip = vector<int> ();
_group = -1;
_spotlight = false;
_V0UpStairs=0.6;
_V0DownStairs=0.6;
_EscalatorUpStairs=0.8;
_EscalatorDownStairs=0.8;
_V0IdleEscalatorUpStairs=0.6;
_V0IdleEscalatorDownStairs=0.6;
_roomCaption = "";
_roomID = -1;
_subRoomID = -1;
_subRoomUID = -1;
_oldRoomID = -1;
_oldSubRoomID = -1;
_lastE0 = Point(0,0);
_navLine = nullptr;
_mentalMap = map<int, int>();
_destHistory = vector<int>();
_trip = vector<int> ();
_lastPosition = Point(0,0);
_lastCellPosition = -1;
_knownDoors.clear();
_distToBlockade=0.0;
_reroutingThreshold = 0.0; // new orientation after 10 seconds, value is incremented
_timeBeforeRerouting = 0.0;
_timeInJam = 0.0;
_patienceTime = 5.0;// time after which the ped feels to be in jam
_recordingTime = 20; //seconds
//_lastPosition;
//_lastVelocities
_routingStrategy=ROUTING_GLOBAL_SHORTEST;
_lastE0 = Point(0,0);
_newOrientationDelay = 0; //0 seconds, in steps
_updateRate = _deltaT;
_turninAngle = 0.0;
_reroutingEnabled = false;
_tmpFirstOrientation = true;
_newOrientationFlag = false;
_router = NULL;
_building = NULL;
//_knownDoors = map<int, NavLineState>();
_spotlight = false;
_ticksInThisRoom = 0;
_agentsCreated++;//increase the number of object created
}
Pedestrian::Pedestrian(const StartDistribution& agentsParameters, Building& building)
: _age(agentsParameters.GetAge()),
_gender(agentsParameters.GetGender()),
_height(agentsParameters.GetHeight()),
_desiredFinalDestination(agentsParameters.GetGoalId()),
:
_group(agentsParameters.GetGroupId()),
_building(&building),
_router(building.GetRoutingEngine()->GetRouter(agentsParameters.GetRouterId())),
_lastPosition(),
_roomID(agentsParameters.GetRoomId()),
_desiredFinalDestination(agentsParameters.GetGoalId()),
_height(agentsParameters.GetHeight()),
_age(agentsParameters.GetAge()),
_premovement(agentsParameters.GetPremovementTime()),
_gender(agentsParameters.GetGender()),
_roomCaption(""),
_roomID(agentsParameters.GetRoomId()),
_subRoomID(agentsParameters.GetSubroomID()),
_subRoomUID(building.GetRoom(_roomID)->GetSubRoom(_subRoomID)->GetUID()),
_lastPosition(),
_patienceTime(agentsParameters.GetPatience()),
_premovement(agentsParameters.GetPremovementTime()),
_router(building.GetRoutingEngine()->GetRouter(agentsParameters.GetRouterId())),
_building(&building),
_ticksInThisRoom(0)
{
}
......@@ -442,7 +452,7 @@ double Pedestrian::GetV0Norm() const
//-----------------------------------------
const Point& pos = GetPos();
// const Point& pos = GetPos();
// double distanceToTarget = (target-pos).Norm();
// double iniDistanceToTarget = (target-_lastPositions.front()).Norm();
......
......@@ -543,8 +543,8 @@ void DirectionLocalFloorfield::Init(Building* buildingArg, double stepsize,
targets.emplace_back(pair.second);
}
}
std::string filename = "floorfield" + std::to_string(roomNr) + ".vtk";
locffviafm[roomNr]->writeFF(filename, targets);
std::string lfilename = "floorfield" + std::to_string(roomNr) + ".vtk";
locffviafm[roomNr]->writeFF(lfilename, targets);
}
......
......@@ -1123,9 +1123,9 @@ void GlobalRouter::WriteGraphGV(string filename, int finalDestination,
{
int to_door = to_AP->GetID();
int room_id = to_AP->GetConnectingRoom1();
int lroom_id = to_AP->GetConnectingRoom1();
if (IsElementInVector(rooms_ids, room_id) == false)
if (IsElementInVector(rooms_ids, lroom_id) == false)
continue;
graph_file << from_door << " -> " << to_door << " [ label="
......
......@@ -667,7 +667,7 @@ int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
}
int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const
int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* vvalue ) const
{
const TiXmlAttribute* node = attributeSet.Find( name );
if ( !node )
......@@ -675,7 +675,7 @@ int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) co
int ival = 0;
int result = node->QueryIntValue( &ival );
*value = (unsigned)ival;
*vvalue = (unsigned)ival;
return result;
}
......
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