Commit 736c6262 authored by Arne Graf's avatar Arne Graf

using ini files with floorfield

parent 17466e2b
......@@ -716,6 +716,39 @@ bool ArgumentParser::ParseGradientModel(TiXmlElement* xGradient) // @todo: chang
if(ParseStrategyNodeToObject(*xModelPara)==false)
return false;
//floorfield
if(xModelPara->FirstChild("floorfield"))
{
if (!xModelPara->FirstChildElement("floorfield")->Attribute("delta_h"))
pDeltaH = 0.0625; // default value
else
{
string delta_h = xModelPara->FirstChildElement("floorfield")->Attribute("delta_h");
pDeltaH = atof(delta_h.c_str());
}
if (!xModelPara->FirstChildElement("floorfield")->Attribute("wall_avoid_distance"))
pWallAvoidDistance = .8; // default value
else
{
string wall_avoid_distance = xModelPara->FirstChildElement("floorfield")->Attribute("wall_avoid_distance");
pWallAvoidDistance = atof(wall_avoid_distance.c_str());
}
if (!xModelPara->FirstChildElement("floorfield")->Attribute("use_wall_avoidance"))
pUseWallAvoidance = true; // default value
else
{
string use_wall_avoidance = xModelPara->FirstChildElement("floorfield")->Attribute("use_wall_avoidance");
if (use_wall_avoidance == "false")
pUseWallAvoidance = false;
else
pUseWallAvoidance = true;
}
Log->Write("INFO: \tfloorfield <delta h=%0.4f, wall avoid distance=%0.2f>", pDeltaH, pWallAvoidDistance);
Log->Write("INFO: \tfloorfield <use wall avoidance=%s>", pUseWallAvoidance ? "true" : "false");
}
//linked-cells
if(ParseLinkedCells(*xModelPara)==false)
return false;
......@@ -784,7 +817,8 @@ bool ArgumentParser::ParseGradientModel(TiXmlElement* xGradient) // @todo: chang
p_op_model = std::shared_ptr<OperationalModel>(new GradientModel(p_exit_strategy.get(), this->GetNuPed(),
this->GetaPed(), this->GetbPed(), this->GetcPed(),
this->GetNuWall(), this->GetaWall(), this->GetbWall(),
this->GetcWall()));
this->GetcWall(),
this->pDeltaH, this->pWallAvoidDistance, this->pUseWallAvoidance));
return true;
}
......
......@@ -96,6 +96,9 @@ private:
unsigned int pSeed;
int pSolver; /// solver for the differential equation
int pExitStrategy; // Strategie zur Richtungswahl (v0)
double pDeltaH;
double pWallAvoidDistance;
bool pUseWallAvoidance;
int pLog;
int pPort;
int _embedMesh;
......
......@@ -82,9 +82,10 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<solver>euler</solver>
<stepsize>0.01</stepsize>
<exit_crossing_strategy>6</exit_crossing_strategy>
<floorfield delta_h="0.0625" wall_avoid_distance="0.8" use_wall_avoidance="true" />
<linkedcells enabled="true" cell_size="2.2" />
<force_ped nu="3" b="0.25" c="3.0" />
<force_wall nu="10" b="0.70" c="3.0" />
<force_ped nu="0" b="0.25" c="3.0" />
<force_wall nu="1" b="0.70" c="3.0" />
</model_parameters>
<agent_parameters agent_parameter_id="1">
<v0 mu="0.5" sigma="0.0" />
......
......@@ -48,7 +48,8 @@ using std::vector;
using std::string;
GradientModel::GradientModel(DirectionStrategy* dir, double nuped, double aped, double bped, double cped,
double nuwall, double awall, double bwall, double cwall)
double nuwall, double awall, double bwall, double cwall,
double deltaH, double wallAvoidDistance, bool useWallAvoidance)
{
_direction = dir;
// Force_rep_PED Parameter
......@@ -61,6 +62,10 @@ GradientModel::GradientModel(DirectionStrategy* dir, double nuped, double aped,
_aWall = awall;
_bWall = bwall;
_cWall = cwall;
// floorfield Parameter
_deltaH = deltaH;
_wallAvoidDistance = wallAvoidDistance;
_useWallAvoidance = useWallAvoidance;
}
......@@ -71,10 +76,8 @@ GradientModel::~GradientModel()
bool GradientModel::Init (Building* building) const
{
//_direction = DirectionFloorfield(building, .0625, 1., true);
if(dynamic_cast<DirectionFloorfield*>(_direction)){
dynamic_cast<DirectionFloorfield*>(_direction)->Init(building, .0625, .5, true);
dynamic_cast<DirectionFloorfield*>(_direction)->Init(building, _deltaH, _wallAvoidDistance, _useWallAvoidance);
}
const vector< Pedestrian* >& allPeds = building->GetAllPedestrians();
......
......@@ -58,6 +58,10 @@ private:
double _bWall;
double _cWall;
double _deltaH;
double _wallAvoidDistance;
bool _useWallAvoidance;
/**
* Driving force \f$ F_i =\frac{\mathbf{v_0}-\mathbf{v_i}}{\tau}\f$
* This is a duplicate of @see GCFMModel::ForceDriv
......@@ -101,7 +105,8 @@ private:
public:
GradientModel(DirectionStrategy* dir, double nuped, double aped, double bped, double cped,
double nuwall, double awall, double bwall, double cwall);
double nuwall, double awall, double bwall, double cwall,
double deltaH, double wallAvoidDistance, bool useWallAvoidance);
virtual ~GradientModel(void);
DirectionStrategy* GetDirection() const;
......
......@@ -455,7 +455,7 @@ const Point& Pedestrian::GetV0(const Point& target)
//new_v0 = delta.NormalizedMolified();
new_v0 = delta.Normalized();
// -------------------------------------- Handover new target
t = _newOrientationDelay++ *_deltaT/(1.0+1000* _distToBlockade);
t = _newOrientationDelay++ *_deltaT/(1.0+1000* _distToBlockade);
_V0 = _V0 + (new_v0 - _V0)*( 1 - exp(-t/_tau) );
#if DEBUG
......
......@@ -256,11 +256,18 @@ Point DirectionInRangeBottleneck::GetTarget(Room* room, Pedestrian* ped) const
/// 6
Point DirectionFloorfield::GetTarget(Room* room, Pedestrian* ped) const
{
if (ffviafm != nullptr) {
#if DEBUG
if (initDone && (ffviafm != nullptr)) {
#endif // DEBUG
Point p;
ffviafm->getDirectionAt(ped->GetPos(), p);
return p;
#if DEBUG
}
#endif // DEBUG
//this should not execute:
exit(EXIT_FAILURE);
}
......@@ -268,9 +275,12 @@ Point DirectionFloorfield::GetTarget(Room* room, Pedestrian* ped) const
void DirectionFloorfield::Init(Building* building, double stepsize, double threshold, bool useDistancMap) {
//implement mechanic, that can read-in an existing floorfield (from a previous run)
ffviafm = new FloorfieldViaFM(building, stepsize, stepsize, threshold, useDistancMap);
initDone = true;
}
DirectionFloorfield::DirectionFloorfield() {};
DirectionFloorfield::DirectionFloorfield() {
initDone = false;
};
DirectionFloorfield::~DirectionFloorfield() {
if (ffviafm) {
......
......@@ -81,6 +81,7 @@ public:
private:
FloorfieldViaFM* ffviafm;
bool initDone;
};
#endif /* _DIRECTIONSTRATEGY_H */
......
......@@ -800,8 +800,8 @@ void FloorfieldViaFM::testoutput(const char* filename1, const char* filename2, c
int numX = (int) ((grid->GetxMax()-grid->GetxMin())/grid->Gethx());
int numY = (int) ((grid->GetyMax()-grid->GetyMin())/grid->Gethy());
int numTotal = numX * numY;
std::cerr << numTotal << " numTotal" << std::endl;
std::cerr << grid->GetnPoints() << " grid" << std::endl;
//std::cerr << numTotal << " numTotal" << std::endl;
//std::cerr << grid->GetnPoints() << " grid" << std::endl;
file.open(filename1);
file2.open(filename2);
file << "# vtk DataFile Version 3.0" << std::endl;
......@@ -834,6 +834,6 @@ void FloorfieldViaFM::testoutput(const char* filename1, const char* filename2, c
file.close();
file2.close();
std::cerr << "File closed: " << filename1 << std::endl;
std::cerr << "INFO: \tFile closed: " << filename1 << 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