Commit 50085212 authored by Arne Graf's avatar Arne Graf

corrected projectRoot in config, added some Ini File arguments

parent e33c4eb9
......@@ -54,6 +54,9 @@ bool GeoFileParser::LoadGeometry(Building* building)
std::string geoFilenameWithPath = _configuration->GetProjectRootDir()+_configuration->GetGeometryFile();
TiXmlDocument docGeo(geoFilenameWithPath);
if (!docGeo.LoadFile()) {
Log->Write(_configuration->GetProjectRootDir());
Log->Write(_configuration->GetGeometryFile());
Log->Write(geoFilenameWithPath);
Log->Write("ERROR: \t%s", docGeo.ErrorDesc());
Log->Write("\t could not parse the geometry file");
return false;
......
......@@ -65,6 +65,8 @@ bool IniFileParser::Parse(std::string iniFile)
size_t found = iniFile.find_last_of("/\\");
if (found!=std::string::npos) {
_config->SetProjectRootDir(iniFile.substr(0, found)+"/");
} else {
_config->SetProjectRootDir("./");
}
TiXmlDocument doc(iniFile);
......@@ -654,6 +656,7 @@ bool IniFileParser::ParseGradientModel(TiXmlElement* xGradient, TiXmlElement* xM
string delta_h = xModelPara->FirstChildElement("floorfield")->Attribute("delta_h");
pDeltaH = atof(delta_h.c_str());
}
_config->set_deltaH(pDeltaH);
if (!xModelPara->FirstChildElement("floorfield")->Attribute("wall_avoid_distance"))
pWallAvoidDistance = .8; // default value
......@@ -662,6 +665,7 @@ bool IniFileParser::ParseGradientModel(TiXmlElement* xGradient, TiXmlElement* xM
"wall_avoid_distance");
pWallAvoidDistance = atof(wall_avoid_distance.c_str());
}
_config->set_wall_avoid_distance(pWallAvoidDistance);
if (!xModelPara->FirstChildElement("floorfield")->Attribute("use_wall_avoidance"))
pUseWallAvoidance = true; // default value
......@@ -669,6 +673,7 @@ bool IniFileParser::ParseGradientModel(TiXmlElement* xGradient, TiXmlElement* xM
string use_wall_avoidance = xModelPara->FirstChildElement("floorfield")->Attribute("use_wall_avoidance");
pUseWallAvoidance = !(use_wall_avoidance=="false");
}
_config->set_use_wall_avoidance(pUseWallAvoidance);
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");
}
......@@ -741,6 +746,7 @@ bool IniFileParser::ParseGradientModel(TiXmlElement* xGradient, TiXmlElement* xM
"slow_down_distance");
pSlowDownDistance = atof(slow_down_distance.c_str());
}
_config->set_slow_down_distance(pSlowDownDistance);
Log->Write("INFO: \tAnti Clipping: SlowDown Distance=%0.2f", pSlowDownDistance);
}
......@@ -752,8 +758,8 @@ bool IniFileParser::ParseGradientModel(TiXmlElement* xGradient, TiXmlElement* xM
_config->SetModel(std::shared_ptr<OperationalModel>(new GradientModel(_exit_strategy, _config->GetNuPed(),
_config->GetaPed(), _config->GetbPed(), _config->GetcPed(),
_config->GetNuWall(), _config->GetaWall(), _config->GetbWall(),
_config->GetcWall(), pDeltaH, pWallAvoidDistance, pUseWallAvoidance,
pSlowDownDistance)));
_config->GetcWall(), _config->get_deltaH(), _config->get_wall_avoid_distance(), _config->get_use_wall_avoidance(),
_config->get_slow_down_distance())));
return true;
}
......@@ -1103,26 +1109,26 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
else if ((strategy == "ff_global_shortest") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST));
Router *r = new FFRouter(id, ROUTING_FF_GLOBAL_SHORTEST, hasSpecificGoals);
Router *r = new FFRouter(id, ROUTING_FF_GLOBAL_SHORTEST, hasSpecificGoals, _config);
_config->GetRoutingEngine()->AddRouter(r);
Log->Write("\nINFO: \tUsing FF Global Shortest Router");
//check if the exit strat is [8]
//check if the exit strat is [8 | 9] //@todo: ar.graf: implement check and check which are valid exitstrats
///Parsing additional options
if (!ParseFfRouterOps(e)) {
if (!ParseFfRouterOps(e, ROUTING_FF_GLOBAL_SHORTEST)) {
return false;
}
}
else if ((strategy == "ff_local_shortest") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST));
Router *r = new FFRouter(id, ROUTING_FF_LOCAL_SHORTEST, hasSpecificGoals);
Router *r = new FFRouter(id, ROUTING_FF_LOCAL_SHORTEST, hasSpecificGoals, _config);
_config->GetRoutingEngine()->AddRouter(r);
Log->Write("\nINFO: \tUsing FF Local Shortest Router");
Log->Write("\nWARNING: \tFF Local Shortest is bugged!!!!");
//check if the exit strat is [8]
//check if the exit strat is [8 | 9]
///Parsing additional options
// if (!ParseFfRouterOps(e)) {
......@@ -1131,13 +1137,13 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
}
else if ((strategy == "ff_quickest") &&
(std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
Router *r = new FFRouter(id, ROUTING_FF_QUICKEST, hasSpecificGoals);
Router *r = new FFRouter(id, ROUTING_FF_QUICKEST, hasSpecificGoals, _config);
_config->GetRoutingEngine()->AddRouter(r);
Log->Write("\nINFO: \tUsing FF Quickest Router");
//if (!ParseFfRouterOps(e)) {
// return false;
//}
if (!ParseFfRouterOps(e, ROUTING_FF_QUICKEST)) {
return false;
}
}
else if (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) {
Log->Write("ERROR: \twrong value for routing strategy [%s]!!!\n",
......@@ -1148,18 +1154,25 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
return true;
}
bool IniFileParser::ParseFfRouterOps(TiXmlNode* routingNode) {
bool IniFileParser::ParseFfRouterOps(TiXmlNode* routingNode, RoutingStrategy s) {
//set defaults
std::string mode = "global_shortest";
FFRouter* r = static_cast<FFRouter*>(_config->GetRoutingEngine()->GetAvailableRouters().back());
//parse ini-file-information
if (routingNode->FirstChild("parameters")) {
TiXmlNode* pParameters = routingNode->FirstChild("parameters");
if (pParameters->FirstChild("mode")) {
mode = pParameters->FirstChild("mode")->FirstChild()->Value();
std::string mode;
if (s == ROUTING_FF_GLOBAL_SHORTEST) {
mode = "global_shortest";
}
if (s == ROUTING_FF_QUICKEST) {
mode = "quickest";
//parse ini-file-information
if (routingNode->FirstChild("parameters")) {
TiXmlNode* pParameters = routingNode->FirstChild("parameters");
if (pParameters->FirstChild("recalc interval")) { //@todo: ar.graf: test ini file with recalc value
_config->set_recalc_interval(atof(pParameters->FirstChild("recalc interval")->FirstChild()->Value()));
}
}
}
FFRouter* r = static_cast<FFRouter*>(_config->GetRoutingEngine()->GetAvailableRouters().back());
r->SetMode(mode);
return true;
}
......
......@@ -58,7 +58,7 @@ private:
bool ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* agentDistri);
bool ParseFfRouterOps(TiXmlNode* routingNode);
bool ParseFfRouterOps(TiXmlNode* routingNode, RoutingStrategy s);
bool ParseCogMapOpts(TiXmlNode* routingNode);
......
......@@ -97,6 +97,15 @@ public:
_showStatistics = false;
_fileFormat = FORMAT_XML_PLAIN;
_agentsParameters = std::map<int, std::shared_ptr<AgentsParameters> >();
// ---------- floorfield
_deltaH = 0.0625;
_wall_avoid_distance = 0.4;
_use_wall_avoidance = true;
// ---------- gradientmodel
_slow_down_distance = 0.2;
//ff router quickest
_recalc_interval = 5;
}
int GetSolver() const { return _solver; };
......@@ -212,6 +221,26 @@ public:
void SetDistEffMaxWall(double distEffMaxWall) { _distEffMaxWall = distEffMaxWall; };
double get_deltaH() const { return _deltaH; }
void set_deltaH(double _deltaH) { Configuration::_deltaH = _deltaH; }
double get_wall_avoid_distance() const { return _wall_avoid_distance; }
void set_wall_avoid_distance(double _wall_avoid_distance) { Configuration::_wall_avoid_distance = _wall_avoid_distance; }
bool get_use_wall_avoidance() const { return _use_wall_avoidance; }
void set_use_wall_avoidance(bool _use_wall_avoidance) { Configuration::_use_wall_avoidance = _use_wall_avoidance; }
double get_slow_down_distance() const { return _slow_down_distance; }
void set_slow_down_distance(double _slow_down_distance) { Configuration::_slow_down_distance = _slow_down_distance; }
double get_recalc_interval() const { return _recalc_interval; }
void set_recalc_interval(double _recalc_interval) { Configuration::_recalc_interval = _recalc_interval; }
const std::string& GetHostname() const { return _hostname; };
void SetHostname(std::string hostname) { _hostname = hostname; };
......@@ -304,6 +333,16 @@ private:
double _maxFWall;
double _distEffMaxPed;
double _distEffMaxWall;
//floorfield
double _deltaH;
double _wall_avoid_distance;
bool _use_wall_avoidance;
//gradientmodel
double _slow_down_distance;
//ff router quickest
double _recalc_interval;
std::string _hostname;
std::string _trajectoriesFile;
std::string _errorLogFile;
......
......@@ -132,7 +132,11 @@ std::shared_ptr<DirectionStrategy> IniFromProtobufLoader::configureExitCrossingS
exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionFloorfield());
break;
case 7:
exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionGoalFloorfield());
// dead end -> not supported anymore (global ff needed, but not available in 3d)
Log->Write("ERROR: \tExit Strategy 7 is not supported any longer. Please refer to www.jupedsim.org");
Log->Write("WARNING: \tChanging Exit-Strategy to #9 (Floorfields with targets within subroom)");
pExitStrategy = 9;
_exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionSubLocalFloorfield());
break;
case 8:
exit_strategy = std::shared_ptr<DirectionStrategy>(new DirectionLocalFloorfield());
......
......@@ -59,13 +59,15 @@ FFRouter::FFRouter()
}
FFRouter::FFRouter(int id, RoutingStrategy s, bool hasSpecificGoals):Router(id,s) {
FFRouter::FFRouter(int id, RoutingStrategy s, bool hasSpecificGoals, Configuration* config):Router(id,s) {
_config = config;
_building = nullptr;
_hasSpecificGoals = hasSpecificGoals;
_globalFF = nullptr;
_targetWithinSubroom = true; //depending on exit_strat 8 => false, depending on exit_strat 9 => true;
if (s == ROUTING_FF_QUICKEST) {
_mode = quickest;
_recalc_interval = _config->get_recalc_interval();
} else if (s == ROUTING_FF_LOCAL_SHORTEST) {
_mode = local_shortest;
_localShortestSafedPeds.clear();
......@@ -542,18 +544,9 @@ int FFRouter::FindExit(Pedestrian* p)
// }
// }
if (_mode == quickest) {
// p->_ticksInThisRoom += 1;
// if (p->GetReroutingTime() > 0.) {
// p->UpdateReroutingTime();
// return p->GetExitIndex();
// } else {
// p->RerouteIn(5.);
// }
//above version (stopwatch at doors) failed
//new version: recalc densityspeed every x seconds
if (p->GetGlobalTime() > timeToRecalc) {
timeToRecalc += 5;
timeToRecalc += _recalc_interval; //@todo: ar.graf: change "5" to value of config file/classmember
// for (auto localfield : _locffviafm) { //@todo: ar.graf: create a list of local ped-ptr instead of giving all peds-ptr
// localfield.second->setSpeedThruPeds(_building->GetAllPedestrians().data(), _building->GetAllPedestrians().size(), _mode, 1.);
// localfield.second->deleteAllFFs();
......
......@@ -111,7 +111,7 @@ public:
*
*/
FFRouter();
FFRouter(int id, RoutingStrategy s, bool hasSpecificGoals);
FFRouter(int id, RoutingStrategy s, bool hasSpecificGoals, Configuration* config);
//FFRouter(const Building* const);
/**
......@@ -195,6 +195,7 @@ public:
private:
protected:
Configuration* _config;
std::map< std::pair<int, int> , double > _distMatrix;
std::map< std::pair<int, int> , int > _pathsMatrix;
std::vector<int> _allDoorUIDs;
......@@ -211,9 +212,11 @@ protected:
std::map<int, int> goalToLineUIDmap3;
int _mode;
double timeToRecalc = 0;
double timeToRecalc = 0.;
double _recalc_interval;
bool _hasSpecificGoals;
bool _targetWithinSubroom;
//output filename counter: cnt
static int cnt;
};
......
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