IniFileParser.cpp 74 KB
Newer Older
GrgrLmml's avatar
GrgrLmml committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/**
 * \section License
 * This file is part of JuPedSim.
 *
 * JuPedSim is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * JuPedSim is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
 **/
//
// Created by laemmel on 24.03.16.
//

#ifdef _OPENMP

#include <omp.h>

Qiancheng Xu's avatar
Qiancheng Xu committed
26

GrgrLmml's avatar
GrgrLmml committed
27 28 29 30 31 32 33 34 35 36 37
#else
#define omp_get_thread_num() 0
#define omp_get_max_threads()  1
#endif

#include "../tinyxml/tinyxml.h"
#include "OutputHandler.h"

#include "IniFileParser.h"
#include "../pedestrian/Pedestrian.h"
#include "../math/GCFMModel.h"
38
#include "../math/KrauszModel.h"
GrgrLmml's avatar
GrgrLmml committed
39 40 41
#include "../math/GompertzModel.h"
#include "../math/GradientModel.h"
#include "../math/VelocityModel.h"
42 43
#include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/quickest/QuickestPathRouter.h"
44
#include "../routing/smoke_router/SmokeRouter.h"
45
#include "../routing/ai_router/AIRouter.h"
46
#include "../routing/ff_router/ffRouter.h"
47 48
#include "../routing/ff_router_trips/ffRouterTrips.h"
#include "../routing/trips_router/TripsRouter.h"
GrgrLmml's avatar
GrgrLmml committed
49

50 51 52

namespace fs = std::filesystem;

Mohcine Chraibi's avatar
Mohcine Chraibi committed
53 54 55 56 57 58 59 60 61 62
/* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */
std::string ver_string(int a, int b, int c) {
      std::ostringstream ss;
      ss << a << '.' << b << '.' << c;
      return ss.str();
}
//https://sourceforge.net/p/predef/wiki/Compilers/
std::string true_cxx =
#ifdef __clang__
      "clang++";
Mohcine Chraibi's avatar
Mohcine Chraibi committed
63
#elif defined(__GNUC__)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
64 65 66 67 68 69 70 71 72 73 74 75 76
"g++";
#elif defined(__MINGW32__)
   "MinGW";
#elif defined(_MSC_VER)
  "Visual Studio";
#else
"Compiler not identified";
#endif


std::string true_cxx_ver =
#ifdef __clang__
    ver_string(__clang_major__, __clang_minor__, __clang_patchlevel__);
Mohcine Chraibi's avatar
Mohcine Chraibi committed
77
#elif defined(__GNUC__)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
78 79 80 81 82 83 84 85 86 87
    ver_string(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#elif defined(__MINGW32__)
ver_string(__MINGW32__, __MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION);
#elif defined( _MSC_VER)
    ver_string(_MSC_VER, _MSC_FULL_VER,_MSC_BUILD);
#else
"";
#endif


GrgrLmml's avatar
GrgrLmml committed
88 89 90 91 92 93 94 95 96 97 98 99 100
IniFileParser::IniFileParser(Configuration* config)
{
     _config = config;
}

bool IniFileParser::Parse(std::string iniFile)
{
     Log->Write("INFO: \tLoading and parsing the project file <%s>",
               iniFile.c_str());
     _config->SetProjectFile(iniFile);//TODO in some locations it is called iniFile and in others project file,
     // and as I just realized, I called it configuration. We should be consistent here anything else
     // is confusing [gl march '16]

101 102 103
     fs::path root(iniFile);
     fs::path q(iniFile);
     _config->SetProjectRootDir(fs::absolute(q.parent_path()).string());
GrgrLmml's avatar
GrgrLmml committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130

     TiXmlDocument doc(iniFile);
     if (!doc.LoadFile()) {
          Log->Write("ERROR: \t%s", doc.ErrorDesc());
          Log->Write("ERROR: \tCould not parse the project file");
          return false;
     }

     // everything is fine. proceed with parsing

     TiXmlElement* xMainNode = doc.RootElement();
     if (!xMainNode) {
          Log->Write("ERROR:\tRoot element does not exist");
          return false;
     }

     if (xMainNode->ValueStr()!="JuPedSim") {
          Log->Write("ERROR:\tRoot element value is not 'JuPedSim'.");
          return false;
     }

     //check the header version
     if (!xMainNode->Attribute("version")) {
          Log->Write("WARNING:\t There is no header version. I am assuming %s",
                    JPS_VERSION);
     }
     else if (std::stod(xMainNode->Attribute("version"))<std::stod(JPS_OLD_VERSION)) {
131
          Log->Write("ERROR:\t Wrong header version. Only version greater than %s is supported.", JPS_OLD_VERSION);
GrgrLmml's avatar
GrgrLmml committed
132 133
          return false;
     }
Mohcine Chraibi's avatar
Mohcine Chraibi committed
134

135 136 137 138 139 140 141 142
     //check the structure of inifile
     if (xMainNode->FirstChild("header")) {
          TiXmlNode* xHeader = xMainNode->FirstChild("header");
          ParseHeader(xHeader);
     }//if header
     else {
          ParseHeader(xMainNode);
     }//else header
GrgrLmml's avatar
GrgrLmml committed
143 144


145 146


147 148 149
     // JPSfire
     // -------------------------------------
     // read walkingspeed
Mohcine Chraibi's avatar
Mohcine Chraibi committed
150
     #ifdef JPSFIRE
151 152 153 154 155
     std::shared_ptr<WalkingSpeed> W( new WalkingSpeed(iniFile) );
     _config->SetWalkingSpeed(W);
     // read  ToxicityAnalysis
     std::shared_ptr<ToxicityAnalysis> T( new ToxicityAnalysis(iniFile, _config->GetFps()));
     _config->SetToxicityAnalysis(T);
Mohcine Chraibi's avatar
Mohcine Chraibi committed
156
     #endif
157 158
     // -------------------------------------

GrgrLmml's avatar
GrgrLmml committed
159 160 161 162
     //pick up which model to use
     //get the wanted ped model id
     _model = xmltoi(xMainNode->FirstChildElement("agents")->Attribute("operational_model_id"), -1);
     if (_model==-1) {
Mohcine Chraibi's avatar
Mohcine Chraibi committed
163
          Log->Write("ERROR: \tmissing operational_model_id attribute in the agent section.");
GrgrLmml's avatar
GrgrLmml committed
164 165 166 167 168
          Log->Write("ERROR: \tplease specify the model id to use");
          return false;
     }

     bool parsingModelSuccessful = false;
169 170
     for (TiXmlElement* xModel = xMainNode->FirstChild("operational_models")->FirstChildElement("model");
                                        xModel; xModel = xModel->NextSiblingElement("model")) {
GrgrLmml's avatar
GrgrLmml committed
171
          if (!xModel->Attribute("description")) {
Mohcine Chraibi's avatar
Mohcine Chraibi committed
172
               Log->Write("ERROR: \t missing attribute description in models?");
GrgrLmml's avatar
GrgrLmml committed
173 174 175 176 177 178
               return false;
          }

          string modelName = string(xModel->Attribute("description"));
          int model_id = xmltoi(xModel->Attribute("operational_model_id"), -1);

carlos's avatar
works?  
carlos committed
179
          if ((_model==MODEL_GCFM) && (model_id==MODEL_GCFM)) {
GrgrLmml's avatar
GrgrLmml committed
180
               if (modelName!="gcfm") {
Mohcine Chraibi's avatar
Mohcine Chraibi committed
181
                    Log->Write("ERROR: \t mismatch model ID and description. Did you mean gcfm?");
GrgrLmml's avatar
GrgrLmml committed
182 183
                    return false;
               }
184
               if (!ParseGCFMModel(xModel, xMainNode))
GrgrLmml's avatar
GrgrLmml committed
185 186 187 188 189 190 191
                    return false;
               parsingModelSuccessful = true;
               //only parsing one model
               break;
          }
          else if ((_model==MODEL_GOMPERTZ) && (model_id==MODEL_GOMPERTZ)) {
               if (modelName!="gompertz") {
Mohcine Chraibi's avatar
Mohcine Chraibi committed
192
                    Log->Write("ERROR: \t mismatch model ID and description. Did you mean gompertz?");
GrgrLmml's avatar
GrgrLmml committed
193 194 195
                    return false;
               }
               //only parsing one model
196
               if (!ParseGompertzModel(xModel, xMainNode))
GrgrLmml's avatar
GrgrLmml committed
197 198 199 200 201 202
                    return false;
               parsingModelSuccessful = true;
               break;
          }
          else if ((_model==MODEL_GRADIENT) && (model_id==MODEL_GRADIENT)) {
               if (modelName!="gradnav") {
Mohcine Chraibi's avatar
Mohcine Chraibi committed
203
                    Log->Write("ERROR: \t mismatch model ID and description. Did you mean gradnav?");
GrgrLmml's avatar
GrgrLmml committed
204 205 206
                    return false;
               }
               //only parsing one model
207
               if (!ParseGradientModel(xModel, xMainNode))
GrgrLmml's avatar
GrgrLmml committed
208 209 210 211 212 213 214 215 216 217
                    return false;
               parsingModelSuccessful = true;
               break;
          }
          else if ((_model==MODEL_VELOCITY) && (model_id==MODEL_VELOCITY)) {
               if (modelName!="Tordeux2015") {
                    Log->Write("ERROR:\t mismatch model ID and description. Did you mean Tordeux2015?");
                    return false;
               }
               //only parsing one model
218
               if (!ParseVelocityModel(xModel, xMainNode))
GrgrLmml's avatar
GrgrLmml committed
219 220 221 222
                    return false;
               parsingModelSuccessful = true;
               break;
          }
223 224 225 226 227 228 229 230 231 232 233
          if ((_model==MODEL_KRAUSZ) && (model_id==MODEL_KRAUSZ)) {
               if (modelName!="krausz") {
                    Log->Write("ERROR: \t mismatch model ID and description. Did you mean krausz?");
                    return false;
               }
               if (!ParseKrauszModel(xModel, xMainNode))
                    return false;
               parsingModelSuccessful = true;
               //only parsing one model
               break;
          }
GrgrLmml's avatar
GrgrLmml committed
234 235 236
     }

     if (!parsingModelSuccessful) {
carlos's avatar
typo  
carlos committed
237
          Log->Write("ERROR: \tWrong model id [%d]. Choose 1 (GCFM), 2 (Gompertz),  3 (Tordeux2015) or 5 (Krausz)", _model);
GrgrLmml's avatar
GrgrLmml committed
238
          Log->Write("ERROR: \tPlease make sure that all models are specified in the operational_models section");
Mohcine Chraibi's avatar
Mohcine Chraibi committed
239
          Log->Write("ERROR: \tand make sure to use the same ID in the agent section");
GrgrLmml's avatar
GrgrLmml committed
240 241 242 243 244
          return false;
     }

     //route choice strategy
     TiXmlNode* xRouters = xMainNode->FirstChild("route_choice_models");
245
     TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
GrgrLmml's avatar
GrgrLmml committed
246

247
     if (!ParseRoutingStrategies(xRouters, xAgentDistri))
GrgrLmml's avatar
GrgrLmml committed
248 249 250 251 252
          return false;
     Log->Write("INFO: \tParsing the project file completed");
     return true;
}

253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
bool IniFileParser::ParseHeader(TiXmlNode* xHeader)
{
          //logfile
          if (xHeader->FirstChild("logfile")) {
               _config->SetErrorLogFile(
                    _config->GetProjectRootDir() + xHeader->FirstChild("logfile")->FirstChild()->Value());
               _config->SetLog(2);
               Log->Write("INFO:\tlogfile <%s>", _config->GetErrorLogFile().c_str());
          }
          Log->Write("----\nJuPedSim - JPScore\n");
          Log->Write("Current date   : %s %s", __DATE__, __TIME__);
          Log->Write("Version        : %s", JPSCORE_VERSION);
          Log->Write("Compiler       : %s (%s)", true_cxx.c_str(), true_cxx_ver.c_str());
          Log->Write("Commit hash    : %s", GIT_COMMIT_HASH);
          Log->Write("Commit date    : %s", GIT_COMMIT_DATE);
          Log->Write("Branch         : %s\n----\n", GIT_BRANCH);


          //seed
          if (xHeader->FirstChild("seed")) {
               TiXmlNode* seedNode = xHeader->FirstChild("seed")->FirstChild();
               if (seedNode) {
                    const char* seedValue = seedNode->Value();
                    _config->SetSeed((unsigned int)atoi(seedValue));//strtol
               }
               else {
                    _config->SetSeed((unsigned int)time(NULL));
               }
          }
          // srand(_config->GetSeed());
          Log->Write("INFO:\trandom seed <%d>", _config->GetSeed());

          // max simulation time
          if (xHeader->FirstChild("max_sim_time")) {
               const char* tmax =
                    xHeader->FirstChildElement("max_sim_time")->FirstChild()->Value();
               _config->SetTmax(atof(tmax));
               Log->Write("INFO: \tMaximal simulation time <%.2f> seconds", _config->GetTmax());
          }

          // Progressbar
          if (xHeader->FirstChild("progressbar")) {
               _config->SetPRB(true);
               Log->Write("INFO: \tUse Progressbar");
          }

          // geometry file name
          if (xHeader->FirstChild("geometry")) {
               std::string filename = xHeader->FirstChild("geometry")->FirstChild()->Value();
               _config->SetGeometryFile(filename);
               Log->Write("INFO: \tgeometry <%s>", filename.c_str());
          }


          //max CPU
          int max_threads = 1;
#ifdef _OPENMP
          max_threads = omp_get_max_threads();
#endif
          if (xHeader->FirstChild("num_threads")) {
               TiXmlNode* numthreads = xHeader->FirstChild("num_threads")->FirstChild();
               if (numthreads) {
#ifdef _OPENMP
                    omp_set_num_threads(xmltoi(numthreads->Value()));
#endif
               }
          }
          _config->SetMaxOpenMPThreads(omp_get_max_threads());
          Log->Write("INFO:\tUsing num_threads <%d> threads (%d available)", _config->GetMaxOpenMPThreads(), max_threads);

          //display statistics
          if (xHeader->FirstChild("show_statistics")) {
               std::string value = xHeader->FirstChild("show_statistics")->FirstChild()->Value();
               _config->SetShowStatistics(value=="true");
               Log->Write("INFO: \tShow statistics: %s", value.c_str());
          }

          //trajectories
          TiXmlNode* xTrajectories = xHeader->FirstChild("trajectories");
          if (xTrajectories) {
               double fps;
               xHeader->FirstChildElement("trajectories")->Attribute("fps", &fps);
               _config->SetFps(fps);

               string format =
                    xHeader->FirstChildElement("trajectories")->Attribute(
                         "format") ?
                    xHeader->FirstChildElement("trajectories")->Attribute(
                         "format") :
                    "xml-plain";
               int embedMesh = 0;
               if (xHeader->FirstChildElement("trajectories")->Attribute(
                        "embed_mesh")) {
                    embedMesh =
                         string(xHeader->FirstChildElement("trajectories")->Attribute("embed_mesh"))=="true" ? 1 : 0;
               }
               if (format=="xml-plain")
                    _config->SetFileFormat(FORMAT_XML_PLAIN);
               if (format=="xml-plain" && embedMesh==1)
                    _config->SetFileFormat(FORMAT_XML_PLAIN_WITH_MESH);
               if (format=="xml-bin")
                    _config->SetFileFormat(FORMAT_XML_BIN);
               if (format=="plain")
                    _config->SetFileFormat(FORMAT_PLAIN);
               if (format=="vtk")
                    _config->SetFileFormat(FORMAT_VTK);

               //color mode
               string color_mode =
                    xHeader->FirstChildElement("trajectories")->Attribute(
                         "color_mode") ?
                    xHeader->FirstChildElement("trajectories")->Attribute(
                         "color_mode") :
                    "velocity";

               if (color_mode=="velocity")
                    Pedestrian::SetColorMode(
                         AgentColorMode::BY_VELOCITY); //TODO: config parameter! does not belong to the pedestrian model, we should create a pedestrian config instead. [gl march '16]
               if (color_mode=="spotlight") Pedestrian::SetColorMode(AgentColorMode::BY_SPOTLIGHT);
               if (color_mode=="group") Pedestrian::SetColorMode(AgentColorMode::BY_GROUP);
               if (color_mode=="knowledge") Pedestrian::SetColorMode(AgentColorMode::BY_KNOWLEDGE);
               if (color_mode=="router") Pedestrian::SetColorMode(AgentColorMode::BY_ROUTER);
               if (color_mode=="final_goal") Pedestrian::SetColorMode(AgentColorMode::BY_FINAL_GOAL);
               if (color_mode=="intermediate_goal") Pedestrian::SetColorMode(AgentColorMode::BY_INTERMEDIATE_GOAL);




               //a file descriptor was given
               if (xTrajectories->FirstChild("file")) {
                    std::string tmp;
                    tmp = xTrajectories->FirstChildElement("file")->Attribute(
                         "location");
                    fs::path p(tmp);
                    fs::path curr_abs_path = fs::current_path();
                    fs::path rel_path = fs::path(_config->GetProjectRootDir()) / fs::path(tmp);
                    fs::path combined = (curr_abs_path /= rel_path);
                    std::string traj = combined.string();

                    if (traj.c_str())
                    {
                         _config->SetTrajectoriesFile(traj);
                         _config->SetOriginalTrajectoriesFile(traj);
                    }


                    Log->Write("INFO: \toutput file  <%s>", _config->GetTrajectoriesFile().c_str());
                    Log->Write("INFO: \tin format <%s> at <%.0f> frames per seconds",format.c_str(), _config->GetFps());
               }

               if (xTrajectories->FirstChild("socket")) {
                    std::string tmp =
                         xTrajectories->FirstChildElement("socket")->Attribute("hostname");
                    if (tmp.c_str())
                         _config->SetHostname(tmp);
                    int port;
                    xTrajectories->FirstChildElement("socket")->Attribute("port", &port);
                    _config->SetPort(port);
                    Log->Write("INFO: \tStreaming results to output [%s:%d] ",
                               _config->GetHostname().c_str(), _config->GetPort());
               }
          }

}
417
bool IniFileParser::ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMainNode)
GrgrLmml's avatar
GrgrLmml committed
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
{
     Log->Write("\nINFO:\tUsing the GCFM model");
     Log->Write("INFO:\tParsing the model parameters");

     TiXmlNode* xModelPara = xGCFM->FirstChild("model_parameters");
     if (!xModelPara) {
          Log->Write("ERROR: \t !!!! Changes in the operational model section !!!");
          Log->Write("ERROR: \t !!!! The new version is in inputfiles/ship_msw/ini_ship2.xml !!!");
          return false;
     }

     // For convenience. This moved to the header as it is not model specific
     if (xModelPara->FirstChild("tmax")) {
          Log->Write(
                    "ERROR: \tthe maximal simulation time section moved to the header!!!");
          Log->Write("ERROR: \t\t <max_sim_time> </max_sim_time>\n");
          return false;
     }

     //solver
     if (!ParseNodeToSolver(*xModelPara))
          return false;

     //stepsize
     if (!ParseStepSize(*xModelPara))
          return false;

     //exit crossing strategy
     if (!ParseStrategyNodeToObject(*xModelPara))
          return false;

     //linked-cells
     if (!ParseLinkedCells(*xModelPara))
          return false;

     //force_ped
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
         if (xModelPara->FirstChild("force_ped")) {
                 string nu = xModelPara->FirstChildElement("force_ped")->Attribute("nu");
                 string dist_max = xModelPara->FirstChildElement("force_ped")->Attribute(
                         "dist_max");
                 string disteff_max =
                         xModelPara->FirstChildElement("force_ped")->Attribute(
                                 "disteff_max"); // @todo: rename disteff_max to force_max
                 string interpolation_width =
                         xModelPara->FirstChildElement("force_ped")->Attribute(
                                 "interpolation_width");

                 _config->SetMaxFPed(atof(dist_max.c_str()));
                 _config->SetNuPed(atof(nu.c_str()));
                 _config->SetDistEffMaxPed(atof(disteff_max.c_str()));
                 _config->SetIntPWidthPed(atof(interpolation_width.c_str()));
                 Log->Write(
                         "INFO: \tfrep_ped nu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
                         atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
         }
GrgrLmml's avatar
GrgrLmml committed
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489

     //force_wall
     if (xModelPara->FirstChild("force_wall")) {
          string nu = xModelPara->FirstChildElement("force_wall")->Attribute("nu");
          string dist_max = xModelPara->FirstChildElement("force_wall")->Attribute(
                    "dist_max");
          string disteff_max =
                    xModelPara->FirstChildElement("force_wall")->Attribute(
                              "disteff_max");
          string interpolation_width =
                    xModelPara->FirstChildElement("force_wall")->Attribute(
                              "interpolation_width");
          _config->SetMaxFWall(atof(dist_max.c_str()));
          _config->SetNuWall(atof(nu.c_str()));
          _config->SetDistEffMaxWall(atof(disteff_max.c_str()));
          _config->SetIntPWidthWall(atof(interpolation_width.c_str()));
          Log->Write(
Mohcine Chraibi's avatar
Mohcine Chraibi committed
490
                    "INFO: \tfrep_wall mu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
491
                          atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
GrgrLmml's avatar
GrgrLmml committed
492 493 494
     }

     //Parsing the agent parameters
495 496
     TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
     ParseAgentParameters(xGCFM, xAgentDistri);
GrgrLmml's avatar
GrgrLmml committed
497 498

     //TODO: models do not belong in a configuration container [gl march '16]
499
     _config->SetModel(std::shared_ptr<OperationalModel>(new GCFMModel(_exit_strategy, _config->GetNuPed(),
GrgrLmml's avatar
GrgrLmml committed
500 501 502 503 504 505 506 507
               _config->GetNuWall(), _config->GetDistEffMaxPed(),
               _config->GetDistEffMaxWall(), _config->GetIntPWidthPed(),
               _config->GetIntPWidthWall(), _config->GetMaxFPed(),
               _config->GetMaxFWall())));

     return true;
}

508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
bool IniFileParser::ParseKrauszModel(TiXmlElement* xKrausz, TiXmlElement* xMainNode)
{
     Log->Write("\nINFO:\tUsing the Krausz model");
     Log->Write("INFO:\tParsing the model parameters");

     TiXmlNode* xModelPara = xKrausz->FirstChild("model_parameters");
     if (!xModelPara) {
          Log->Write("ERROR: \t !!!! Changes in the operational model section !!!");
          Log->Write("ERROR: \t !!!! The new version is in inputfiles/ship_msw/ini_ship2.xml !!!");
          return false;
     }

     // For convenience. This moved to the header as it is not model specific
     if (xModelPara->FirstChild("tmax")) {
          Log->Write(
                  "ERROR: \tthe maximal simulation time section moved to the header!!!");
          Log->Write("ERROR: \t\t <max_sim_time> </max_sim_time>\n");
          return false;
     }

     //solver
     if (!ParseNodeToSolver(*xModelPara))
          return false;

     //stepsize
     if (!ParseStepSize(*xModelPara))
          return false;

     //exit crossing strategy
     if (!ParseStrategyNodeToObject(*xModelPara))
          return false;

     //linked-cells
     if (!ParseLinkedCells(*xModelPara))
          return false;

     //force_ped
     if (xModelPara->FirstChild("force_ped")) {
          string nu = xModelPara->FirstChildElement("force_ped")->Attribute("nu");
          string dist_max = xModelPara->FirstChildElement("force_ped")->Attribute(
                  "dist_max");
          string disteff_max =
                  xModelPara->FirstChildElement("force_ped")->Attribute(
                          "disteff_max"); // @todo: rename disteff_max to force_max
          string interpolation_width =
                  xModelPara->FirstChildElement("force_ped")->Attribute(
                          "interpolation_width");

          _config->SetMaxFPed(atof(dist_max.c_str()));
          _config->SetNuPed(atof(nu.c_str()));
          _config->SetDistEffMaxPed(atof(disteff_max.c_str()));
          _config->SetIntPWidthPed(atof(interpolation_width.c_str()));
          Log->Write(
                  "INFO: \tfrep_ped nu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
562
                          atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
     }

     //force_wall
     if (xModelPara->FirstChild("force_wall")) {
          string nu = xModelPara->FirstChildElement("force_wall")->Attribute("nu");
          string dist_max = xModelPara->FirstChildElement("force_wall")->Attribute(
                  "dist_max");
          string disteff_max =
                  xModelPara->FirstChildElement("force_wall")->Attribute(
                          "disteff_max");
          string interpolation_width =
                  xModelPara->FirstChildElement("force_wall")->Attribute(
                          "interpolation_width");
          _config->SetMaxFWall(atof(dist_max.c_str()));
          _config->SetNuWall(atof(nu.c_str()));
          _config->SetDistEffMaxWall(atof(disteff_max.c_str()));
          _config->SetIntPWidthWall(atof(interpolation_width.c_str()));
          Log->Write(
                  "INFO: \tfrep_wall mu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
582
                          atof(nu.c_str()), atof(dist_max.c_str()), atof(disteff_max.c_str()), atof(interpolation_width.c_str()));
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
     }

     //Parsing the agent parameters
     TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
     ParseAgentParameters(xKrausz, xAgentDistri);

     //TODO: models do not belong in a configuration container [gl march '16]
     _config->SetModel(std::shared_ptr<OperationalModel>(new KrauszModel(_exit_strategy, _config->GetNuPed(),
                                                                         _config->GetNuWall(), _config->GetDistEffMaxPed(),
                                                                         _config->GetDistEffMaxWall(), _config->GetIntPWidthPed(),
                                                                         _config->GetIntPWidthWall(), _config->GetMaxFPed(),
                                                                         _config->GetMaxFWall())));
     return true;
}

598
bool IniFileParser::ParseGompertzModel(TiXmlElement* xGompertz, TiXmlElement* xMainNode)
GrgrLmml's avatar
GrgrLmml committed
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
{
     //parsing the model parameters
     Log->Write("\nINFO:\tUsing the Gompertz model");

     Log->Write("INFO:\tParsing the model parameters");

     TiXmlNode* xModelPara = xGompertz->FirstChild("model_parameters");
     if (!xModelPara) {
          Log->Write("ERROR: \t !!!! Changes in the operational model section !!!");
          Log->Write("ERROR: \t !!!! The new version is in inputfiles/ship_msw/ini_ship3.xml !!!");
          return false;
     }

     // For convenience. This moved to the header as it is not model specific
     if (xModelPara->FirstChild("tmax")) {
          Log->Write("ERROR: \tthe maximal simulation time section moved to the header!!!");
          Log->Write("ERROR: \t\t <max_sim_time> </max_sim_time>\n");
          return false;
     }

     //solver
     if (!ParseNodeToSolver(*xModelPara))
          return false;

     //stepsize
     if (!ParseStepSize(*xModelPara))
          return false;

     //exit crossing strategy
     if (!ParseStrategyNodeToObject(*xModelPara))
          return false;

     //linked-cells
     if (!ParseLinkedCells(*xModelPara))
          return false;

     //force_ped
     if (xModelPara->FirstChild("force_ped")) {
          string nu = xModelPara->FirstChildElement("force_ped")->Attribute("nu");
          _config->SetNuPed(atof(nu.c_str()));

          if (!xModelPara->FirstChildElement("force_ped")->Attribute("a"))
               _config->SetaPed(1.0); // default value
          else {
               string a = xModelPara->FirstChildElement("force_ped")->Attribute("a");
               _config->SetaPed(atof(a.c_str()));
          }
          if (!xModelPara->FirstChildElement("force_ped")->Attribute("b"))
               _config->SetbPed(0.25); // default value
          else {
               string b = xModelPara->FirstChildElement("force_ped")->Attribute("b");
               _config->SetbPed(atof(b.c_str()));
          }
          if (!xModelPara->FirstChildElement("force_ped")->Attribute("c"))
               _config->SetcPed(3.0); // default value
          else {
               string c = xModelPara->FirstChildElement("force_ped")->Attribute("c");
               _config->SetcPed(atof(c.c_str()));
          }
          Log->Write("INFO: \tfrep_ped mu=%s, a=%0.2f, b=%0.2f c=%0.2f", nu.c_str(), _config->GetaPed(),
                    _config->GetbPed(), _config->GetcPed());
     }
     //force_wall
     if (xModelPara->FirstChild("force_wall")) {
          string nu = xModelPara->FirstChildElement("force_wall")->Attribute("nu");
          _config->SetNuWall(atof(nu.c_str()));
          if (!xModelPara->FirstChildElement("force_wall")->Attribute("a"))
               _config->SetaWall(1.0); // default value
          else {
               string a = xModelPara->FirstChildElement("force_wall")->Attribute("a");
               _config->SetaWall(atof(a.c_str()));
          }
          if (!xModelPara->FirstChildElement("force_wall")->Attribute("b"))
               _config->SetbWall(0.7); // default value
          else {
               string b = xModelPara->FirstChildElement("force_wall")->Attribute("b");
               _config->SetbWall(atof(b.c_str()));
          }
          if (!xModelPara->FirstChildElement("force_wall")->Attribute("c"))
               _config->SetcWall(3.0); // default value
          else {
               string c = xModelPara->FirstChildElement("force_wall")->Attribute("c");
               _config->SetcWall(atof(c.c_str()));
          }

          Log->Write("INFO: \tfrep_wall mu=%s, a=%0.2f, b=%0.2f c=%0.2f", nu.c_str(), _config->GetaWall(),
                    _config->GetbWall(), _config->GetcWall());
     }

     //Parsing the agent parameters
689 690
     TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
     ParseAgentParameters(xGompertz, xAgentDistri);
GrgrLmml's avatar
GrgrLmml committed
691 692 693 694 695 696 697 698 699 700

     //TODO: models do not belong in a configuration container [gl march '16]
     _config->SetModel(std::shared_ptr<OperationalModel>(new GompertzModel(_exit_strategy, _config->GetNuPed(),
               _config->GetaPed(), _config->GetbPed(), _config->GetcPed(),
               _config->GetNuWall(), _config->GetaWall(), _config->GetbWall(),
               _config->GetcWall())));

     return true;
}

701
bool IniFileParser::ParseGradientModel(TiXmlElement* xGradient, TiXmlElement* xMainNode)
GrgrLmml's avatar
GrgrLmml committed
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744
{
     //parsing the model parameters
     Log->Write("\nINFO:\tUsing the Gradient model");

     Log->Write("INFO:\tParsing the model parameters");

     TiXmlNode* xModelPara = xGradient->FirstChild("model_parameters");

     if (!xModelPara) {
          Log->Write("ERROR: \t !!!! Changes in the operational model section !!!");
          Log->Write("ERROR: \t !!!! The new version is in inputfiles/ship_msw/ini_ship3.xml !!!");
          return false;
     }

     // For convenience. This moved to the header as it is not model specific
     if (xModelPara->FirstChild("tmax")) {
          Log->Write("ERROR: \tthe maximal simulation time section moved to the header!!!");
          Log->Write("ERROR: \t\t <max_sim_time> </max_sim_time>\n");
          return false;
     }

     //solver
     if (!ParseNodeToSolver(*xModelPara))
          return false;

     //stepsize
     if (!ParseStepSize(*xModelPara))
          return false;

     //exit crossing strategy
     if (!ParseStrategyNodeToObject(*xModelPara))
          return false;

     //floorfield
     double pDeltaH = 0., pWallAvoidDistance = 0., pSlowDownDistance = 0.; //TODO: should be moved to configuration [gl march '16]
     bool pUseWallAvoidance = false;
     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());
          }
f.mack's avatar
f.mack committed
745
          _config->set_deltaH(pDeltaH);
GrgrLmml's avatar
GrgrLmml committed
746 747 748 749 750 751 752 753

          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());
          }
f.mack's avatar
f.mack committed
754
          _config->set_wall_avoid_distance(pWallAvoidDistance);
GrgrLmml's avatar
GrgrLmml committed
755 756 757 758 759 760 761

          if (!xModelPara->FirstChildElement("floorfield")->Attribute("use_wall_avoidance"))
               pUseWallAvoidance = true; // default value
          else {
               string use_wall_avoidance = xModelPara->FirstChildElement("floorfield")->Attribute("use_wall_avoidance");
               pUseWallAvoidance = !(use_wall_avoidance=="false");
          }
f.mack's avatar
f.mack committed
762
          _config->set_use_wall_avoidance(pUseWallAvoidance);
GrgrLmml's avatar
GrgrLmml committed
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
          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))
          return false;


     //force_ped
     if (xModelPara->FirstChild("force_ped")) {
          string nu = xModelPara->FirstChildElement("force_ped")->Attribute("nu");
          _config->SetNuPed(atof(nu.c_str()));

          if (!xModelPara->FirstChildElement("force_ped")->Attribute("a"))
               _config->SetaPed(1.0); // default value
          else {
               string a = xModelPara->FirstChildElement("force_ped")->Attribute("a");
               _config->SetaPed(atof(a.c_str()));
          }

          if (!xModelPara->FirstChildElement("force_ped")->Attribute("b"))
               _config->SetbPed(0.25); // default value
          else {
               string b = xModelPara->FirstChildElement("force_ped")->Attribute("b");
               _config->SetbPed(atof(b.c_str()));
          }
          if (!xModelPara->FirstChildElement("force_ped")->Attribute("c"))
               _config->SetcPed(3.0); // default value
          else {
               string c = xModelPara->FirstChildElement("force_ped")->Attribute("c");
               _config->SetcPed(atof(c.c_str()));
          }
          Log->Write("INFO: \tfrep_ped mu=%s, a=%0.2f, b=%0.2f c=%0.2f", nu.c_str(), _config->GetaPed(),
                    _config->GetbPed(), _config->GetcPed());
     }
     //force_wall
     if (xModelPara->FirstChild("force_wall")) {
          string nu = xModelPara->FirstChildElement("force_wall")->Attribute("nu");
          _config->SetNuWall(atof(nu.c_str()));

          if (!xModelPara->FirstChildElement("force_wall")->Attribute("a"))
               _config->SetaWall(1.0); // default value
          else {
               string a = xModelPara->FirstChildElement("force_wall")->Attribute("a");
               _config->SetaWall(atof(a.c_str()));
          }

          if (!xModelPara->FirstChildElement("force_wall")->Attribute("b"))
               _config->SetbWall(0.7); // default value
          else {
               string b = xModelPara->FirstChildElement("force_wall")->Attribute("b");
               _config->SetbWall(atof(b.c_str()));
          }
          if (!xModelPara->FirstChildElement("force_wall")->Attribute("c"))
               _config->SetcWall(3.0); // default value
          else {
               string c = xModelPara->FirstChildElement("force_wall")->Attribute("c");
               _config->SetcWall(atof(c.c_str()));
          }
          Log->Write("INFO: \tfrep_wall mu=%s, a=%0.2f, b=%0.2f c=%0.2f", nu.c_str(), _config->GetaWall(),
                    _config->GetbWall(), _config->GetcWall());
     }
     //anti_clipping
     if (xModelPara->FirstChild("anti_clipping")) {
          if (!xModelPara->FirstChildElement("anti_clipping")->Attribute("slow_down_distance"))
               pSlowDownDistance = .2; //default value
          else {
               string slow_down_distance = xModelPara->FirstChildElement("anti_clipping")->Attribute(
                         "slow_down_distance");
               pSlowDownDistance = atof(slow_down_distance.c_str());
          }
f.mack's avatar
f.mack committed
835
          _config->set_slow_down_distance(pSlowDownDistance);
GrgrLmml's avatar
GrgrLmml committed
836 837 838 839
          Log->Write("INFO: \tAnti Clipping: SlowDown Distance=%0.2f", pSlowDownDistance);
     }

     //Parsing the agent parameters
840 841
     TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
     ParseAgentParameters(xGradient, xAgentDistri);
GrgrLmml's avatar
GrgrLmml committed
842 843

     //TODO: models do not belong in a configuration container [gl march '16]
844
     _config->SetModel(std::shared_ptr<OperationalModel>(new GradientModel(_exit_strategy, _config->GetNuPed(),
GrgrLmml's avatar
GrgrLmml committed
845 846
               _config->GetaPed(), _config->GetbPed(), _config->GetcPed(),
               _config->GetNuWall(), _config->GetaWall(), _config->GetbWall(),
f.mack's avatar
f.mack committed
847 848
               _config->GetcWall(), _config->get_deltaH(), _config->get_wall_avoid_distance(), _config->get_use_wall_avoidance(),
               _config->get_slow_down_distance())));
GrgrLmml's avatar
GrgrLmml committed
849 850 851 852

     return true;
}

853
bool IniFileParser::ParseVelocityModel(TiXmlElement* xVelocity, TiXmlElement* xMainNode)
GrgrLmml's avatar
GrgrLmml committed
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932
{
     //parsing the model parameters
     Log->Write("\nINFO:\tUsing Tordeux2015 model");
     Log->Write("INFO:\tParsing the model parameters");

     TiXmlNode* xModelPara = xVelocity->FirstChild("model_parameters");

     if (!xModelPara) {
          Log->Write("ERROR: \t !!!! Changes in the operational model section !!!");
          Log->Write("ERROR: \t !!!! The new version is in inputfiles/ship_msw/ini_ship3.xml !!!");
          return false;
     }

     // For convenience. This moved to the header as it is not model specific
     if (xModelPara->FirstChild("tmax")) {
          Log->Write("ERROR: \tthe maximal simulation time section moved to the header!!!");
          Log->Write("ERROR: \t\t <max_sim_time> </max_sim_time>\n");
          return false;
     }

     //solver
     if (!ParseNodeToSolver(*xModelPara))
          return false;

     //stepsize
     if (!ParseStepSize(*xModelPara))
          return false;

     //exit crossing strategy
     if (!ParseStrategyNodeToObject(*xModelPara))
          return false;

     //linked-cells
     if (!ParseLinkedCells(*xModelPara))
          return false;

     //periodic
     if (!ParsePeriodic(*xModelPara))
          return false;

     //force_ped
     if (xModelPara->FirstChild("force_ped")) {

          if (!xModelPara->FirstChildElement("force_ped")->Attribute("a"))
               _config->SetaPed(1.0); // default value
          else {
               string a = xModelPara->FirstChildElement("force_ped")->Attribute("a");
               _config->SetaPed(atof(a.c_str()));
          }

          if (!xModelPara->FirstChildElement("force_ped")->Attribute("D"))
               _config->SetDPed(0.1); // default value in [m]
          else {
               string D = xModelPara->FirstChildElement("force_ped")->Attribute("D");
               _config->SetDPed(atof(D.c_str()));
          }
          Log->Write("INFO: \tfrep_ped a=%0.2f, D=%0.2f", _config->GetaPed(), _config->GetDPed());

     }
     //force_wall
     if (xModelPara->FirstChild("force_wall")) {

          if (!xModelPara->FirstChildElement("force_wall")->Attribute("a"))
               _config->SetaWall(1.0); // default value
          else {
               string a = xModelPara->FirstChildElement("force_wall")->Attribute("a");
               _config->SetaWall(atof(a.c_str()));
          }

          if (!xModelPara->FirstChildElement("force_wall")->Attribute("D"))
               _config->SetDWall(0.1); // default value in [m]
          else {
               string D = xModelPara->FirstChildElement("force_wall")->Attribute("D");
               _config->SetDWall(atof(D.c_str()));
          }
          Log->Write("INFO: \tfrep_wall a=%0.2f, D=%0.2f", _config->GetaWall(), _config->GetDWall());
     }

     //Parsing the agent parameters
933 934
     TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
     ParseAgentParameters(xVelocity, xAgentDistri);
935
     _config->SetModel(std::shared_ptr<OperationalModel>(new VelocityModel(_exit_strategy, _config->GetaPed(),
GrgrLmml's avatar
GrgrLmml committed
936 937 938 939 940 941
               _config->GetDPed(), _config->GetaWall(),
               _config->GetDWall())));

     return true;
}

942
void IniFileParser::ParseAgentParameters(TiXmlElement* operativModel, TiXmlNode* agentsDistri)
GrgrLmml's avatar
GrgrLmml committed
943 944 945
{
     //Parsing the agent parameters
     Log->Write("\nINFO:\tParsing agents  parameters");
946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
     //first get list of actually used router
     std::vector<int> usedAgentParams;
     usedAgentParams.clear();
     for (TiXmlElement* e = agentsDistri->FirstChildElement("group"); e;
          e = e->NextSiblingElement("group")) {
          int agentsParams = -1;
          if (e->Attribute("agent_parameter_id")) {
               agentsParams = atoi(e->Attribute("agent_parameter_id"));
               if(std::find(usedAgentParams.begin(), usedAgentParams.end(), agentsParams) == usedAgentParams.end()) {
                    usedAgentParams.emplace_back(agentsParams);
               }
          }
     }
     for(TiXmlElement* xAgentPara = operativModel->FirstChildElement("agent_parameters"); xAgentPara;
         xAgentPara = xAgentPara->NextSiblingElement("agent_parameters")) {
GrgrLmml's avatar
GrgrLmml committed
961 962

          //get the group ID
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
          int para_id= xmltoi(xAgentPara->Attribute("agent_parameter_id"),-1);
          if (std::find(usedAgentParams.begin(), usedAgentParams.end(), para_id) != usedAgentParams.end() ) {
               Log->Write("INFO: \tParsing the group parameter id [%d]", para_id);

               auto agentParameters = std::shared_ptr<AgentsParameters>(new AgentsParameters(para_id, _config->GetSeed()));
               _config->AddAgentsParameters(agentParameters, para_id);

               //desired speed
               if (xAgentPara->FirstChild("v0")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("v0")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("v0")->Attribute("sigma"));
                    agentParameters->InitV0(mu, sigma);
                    agentParameters->InitV0DownStairs(mu, sigma);
                    agentParameters->InitV0UpStairs(mu, sigma);
                    Log->Write("INFO: \tdesired speed mu=%f , sigma=%f", mu, sigma);
               }

               if (xAgentPara->FirstChild("v0_upstairs")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("v0_upstairs")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("v0_upstairs")->Attribute("sigma"));
                    agentParameters->InitV0UpStairs(mu, sigma);
                    Log->Write("INFO: \tdesired speed upstairs mu=%f , sigma=%f", mu, sigma);
               }

               if (xAgentPara->FirstChild("v0_downstairs")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("v0_downstairs")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("v0_downstairs")->Attribute("sigma"));
                    agentParameters->InitV0DownStairs(mu, sigma);
                    Log->Write("INFO: \tdesired speed downstairs mu=%f , sigma=%f", mu, sigma);
               }//------------------------------------------------------------------------
               if (xAgentPara->FirstChild("escalator_upstairs")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("escalator_upstairs")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("escalator_upstairs")->Attribute("sigma"));
                    agentParameters->InitEscalatorUpStairs(mu, sigma);
                    Log->Write("INFO: \tspeed of escalator upstairs mu=%f , sigma=%f", mu, sigma);
               }
               if (xAgentPara->FirstChild("escalator_downstairs")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("escalator_downstairs")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("escalator_downstairs")->Attribute("sigma"));
                    agentParameters->InitEscalatorDownStairs(mu, sigma);
                    Log->Write("INFO: \tspeed of escalator downstairs mu=%f , sigma=%f", mu, sigma);
               }
               if (xAgentPara->FirstChild("v0_idle_escalator_upstairs")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("v0_idle_escalator_upstairs")->Attribute("mu"));
                    double sigma = xmltof(
                              xAgentPara->FirstChildElement("v0_idle_escalator_upstairs")->Attribute("sigma"));
                    agentParameters->InitV0IdleEscalatorUpStairs(mu, sigma);
                    Log->Write("INFO: \tdesired speed idle escalator upstairs mu=%f , sigma=%f", mu, sigma);
               }
               if (xAgentPara->FirstChild("v0_idle_escalator_downstairs")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("v0_idle_escalator_downstairs")->Attribute("mu"));
                    double sigma = xmltof(
                              xAgentPara->FirstChildElement("v0_idle_escalator_downstairs")->Attribute("sigma"));
                    agentParameters->InitV0IdleEscalatorDownStairs(mu, sigma);
                    Log->Write("INFO: \tdesired speed idle escalator downstairs mu=%f , sigma=%f", mu, sigma);
               }
               //------------------------------------------------------------------------

               //bmax
               if (xAgentPara->FirstChild("bmax")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("bmax")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("bmax")->Attribute("sigma"));
                    agentParameters->InitBmax(mu, sigma);
                    Log->Write("INFO: \tBmax mu=%f , sigma=%f", mu, sigma);
               }

               //bmin
               if (xAgentPara->FirstChild("bmin")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("bmin")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("bmin")->Attribute("sigma"));
                    agentParameters->InitBmin(mu, sigma);
                    Log->Write("INFO: \tBmin mu=%f , sigma=%f", mu, sigma);
               }

               //amin
               if (xAgentPara->FirstChild("amin")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("amin")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("amin")->Attribute("sigma"));
                    agentParameters->InitAmin(mu, sigma);
                    Log->Write("INFO: \tAmin mu=%f , sigma=%f", mu, sigma);
               }
               //tau
               if (xAgentPara->FirstChild("tau")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("tau")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("tau")->Attribute("sigma"));
                    agentParameters->InitTau(mu, sigma);
                    Log->Write("INFO: \tTau mu=%f , sigma=%f", mu, sigma);
               }
               //atau
               if (xAgentPara->FirstChild("atau")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("atau")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("atau")->Attribute("sigma"));
                    agentParameters->InitAtau(mu, sigma);
                    Log->Write("INFO: \tAtau mu=%f , sigma=%f", mu, sigma);
               }
               // T
               if (xAgentPara->FirstChild("T")) {
                    double mu = xmltof(xAgentPara->FirstChildElement("T")->Attribute("mu"));
                    double sigma = xmltof(xAgentPara->FirstChildElement("T")->Attribute("sigma"));
                    agentParameters->InitT(mu, sigma);
                    Log->Write("INFO: \tT mu=%f , sigma=%f", mu, sigma);
               }
1065 1066 1067 1068 1069 1070 1071
               // swaying parameters
               if (xAgentPara->FirstChild("sway")) {
                    double freqA = xmltof(xAgentPara->FirstChildElement("sway")->Attribute("freqA"));
                    double freqB = xmltof(xAgentPara->FirstChildElement("sway")->Attribute("freqB"));
                    double ampA = xmltof(xAgentPara->FirstChildElement("sway")->Attribute("ampA"));
                    double ampB = xmltof(xAgentPara->FirstChildElement("sway")->Attribute("ampB"));
                    agentParameters->SetSwayParams(freqA, freqB, ampA, ampB);
carlos's avatar
carlos committed
1072
                    Log->Write("INFO: \tSwaying parameters freqA=%f , freqB=%f , ampA=%f, ampB=%f");
1073
               }
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084

               if (_model == 2) { // Gompertz
                    double beta_c = 1; /// @todo quick and dirty
                    double max_Ea = agentParameters->GetAmin() + agentParameters->GetAtau() * agentParameters->GetV0();
                    double max_Eb = 0.5 * (agentParameters->GetBmin() +
                                           0.49); /// @todo hard-coded value should be the same as in pedestrians GetEB
                    double max_Ea_Eb = (max_Ea > max_Eb) ? max_Ea : max_Eb;
                    _config->SetDistEffMaxPed(2 * beta_c * max_Ea_Eb);
                    _config->SetDistEffMaxWall(_config->GetDistEffMaxPed());
               }

Arne Graf's avatar
Arne Graf committed
1085
               if (_model == 4) { //  Gradient
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099
                    double beta_c = 2; /// @todo quick and dirty
                    double max_Ea = agentParameters->GetAmin() + agentParameters->GetAtau() * agentParameters->GetV0();
                    double max_Eb = 0.5 * (agentParameters->GetBmin() +
                                           0.49); /// @todo hard-coded value should be the same as in pedestrians GetEB
                    double max_Ea_Eb = (max_Ea > max_Eb) ? max_Ea : max_Eb;
                    _config->SetDistEffMaxPed(2 * beta_c * max_Ea_Eb);
                    _config->SetDistEffMaxWall(_config->GetDistEffMaxPed());
               }

               if (_model == 3) { // Tordeux2015
                    double max_Eb = 2 * agentParameters->GetBmax();
                    _config->SetDistEffMaxPed(max_Eb+agentParameters->GetT()*agentParameters->GetV0());
                    _config->SetDistEffMaxWall(_config->GetDistEffMaxPed());
               }
1100 1101 1102

               if (_model == 5) // Krausz
               {
1103
                    agentParameters->EnableStretch(false);
1104
               }
GrgrLmml's avatar
GrgrLmml committed
1105 1106 1107 1108
          }
     }
}

1109
bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* agentsDistri)
GrgrLmml's avatar
GrgrLmml committed
1110 1111 1112 1113 1114
{
     if (!routingNode) {
          Log->Write("ERROR: \t route_choice_models section is missing");
          return false;
     }
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140

     if (!agentsDistri) {
          Log->Write("ERROR: \t Agent Distribution section is missing");
          return false;
     }
     //first get list of actually used router
     std::vector<int> usedRouter;
     usedRouter.clear();
     bool hasSpecificGoals = false;
     for (TiXmlElement* e = agentsDistri->FirstChildElement("group"); e;
          e = e->NextSiblingElement("group")) {
          int router = -1;
          if (e->Attribute("router_id")) {
               router = atoi(e->Attribute("router_id"));
               if(std::find(usedRouter.begin(), usedRouter.end(), router) == usedRouter.end()) {
                    usedRouter.emplace_back(router);
               }
          }
          int goal = -1;
          if (e->Attribute("goal_id")) {
               goal = atoi(e->Attribute("goal_id"));
               if (goal != -1) {
                    hasSpecificGoals = true;
               }
          }
     }
Arne Graf's avatar
Arne Graf committed
1141
     _config->set_has_specific_goals(hasSpecificGoals);
GrgrLmml's avatar
GrgrLmml committed
1142 1143 1144 1145 1146 1147
     for (TiXmlElement* e = routingNode->FirstChildElement("router"); e;
          e = e->NextSiblingElement("router")) {

          string strategy = e->Attribute("description");
          int id = atoi(e->Attribute("router_id"));

1148 1149 1150 1151
          if ((strategy == "local_shortest") &&
              (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
               //pRoutingStrategies.push_back(make_pair(id, ROUTING_LOCAL_SHORTEST));
               Router *r = new GlobalRouter(id, ROUTING_LOCAL_SHORTEST);
GrgrLmml's avatar
GrgrLmml committed
1152 1153
               _config->GetRoutingEngine()->AddRouter(r);
          }
1154 1155 1156 1157
          else if ((strategy == "global_shortest") &&
                   (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
               //pRoutingStrategies.push_back(make_pair(id, ROUTING_GLOBAL_SHORTEST));
               Router *r = new GlobalRouter(id, ROUTING_GLOBAL_SHORTEST);
GrgrLmml's avatar
GrgrLmml committed
1158 1159
               _config->GetRoutingEngine()->AddRouter(r);
          }
1160 1161 1162 1163
          else if ((strategy == "quickest")  &&
                   (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
               //pRoutingStrategies.push_back(make_pair(id, ROUTING_QUICKEST));
               Router *r = new QuickestPathRouter(id, ROUTING_QUICKEST);
GrgrLmml's avatar
GrgrLmml committed
1164 1165
               _config->GetRoutingEngine()->AddRouter(r);
          }
1166
          else if ((strategy == "smoke") &&
1167
                   (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
1168
#ifndef JPSFIRE
Mohcine Chraibi's avatar
Mohcine Chraibi committed
1169
               std::cerr << "\nCan not use smoke router without jpsfire. Rerun cmake with option  -DJPSFIRE=true and recompile.\n";
1170 1171
               exit(EXIT_FAILURE);
#endif
1172
               Router *r = new SmokeRouter(id, ROUTING_SMOKE);
GrgrLmml's avatar
GrgrLmml committed
1173 1174
               _config->GetRoutingEngine()->AddRouter(r);

1175
               Log->Write("\nINFO: \tUsing SmokeRouter");
GrgrLmml's avatar
GrgrLmml committed
1176 1177 1178 1179
               ///Parsing additional options
               if (!ParseCogMapOpts(e))
                    return false;
          }
1180 1181
          else if ((strategy == "AI") &&
                   (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
1182
     #ifdef AIROUTER
1183 1184 1185 1186 1187 1188 1189
               Router *r = new AIRouter(id, ROUTING_AI);
               _config->GetRoutingEngine()->AddRouter(r);

               Log->Write("\nINFO: \tUsing AIRouter");
               ///Parsing additional options
               if (!ParseAIOpts(e))
                    return false;
Mohcine Chraibi's avatar
Mohcine Chraibi committed
1190 1191 1192
     #else
               std::cerr << "\nCan not use AI Router. Rerun cmake with option  -DAIROUTER=true and recompile.\n";
               exit(EXIT_FAILURE);
1193
     #endif
1194
          }
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
//                    else if ((strategy == "AI_trips") &&
//                   (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
//     #ifdef AIROUTER
//               Router *r = new AIRouterTrips(id, ROUTING_AI_TRIPS);
//               _config->GetRoutingEngine()->AddRouter(r);
//
//               Log->Write("\nINFO: \tUsing AIRouter Trips");
//               ///Parsing additional options
//               if (!ParseAIOpts(e))
//                    return false;
//     #else
//               std::cerr << "\nCan not use AI Router. Rerun cmake with option  -DAIROUTER=true and recompile.\n";
//               exit(EXIT_FAILURE);
//     #endif
//          }
1210 1211

          else if ((strategy == "ff_global_shortest_trips") &&
1212 1213
                   (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
               //pRoutingStrategies.push_back(make_pair(id, ROUTING_FF_GLOBAL_SHORTEST));
1214
               Router *r = new FFRouterTrips(id, ROUTING_FF_GLOBAL_SHORTEST, hasSpecificGoals, _config);
1215
               _config->GetRoutingEngine()->AddRouter(r);
1216

Arne Graf's avatar
Arne Graf committed
1217
               if ((_exit_strat_number == 8) || (_exit_strat_number == 9)){
1218
                   Log->Write("\nINFO: \tUsing FF Global Shortest Router Trips");
1219 1220 1221
               }
               else {
                   Log->Write("\nWARNING: \tExit Strategy Number is not 8 or 9!!!");
1222
                   // config object holds default values, so we omit any set operations
1223 1224
               }

1225
               ///Parsing additional options
f.mack's avatar
f.mack committed
1226
               if (!ParseFfRouterOps(e, ROUTING_FF_GLOBAL_SHORTEST)) {
1227 1228 1229
                    return false;
               }
          }
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249
          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, _config);
               _config->GetRoutingEngine()->AddRouter(r);

               if ((_exit_strat_number == 8) || (_exit_strat_number == 9)){
                    Log->Write("\nINFO: \tUsing FF Global Shortest Router");
               }
               else {
                    Log->Write("\nWARNING: \tExit Strategy Number is not 8 or 9!!!");
                    // config object holds default values, so we omit any set operations
               }

               ///Parsing additional options
               if (!ParseFfRouterOps(e, ROUTING_FF_GLOBAL_SHORTEST)) {
                    return false;
               }
          }

1250 1251 1252
          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));
f.mack's avatar
f.mack committed
1253
               Router *r = new FFRouter(id, ROUTING_FF_LOCAL_SHORTEST, hasSpecificGoals, _config);
1254 1255
               _config->GetRoutingEngine()->AddRouter(r);
               Log->Write("\nINFO: \tUsing FF Local Shortest Router");
f.mack's avatar
f.mack committed
1256
               Log->Write("\nWARNING: \tFF Local Shortest is bugged!!!!");
1257

Arne Graf's avatar
Arne Graf committed
1258
               if ((_exit_strat_number == 8) || (_exit_strat_number == 9)){
1259 1260 1261 1262
                   Log->Write("\nINFO: \tUsing FF Global Shortest Router");
               }
               else {
                   Log->Write("\nWARNING: \tExit Strategy Number is not 8 or 9!!!");
1263
                   // config object holds default values, so we omit any set operations
1264 1265
               }

f.mack's avatar
f.mack committed
1266
               //check if the exit strat is [8 | 9]
1267 1268 1269 1270 1271 1272 1273 1274

               ///Parsing additional options
//               if (!ParseFfRouterOps(e)) {
//                    return false;
//               }
          }
          else if ((strategy == "ff_quickest") &&
                   (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
f.mack's avatar
f.mack committed
1275
               Router *r = new FFRouter(id, ROUTING_FF_QUICKEST, hasSpecificGoals, _config);
1276 1277 1278
               _config->GetRoutingEngine()->AddRouter(r);
               Log->Write("\nINFO: \tUsing FF Quickest Router");

f.mack's avatar
f.mack committed
1279 1280 1281
               if (!ParseFfRouterOps(e, ROUTING_FF_QUICKEST)) {
                    return false;
               }
1282
          }
1283 1284 1285 1286 1287 1288
          else if ((strategy == "trips")  &&
                    (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) ) {
               Router *r = new TripsRouter(id, ROUTING_TRIPS, _config);
               _config->GetRoutingEngine()->AddRouter(r);
          }

1289
          else if (std::find(usedRouter.begin(), usedRouter.end(), id) != usedRouter.end()) {
GrgrLmml's avatar
GrgrLmml committed
1290 1291 1292 1293 1294 1295 1296 1297
               Log->Write("ERROR: \twrong value for routing strategy [%s]!!!\n",
                         strategy.c_str());
               return false;
          }
     }
     return true;
}

f.mack's avatar
f.mack committed
1298
bool IniFileParser::ParseFfRouterOps(TiXmlNode* routingNode, RoutingStrategy s) {
1299
     //set defaults
f.mack's avatar
f.mack committed
1300 1301 1302 1303 1304 1305 1306 1307 1308
     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");
Arne Graf's avatar
Arne Graf committed
1309 1310
               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()));
f.mack's avatar
f.mack committed
1311
               }
1312 1313
          }
     }
1314 1315 1316 1317 1318 1319 1320 1321 1322
     _config->set_write_VTK_files(false);
     if (routingNode->FirstChild("parameters")) {
          TiXmlNode* pParametersForAllFF = routingNode->FirstChild("parameters");
          if (pParametersForAllFF->FirstChild("write_VTK_files"))  {
               //remark: std::strcmp returns 0 if the strings are equal
               bool tmp_write_VTK = !std::strcmp(pParametersForAllFF->FirstChild("write_VTK_files")->FirstChild()->Value(), "true");
               _config->set_write_VTK_files(tmp_write_VTK);
          }
     }
f.mack's avatar
f.mack committed
1323 1324 1325
     FFRouter* r = static_cast<FFRouter*>(_config->GetRoutingEngine()->GetAvailableRouters().back());


1326 1327 1328 1329
     r->SetMode(mode);
     return true;
}

GrgrLmml's avatar
GrgrLmml committed
1330 1331 1332
bool IniFileParser::ParseCogMapOpts(TiXmlNode* routingNode)
{

f.mack's avatar
f.mack committed
1333
     TiXmlNode* sensorNode = routingNode->FirstChild();
GrgrLmml's avatar
GrgrLmml committed
1334 1335 1336 1337 1338
     if (!sensorNode) {
          Log->Write("ERROR:\tNo sensors found.\n");
          return false;
     }

1339 1340
     /// static_cast to get access to the method 'addOption' of the SmokeRouter
     SmokeRouter* r = static_cast<SmokeRouter*>(_config->GetRoutingEngine()->GetAvailableRouters().back());
GrgrLmml's avatar
GrgrLmml committed
1341 1342 1343 1344 1345

     std::vector<std::string> sensorVec;
     for (TiXmlElement* e = sensorNode->FirstChildElement("sensor"); e;
          e = e->NextSiblingElement("sensor")) {
          string sensor = e->Attribute("description");
1346
          //adding Smoke Sensor specific parameters is executed in the class FDSFIreMeshStorage
GrgrLmml's avatar
GrgrLmml committed
1347 1348
          sensorVec.push_back(sensor);

Mohcine Chraibi's avatar
Mohcine Chraibi committed
1349
          Log->Write("INFO: \tSensor <%s> added.", sensor.c_str());
GrgrLmml's avatar
GrgrLmml committed
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362
     }

     r->addOption("Sensors", sensorVec);

     TiXmlElement* cogMap = routingNode->FirstChildElement("cognitive_map");

     if (!cogMap) {
          Log->Write("ERROR:\tCognitive Map not specified.\n");
          return false;
     }

     std::vector<std::string> cogMapStatus;
     cogMapStatus.push_back(cogMap->Attribute("status"));
Mohcine Chraibi's avatar
Mohcine Chraibi committed
1363
     Log->Write("INFO: \tAll pedestrian starting with a(n) %s cognitive maps", cogMapStatus[0].c_str());
GrgrLmml's avatar
GrgrLmml committed
1364 1365
     r->addOption("CognitiveMap", cogMapStatus);

1366 1367 1368 1369 1370 1371 1372 1373 1374
     std::vector<std::string> cogMapFiles;
     if (!cogMap->Attribute("files"))
     {
        Log->Write("WARNING:\tNo input files for the cognitive map specified!");
        return true;
     }
     cogMapFiles.push_back(cogMap->Attribute("files"));
     r->addOption("CognitiveMapFiles",cogMapFiles);

GrgrLmml's avatar
GrgrLmml committed
1375 1376
     return true;
}
1377
#ifdef AIROUTER
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419
bool IniFileParser::ParseAIOpts(TiXmlNode* routingNode) {
     TiXmlNode *sensorNode = routingNode->FirstChild();

     if (!sensorNode) {
          Log->Write("ERROR:\tNo sensors found.\n");
          return false;
     }

     /// static_cast to get access to the method 'addOption' of the AIRouter
     AIRouter *r = static_cast<AIRouter *>(_config->GetRoutingEngine()->GetAvailableRouters().back());

     std::vector<std::string> sensorVec;
     for (TiXmlElement *e = sensorNode->FirstChildElement("sensor"); e;
          e = e->NextSiblingElement("sensor")) {
          string sensor = e->Attribute("description");
          sensorVec.push_back(sensor);

          Log->Write("INFO: \tSensor <%s> added.", sensor.c_str());
     }

     r->addOption("Sensors", sensorVec);

     TiXmlElement *cogMap = routingNode->FirstChildElement("cognitive_map");

     if (!cogMap) {
          Log->Write("ERROR:\tCognitive Map not specified.\n");
          return false;
     }

     //std::vector<std::string> cogMapStatus;
     //cogMapStatus.push_back(cogMap->Attribute("status"));
     //Log->Write("INFO: \tAll pedestrian starting with a(n) %s cognitive maps", cogMapStatus[0].c_str());
     //r->addOption("CognitiveMap", cogMapStatus);

     std::vector<std::string> cogMapFiles;
     if (!cogMap->Attribute("files")) {
          Log->Write("WARNING:\tNo input files for the cognitive map specified!");
     }
     else
     {
          cogMapFiles.push_back(cogMap->Attribute("files"));
          r->addOption("CognitiveMapFiles", cogMapFiles);
Mohcine Chraibi's avatar
Mohcine Chraibi committed
1420
          Log->Write("INFO:\tinput files for the cognitive map specified!");
1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436
     }

     //Signs
     TiXmlElement *signs = routingNode->FirstChildElement("signage");

     if (!signs)
     {
          Log->Write("INFO: \tNo signage specified");
     }
     else
     {
          r->addOption("SignFiles",std::vector<std::string>{signs->Attribute("file")});
     }

     return true;
}
1437
#endif
1438 1439


GrgrLmml's avatar
GrgrLmml committed
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450
bool IniFileParser::ParseLinkedCells(const TiXmlNode& linkedCellNode)
{
     if (linkedCellNode.FirstChild("linkedcells")) {
          string linkedcells = linkedCellNode.FirstChildElement("linkedcells")->Attribute(
                    "enabled");
          string cell_size = linkedCellNode.FirstChildElement("linkedcells")->Attribute(
                    "cell_size");

          if (linkedcells=="true") {
               _config->SetLinkedCellSize(atof(cell_size.c_str()));
               Log->Write(
Mohcine Chraibi's avatar
Mohcine Chraibi committed
1451
                         "INFO: \tlinked cells enabled with size  <%.2f>", _config->GetLinkedCellSize());
GrgrLmml's avatar
GrgrLmml committed
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466
               return true;
          }
          else {
               _config->SetLinkedCellSize(-1.0);
               Log->Write("WARNING: \tinvalid parameters for linkedcells");
               return false;
          }
     }
     return false;
}

bool IniFileParser::ParseStepSize(TiXmlNode& stepNode)
{
     if (stepNode.FirstChild("stepsize")) {
          const char* stepsize = stepNode.FirstChild("stepsize")->FirstChild()->Value();
Arne Graf's avatar
Arne Graf committed
1467 1468 1469
          if (stepsize) {
               double tmp = 1. / _config->GetFps();
               double stepsizeDBL = atof(stepsize);
1470 1471
               if ( (stepNode.FirstChildElement("stepsize")->Attribute("fix")) &&
                         (std::string(stepNode.FirstChildElement("stepsize")->Attribute("fix")) == "yes") ) {
1472 1473
                    _config->Setdt(atof(stepsize));
                    Log->Write("INFO: \tstepsize <%f>", _config->Getdt());
f.mack's avatar
f.mack committed
1474 1475 1476
                    if (tmp < _config->Getdt()) {
                         Log->Write("WARNING: \tStepsize dt = %f > %f = frameinterval.\nWARNING: \tYou should decrease stepsize or fps!", _config->Getdt(), tmp);
                    }
1477 1478
                    return true;
               }
Arne Graf's avatar
Arne Graf committed
1479 1480
               //find a stepsize, that can be multiplied by (int) to get framerate
               for (int i = 1; i < 2000; ++i) {
1481
                    if ((tmp / i) <= stepsizeDBL) {