Commit a1c6dd8e authored by Ulrich Kemloh's avatar Ulrich Kemloh

Added new parameter for pedestrians: risk tolerance

Sample: risk_tolerance_mean="0.8" risk_tolerance_sigma="0.01"
The value is truncated to the interval [0 1] if not in that interval.
Pedestrians with large value are likely to take more 'risk'
parent bb1fbcf0
...@@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file. ...@@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file.
## v0.7.0 [Unreleased] ## v0.7.0 [Unreleased]
### Added ### Added
- Changelog file - Changelog file
- Rimea testcases - Rimea testcases
- risk tolerance factor (value in [0 1]) for pedestrian. Pedestrians with high values are likely to take more risks.
### Changed ### Changed
- -
......
...@@ -136,7 +136,8 @@ enum AgentColorMode { ...@@ -136,7 +136,8 @@ enum AgentColorMode {
BY_VELOCITY=1, BY_VELOCITY=1,
BY_KNOWLEDGE, BY_KNOWLEDGE,
BY_ROUTE, BY_ROUTE,
BY_SPOTLIGHT BY_SPOTLIGHT,
//BY_GROUP
}; };
//global functions for convenience //global functions for convenience
......
...@@ -12,7 +12,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd"> ...@@ -12,7 +12,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!-- trajectories file and format --> <!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8"> <trajectories format="xml-plain" fps="8">
<file location="big_room_trrajectories.xml" /> <file location="big_room_trrajectories.xml" />
<!--<socket hostname="127.0.0.1" port="8989"/> --> <socket hostname="127.0.0.1" port="8989"/>
</trajectories> </trajectories>
<!-- where to store the logs --> <!-- where to store the logs -->
<!--<logfile>outputfiles/log.txt</logfile> --> <!--<logfile>outputfiles/log.txt</logfile> -->
...@@ -70,7 +70,8 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd"> ...@@ -70,7 +70,8 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!--persons information and distribution --> <!--persons information and distribution -->
<agents operational_model_id="2"> <agents operational_model_id="2">
<agents_distribution> <agents_distribution>
<group group_id="0" room_id="0" subroom_id="0" number="500" router_id="1" agent_parameter_id="1" /> <group group_id="0" room_id="0" subroom_id="0" number="50" router_id="1" agent_parameter_id="1"
risk_tolerance_mean="0.8" risk_tolerance_sigma="0.01"/>
</agents_distribution> </agents_distribution>
</agents> </agents>
......
...@@ -12,7 +12,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd"> ...@@ -12,7 +12,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!-- trajectories file and format --> <!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8"> <trajectories format="xml-plain" fps="8">
<file location="testSchulTrajectories.xml" /> <file location="testSchulTrajectories.xml" />
<!-- <socket hostname="127.0.0.1" port="8989"/> --> <socket hostname="127.0.0.1" port="8989"/>
</trajectories> </trajectories>
<!-- where to store the logs --> <!-- where to store the logs -->
<!--<logfile>outputfiles/log.txt</logfile> --> <!--<logfile>outputfiles/log.txt</logfile> -->
......
...@@ -257,6 +257,8 @@ bool PedDistributor::InitDistributor(const string& fileName, const std::map<int, ...@@ -257,6 +257,8 @@ bool PedDistributor::InitDistributor(const string& fileName, const std::map<int,
double patience= xmltof(e->Attribute("patience"), 5); double patience= xmltof(e->Attribute("patience"), 5);
double premovement_mean= xmltof(e->Attribute("pre_movement_mean"), 0); double premovement_mean= xmltof(e->Attribute("pre_movement_mean"), 0);
double premovement_sigma= xmltof(e->Attribute("pre_movement_sigma"), 0); double premovement_sigma= xmltof(e->Attribute("pre_movement_sigma"), 0);
double risk_tolerance_mean= xmltof(e->Attribute("risk_tolerance_mean"), 0);
double risk_tolerance_sigma= xmltof(e->Attribute("risk_tolerance_sigma"), 0);
double x_min=xmltof(e->Attribute("x_min"), -FLT_MAX); double x_min=xmltof(e->Attribute("x_min"), -FLT_MAX);
double x_max=xmltof(e->Attribute("x_max"), FLT_MAX); double x_max=xmltof(e->Attribute("x_max"), FLT_MAX);
...@@ -292,6 +294,7 @@ bool PedDistributor::InitDistributor(const string& fileName, const std::map<int, ...@@ -292,6 +294,7 @@ bool PedDistributor::InitDistributor(const string& fileName, const std::map<int,
dis->SetHeight(height); dis->SetHeight(height);
dis->SetPatience(patience); dis->SetPatience(patience);
dis->InitPremovementTime(premovement_mean,premovement_sigma); dis->InitPremovementTime(premovement_mean,premovement_sigma);
dis->InitRiskTolerance(risk_tolerance_mean,risk_tolerance_sigma);
if(agentPars.count(agent_para_id)==0) if(agentPars.count(agent_para_id)==0)
{ {
...@@ -759,6 +762,7 @@ void PedDistributor::DistributeInSubRoom(SubRoom* r,int nAgents , vector<Point>& ...@@ -759,6 +762,7 @@ void PedDistributor::DistributeInSubRoom(SubRoom* r,int nAgents , vector<Point>&
ped->SetSubRoomID(r->GetSubRoomID()); ped->SetSubRoomID(r->GetSubRoomID());
ped->SetPatienceTime(para->GetPatience()); ped->SetPatienceTime(para->GetPatience());
ped->SetPremovementTime(para->GetPremovementTime()); ped->SetPremovementTime(para->GetPremovementTime());
ped->SetRiskTolerance(para->GetRiskTolerance());
const Point& start_pos = para->GetStartPosition(); const Point& start_pos = para->GetStartPosition();
...@@ -844,3 +848,13 @@ double StartDistributionRoom::GetPremovementTime() ...@@ -844,3 +848,13 @@ double StartDistributionRoom::GetPremovementTime()
{ {
return _premovementTime(_generator); return _premovementTime(_generator);
} }
void StartDistributionRoom::InitRiskTolerance(double mean, double stdv)
{
_riskTolerance = std::normal_distribution<double>(mean,stdv);
}
double StartDistributionRoom::GetRiskTolerance()
{
return _riskTolerance(_generator);
}
...@@ -74,6 +74,11 @@ private: ...@@ -74,6 +74,11 @@ private:
//pre movement time distribution //pre movement time distribution
std::normal_distribution<double> _premovementTime; std::normal_distribution<double> _premovementTime;
//risk tolerance distribution
std::normal_distribution<double> _riskTolerance;
//random number generator engine
std::default_random_engine _generator; std::default_random_engine _generator;
...@@ -109,8 +114,10 @@ public: ...@@ -109,8 +114,10 @@ public:
void Setbounds(double bounds[4]); void Setbounds(double bounds[4]);
AgentsParameters* GetGroupParameters(); AgentsParameters* GetGroupParameters();
void SetGroupParameters(AgentsParameters* groupParameters); void SetGroupParameters(AgentsParameters* groupParameters);
void InitPremovementTime(double mean, double stv); void InitPremovementTime(double mean, double stdv);
double GetPremovementTime(); double GetPremovementTime();
void InitRiskTolerance(double mean, double stdv);
double GetRiskTolerance();
}; };
//TODO merge the two classes and set the _subRoomID=-1 //TODO merge the two classes and set the _subRoomID=-1
......
...@@ -793,6 +793,18 @@ double Pedestrian::GetPremovementTime() ...@@ -793,6 +793,18 @@ double Pedestrian::GetPremovementTime()
return _premovement; return _premovement;
} }
void Pedestrian::SetRiskTolerance(double tol)
{
if (tol>1) tol=1;
if(tol<0) tol=0;
_riskTolerance=tol;
}
double Pedestrian::GetRiskTolerance() const
{
return _riskTolerance;
}
const Building* Pedestrian::GetBuilding() const Building* Pedestrian::GetBuilding()
{ {
return _building; return _building;
......
...@@ -55,6 +55,7 @@ private: ...@@ -55,6 +55,7 @@ private:
double _height; double _height;
double _age; double _age;
double _premovement = 0; double _premovement = 0;
double _riskTolerance=0;
std::string _gender; std::string _gender;
//gcfm specific parameters //gcfm specific parameters
...@@ -128,7 +129,7 @@ private: ...@@ -128,7 +129,7 @@ private:
Building * _building; Building * _building;
public: public:
// Konstruktoren // constructors
Pedestrian(); Pedestrian();
virtual ~Pedestrian(); virtual ~Pedestrian();
...@@ -325,6 +326,20 @@ public: ...@@ -325,6 +326,20 @@ public:
*/ */
double GetPremovementTime(); double GetPremovementTime();
/**
* Set/Get the risk tolerance of a pedestrians.
* The value should be in the interval [0 1].
* It will be truncated accordingly if not in that interval.
*/
void SetRiskTolerance(double tol);
/**
* Set/Get the risk tolerance of a pedestrians.
* The value should be in the interval [0 1].
* It will be truncated accordingly if not in that interval.
*/
double GetRiskTolerance() const;
/** /**
* return the pedestrian color used for visualiation. * return the pedestrian color used for visualiation.
* Default mode is coded by velocity. * Default mode is coded by velocity.
......
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