Commit f9063e2d authored by Ulrich Kemloh's avatar Ulrich Kemloh

Refactoring

parent 763139dc
......@@ -218,8 +218,8 @@ set ( source_files
routing/cognitive_map/sensor/JamSensor.cpp
routing/cognitive_map/sensor/LastDestinationsSensor.cpp
routing/cognitive_map/sensor/SmokeSensor.cpp
routing/cognitive_map/fire_mesh/firemesh.cpp
routing/cognitive_map/fire_mesh/knot.cpp
routing/cognitive_map/fire_mesh/FireMesh.cpp
routing/cognitive_map/fire_mesh/Knot.cpp
poly2tri/common/shapes.cpp
poly2tri/sweep/sweep_context.cpp
......
<?xml version="1.0" encoding="UTF-8" ?>
<JuPedSim project="JPS-Project" version="0.6"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<JuPedSim project="JPS-Project" version="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<!-- seed used for initialising random generator -->
<seed>12542</seed>
<max_sim_time>900</max_sim_time>
<max_sim_time>900</max_sim_time>
<!-- geometry file -->
<geometry>smokesensortest.xml</geometry>
<!-- trajectories file and format -->
......@@ -21,49 +19,49 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<!-- traffic information: e.g closed doors or smoked rooms -->
<traffic_constraints>
<!-- room states are: good or smoked -->
<!-- <rooms> -->
<!-- <room room_id="0" state="good" /> -->
<!-- </rooms> -->
<!-- <rooms> -->
<!-- <room room_id="0" state="good" /> -->
<!-- </rooms> -->
<!-- doors states are: close or open -->
<doors>
<!--door trans_id="1" caption="" state="open" />
<door trans_id="2" caption="" state="open" /-->
<door trans_id="2" caption="" state="open" / -->
</doors>
</traffic_constraints>
<routing>
<!--goals>
<goal id="0" final="false" caption="goal 1">
<polygon>
<vertex px="-1.0" py="5.0" />
<vertex px="-1.0" py="6.5" />
<vertex px="-2.0" py="6.5" />
<vertex px="-2.0" py="5.0" />
<vertex px="-1.0" py="5.0" />
</polygon>
<polygon>
<vertex px="-1.0" py="5.0" />
<vertex px="-1.0" py="6.5" />
<vertex px="-2.0" py="6.5" />
<vertex px="-2.0" py="5.0" />
<vertex px="-1.0" py="5.0" />
</polygon>
</goal>
<goal id="1" final="false" caption="goal 2">
<polygon>
<vertex px="24.0" py="6.5" />
<vertex px="23.0" py="6.5" />
<vertex px="23.0" py="5.0" />
<vertex px="24.0" py="5.0" />
<vertex px="24.0" py="6.5" />
</polygon>
<polygon>
<vertex px="24.0" py="6.5" />
<vertex px="23.0" py="6.5" />
<vertex px="23.0" py="5.0" />
<vertex px="24.0" py="5.0" />
<vertex px="24.0" py="6.5" />
</polygon>
</goal>
</goals-->
</goals -->
<!-- in the form goal_id1:goal_id2:goal_id3:..:goal_idn -->
<!-- <routes> -->
<!-- <route id="1">0:1:0:1:0:1:2</route> -->
<!-- <route id="2">0:1:0:1:2</route> -->
<!-- </routes> -->
<!-- <routes> -->
<!-- <route id="1">0:1:0:1:0:1:2</route> -->
<!-- <route id="2">0:1:0:1:2</route> -->
<!-- </routes> -->
</routing>
<!--persons information and distribution -->
<agents operational_model_id="1">
<agents_distribution>
<group group_id="1" agent_parameter_id="1" room_id="0" subroom_id="0" number="50" router_id="7" />
<group group_id="1" agent_parameter_id="1" room_id="0" subroom_id="0" number="50" router_id="7" />
</agents_distribution>
</agents>
......@@ -71,22 +69,23 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<!-- These parameters may be overwritten -->
<operational_models>
<model operational_model_id="1" description="gcfm">
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exitCrossingStrategy>4</exitCrossingStrategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="0.3" dist_max="3" disteff_max="2" interpolation_width="0.1" />
<force_wall nu="0.2" dist_max="3" disteff_max="2" interpolation_width="0.1" />
<model_parameters>
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exit_crossing_strategy>4</exit_crossing_strategy>
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="0.3" dist_max="3" disteff_max="2" interpolation_width="0.1" />
<force_wall nu="0.2" dist_max="3" disteff_max="2" interpolation_width="0.1" />
</model_parameters>
<agent_parameters agent_parameter_id="1">
<v0 mu="1.24" sigma="0.001" />
<bmax mu="0.25" sigma="0.001" />
<bmin mu="0.20" sigma="0.001" />
<amin mu="0.18" sigma="0.001" />
<tau mu="0.5" sigma="0.001" />
<atau mu="0.5" sigma="0.001" />
</agent_parameters>
<agent_parameters agent_parameter_id="1">
<v0 mu="1.24" sigma="0.001" />
<bmax mu="0.25" sigma="0.001" />
<bmin mu="0.20" sigma="0.001" />
<amin mu="0.18" sigma="0.001" />
<tau mu="0.5" sigma="0.001" />
<atau mu="0.5" sigma="0.001" />
</agent_parameters>
</model>
</operational_models>
......@@ -99,13 +98,13 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
</parameters>
</router>
<router router_id="7" description="cognitive_map">
<sensors>
<sensor sensor_id="1" description="Smoke" status="activated"/>
</sensors>
<cognitive_map status="complete"/>
<sensors>
<sensor sensor_id="1" description="Smoke" status="activated" potentialfile="./"/>
</sensors>
<cognitive_map status="complete" />
<!--parameters>
<navigation_lines file="routing.xml" />
</parameters-->
</parameters -->
</router>
</route_choice_models>
......
......@@ -47,21 +47,21 @@ std::vector<std::string> &split(const std::string &s, char delim, std::vector<st
FireMesh::FireMesh()
{
//statHeaderRead=false;
statMesh=false;
_statMesh=false;
}
FireMesh::FireMesh(const double &xmin, const double &ymin, const double &xmax, const double &ymax, const int &cellsize)
{
setUpMesh(xmin,ymin,xmax,ymax,cellsize);
GetUpMesh(xmin,ymin,xmax,ymax,cellsize);
//statHeaderRead=false;
statMesh=false;
_statMesh=false;
}
FireMesh::FireMesh(const std::string &filename)
{
setKnotValuesFromFile(filename);
SetKnotValuesFromFile(filename);
//statHeaderRead=false;
statMesh=false;
_statMesh=false;
}
......@@ -70,7 +70,7 @@ FireMesh::~FireMesh()
}
void FireMesh::setUpMesh(const double &xmin, const double &ymin, const double &xmax, const double &ymax, const int &cellsize)
void FireMesh::GetUpMesh(const double &xmin, const double &ymin, const double &xmax, const double &ymax, const int &cellsize)
{
_cellsize=cellsize;
......@@ -95,7 +95,7 @@ void FireMesh::setUpMesh(const double &xmin, const double &ymin, const double &x
{
for (int j=0; j<_matrix[0].size(); ++j)
{
knot k(xmin+i*cellsize, j*cellsize);
Knot k(xmin+i*cellsize, j*cellsize);
_matrix[i][j]=k;
}
}
......@@ -104,13 +104,13 @@ void FireMesh::setUpMesh(const double &xmin, const double &ymin, const double &x
}
const Matrix &FireMesh::getMesh() const
const Matrix &FireMesh::GetMesh() const
{
return _matrix;
}
double FireMesh::getKnotValue(const double &x, const double &y) const
double FireMesh::GetKnotValue(const double &x, const double &y) const
{
double restx;
double resty;
......@@ -163,11 +163,11 @@ double FireMesh::getKnotValue(const double &x, const double &y) const
row=0;
}
return _matrix[row][col].getValue();
return _matrix[row][col].GetValue();
}
void FireMesh::setKnotValuesFromFile(const std::string &filename)
void FireMesh::SetKnotValuesFromFile(const std::string &filename)
{
///open File (reading)
std::ifstream pFile(filename);
......@@ -195,7 +195,7 @@ void FireMesh::setKnotValuesFromFile(const std::string &filename)
strVec.clear();
//std::cout << xmin << ymin << xmax << ymax << std::endl;
setUpMesh(xmin,ymin,xmax,ymax,cellsize);
GetUpMesh(xmin,ymin,xmax,ymax,cellsize);
//statHeaderRead=true;
//}
......@@ -209,7 +209,7 @@ void FireMesh::setKnotValuesFromFile(const std::string &filename)
for (auto &elem : strVec)
{
//std::cout << elem << std::endl;
_matrix[m][n].setValue(std::stod(elem));
_matrix[m][n].SetValue(std::stod(elem));
++n;
}
strVec.clear();
......@@ -217,18 +217,20 @@ void FireMesh::setKnotValuesFromFile(const std::string &filename)
}
pFile.close();
statMesh=true;
_statMesh=true;
}
else
std::cout << "Unable to open file";
{
Log->Write("ERROR:\Could not open potential file: %s",filename.c_str());
//return false;
exit(EXIT_FAILURE);
}
}
bool FireMesh::statusMesh() const
{
return statMesh;
return _statMesh;
}
......
......@@ -32,11 +32,13 @@
#include <vector>
#include <string>
#include "knot.h"
#include "../../../IO/OutputHandler.h"
//using Matrix = std::array<std::array<T, COL>, ROW>;
//log output
extern OutputHandler* Log;
using Matrix = std::vector<std::vector<knot>>;
using Matrix = std::vector<std::vector<Knot>>;
class FireMesh
{
......@@ -46,15 +48,14 @@ public:
FireMesh(const std::string &filename);
~FireMesh();
void setUpMesh(const double &xmin, const double &ymin, const double &xmax, const double &ymax, const int &cellsize);
const Matrix &getMesh() const;
void GetUpMesh(const double &xmin, const double &ymin, const double &xmax, const double &ymax, const int &cellsize);
const Matrix &GetMesh() const;
double getKnotValue(const double &x, const double &y) const;
void setKnotValuesFromFile(const std::string &filename);
double GetKnotValue(const double &x, const double &y) const;
void SetKnotValuesFromFile(const std::string &filename);
bool statusMesh() const;
private:
Matrix _matrix;
int _cellsize;
......@@ -62,9 +63,7 @@ private:
double _xmax;
double _ymin;
double _ymax;
//bool statHeaderRead;
bool statMesh;
bool _statMesh;
};
......
#include "knot.h"
knot::knot()
Knot::Knot()
{
}
knot::knot(const double &x, const double &y, const double &value)
Knot::Knot(const double &x, const double &y, const double &value)
{
_x=x;
_y=y;
......@@ -13,17 +13,17 @@ knot::knot(const double &x, const double &y, const double &value)
}
knot::~knot()
Knot::~Knot()
{
}
void knot::setValue(const double &value)
void Knot::SetValue(const double &value)
{
_value=value;
}
const double &knot::getValue() const
const double &Knot::GetValue() const
{
return _value;
}
......
......@@ -2,15 +2,15 @@
#define KNOT_H
class knot
class Knot
{
public:
knot();
knot(const double &x, const double &y, const double &value=0);
~knot();
Knot();
Knot(const double &x, const double &y, const double &value=0);
~Knot();
void setValue(const double &value);
const double &getValue() const;
void SetValue(const double &value);
const double &GetValue() const;
private:
double _x;
......
......@@ -49,14 +49,14 @@ GraphEdge::~GraphEdge()
}
GraphEdge::GraphEdge(const GraphVertex * const s, const GraphVertex * const d, const Crossing * const crossing)
: src(s), dest(d), crossing(crossing)
: _src(s), _dest(d), _crossing(crossing)
{
CalcApproximateDistance();
setUpFireMesh();
SetUpFireMesh();
}
GraphEdge::GraphEdge(GraphEdge const &ge)
: src(ge.src), dest(ge.dest), crossing(ge.crossing), approximate_distance(ge.approximate_distance), fireMesh(ge.fireMesh)
: _src(ge._src), _dest(ge._dest), _crossing(ge._crossing), _approximate_distance(ge._approximate_distance), _fireMesh(ge._fireMesh)
{
}
......@@ -64,21 +64,21 @@ void GraphEdge::CalcApproximateDistance()
{
double distance = 0.0;
int count = 0;
for(std::vector<Crossing*>::const_iterator it = src->GetSubRoom()->GetAllCrossings().begin(); it != src->GetSubRoom()->GetAllCrossings().end(); ++it) {
if(crossing->GetUniqueID() == (*it)->GetUniqueID()) continue;
for(std::vector<Crossing*>::const_iterator it = _src->GetSubRoom()->GetAllCrossings().begin(); it != _src->GetSubRoom()->GetAllCrossings().end(); ++it) {
if(_crossing->GetUniqueID() == (*it)->GetUniqueID()) continue;
if(GetDest() != NULL && ((*it)->GetSubRoom1() == GetDest()->GetSubRoom() || (*it)->GetSubRoom2() == GetDest()->GetSubRoom())) continue;
count++;
distance = distance + (((*it)->GetCentre() - crossing->GetCentre()).Norm());
distance = distance + (((*it)->GetCentre() - _crossing->GetCentre()).Norm());
}
for(std::vector<Transition*>::const_iterator it = src->GetSubRoom()->GetAllTransitions().begin(); it != src->GetSubRoom()->GetAllTransitions().end(); ++it) {
if(crossing->GetUniqueID() == (*it)->GetUniqueID()) continue;
for(std::vector<Transition*>::const_iterator it = _src->GetSubRoom()->GetAllTransitions().begin(); it != _src->GetSubRoom()->GetAllTransitions().end(); ++it) {
if(_crossing->GetUniqueID() == (*it)->GetUniqueID()) continue;
if(GetDest() != NULL && ((*it)->GetSubRoom1() == GetDest()->GetSubRoom() || (*it)->GetSubRoom2() == GetDest()->GetSubRoom())) continue;
count++;
distance = distance + (((*it)->GetCentre() - crossing->GetCentre()).Norm());
distance = distance + (((*it)->GetCentre() - _crossing->GetCentre()).Norm());
}
if(count == 0) approximate_distance = 0;
else approximate_distance = distance/count;
if(count == 0) _approximate_distance = 0;
else _approximate_distance = distance/count;
}
......@@ -131,44 +131,50 @@ double GraphEdge::GetRoomToFloorFactor() const
double GraphEdge::GetApproximateDistance(const Point & position) const
{
return (crossing->GetCentre()-position).Norm();
return (_crossing->GetCentre()-position).Norm();
}
double GraphEdge::GetApproximateDistance() const
{
return approximate_distance;
return _approximate_distance;
}
const GraphVertex * GraphEdge::GetDest() const
{
return dest;
return _dest;
}
const GraphVertex * GraphEdge::GetSrc() const
{
return src;
return _src;
}
const Crossing * GraphEdge::GetCrossing() const
{
return crossing;
return _crossing;
}
const FireMesh &GraphEdge::getFireMesh() const
const FireMesh &GraphEdge::GetFireMesh() const
{
return this->fireMesh;
return _fireMesh;
}
void GraphEdge::setUpFireMesh()
void GraphEdge::SetUpFireMesh()
{
std::string filename = "D:/JuPedSim/jpscore/inputfiles/cognitive_map/Door_X_"+std::to_string(crossing->GetCentre().GetX())+"_Y_"+std::to_string(crossing->GetCentre().GetY())+".csv";
fireMesh.setKnotValuesFromFile(filename);
//TODO: read this prefix from the ini file
// std::string filename = "D:/workspace/JuPedSim/jpscore/inputfiles/cognitive_map";
std::string prefix = "D:/workspace/JPS/JPScore/inputfiles/cognitive_map";
std::string filename = prefix + "/Door_X_" + std::to_string(_crossing->GetCentre().GetX())
+ "_Y_" + std::to_string(_crossing->GetCentre().GetY()) + ".csv";
_fireMesh.SetKnotValuesFromFile(filename);
}
double GraphEdge::getSmokeFactor(const Point &pointPed) const
double GraphEdge::GetSmokeFactor(const Point &pointPed) const
{ //std::cout << pointPed.GetX() << " " << pointPed.GetY() << std::endl;
if (fireMesh.statusMesh()==true)
return fireMesh.getKnotValue(pointPed.GetX(),pointPed.GetY());
if (_fireMesh.statusMesh()==true)
return _fireMesh.GetKnotValue(pointPed.GetX(),pointPed.GetY());
else
return 1.0;
......@@ -176,5 +182,5 @@ double GraphEdge::getSmokeFactor(const Point &pointPed) const
bool GraphEdge::IsExit() const
{
return crossing->IsExit();
return _crossing->IsExit();
}
......@@ -38,20 +38,19 @@ class SubRoom;
class GraphVertex;
class Crossing;
//log output
extern OutputHandler* Log;
/**
* @brief Graph Edge.
*
*/
class GraphEdge {
class GraphEdge
{
public:
typedef std::map<std::string, std::pair<double, double> > FactorContainer;
/****************************
* Constructors & Destructors
****************************/
GraphEdge(const GraphVertex * const s, const GraphVertex * const d, const Crossing * const crossing);
GraphEdge(GraphEdge const & ge);
virtual ~GraphEdge();
......@@ -64,34 +63,24 @@ public:
const Crossing * GetCrossing() const;
///FireMesh
const FireMesh& getFireMesh() const;
void setUpFireMesh();
double getSmokeFactor(const Point &pointPed) const;
const FireMesh& GetFireMesh() const;
void SetUpFireMesh();
double GetSmokeFactor(const Point &pointPed) const;
double GetApproximateDistance() const;
double GetApproximateDistance(const Point &) const;
void SetFactor(double factor, std::string name);
double GetRoomToFloorFactor() const;
double GetFactor() const;
double GetFactorWithDistance(double distance) const;
double GetFactor() const;
double GetFactorWithDistance(double distance) const;
double GetWeight(const Point &) const;
bool IsExit() const;
private:
const GraphVertex * const src;
const GraphVertex * const dest;
const Crossing * const crossing;
FireMesh fireMesh;
const GraphVertex * const _src;
const GraphVertex * const _dest;
const Crossing * const _crossing;
FireMesh _fireMesh;
/**
* Factor Bag
......@@ -103,8 +92,7 @@ private:
FactorContainer factors;
//WEIGHTS DEPRECATED!
double approximate_distance;
// double density = 0.0;
double _approximate_distance;
};
......
......@@ -31,7 +31,7 @@ void SmokeSensor::execute(const Pedestrian * pedestrian, CognitiveMap * cognitiv
for (auto &item : *edges)
{
double smokeFactor = item->getSmokeFactor(pedestrian->GetPos());
double smokeFactor = item->GetSmokeFactor(pedestrian->GetPos());
//std::cout << smokeFactor << std::endl;
item->SetFactor(smokeFactor,GetName());
//std::cout << item->GetFactor() << std::endl;
......
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