Unverified Commit ea1fbaf7 authored by Mohcine Chraibi's avatar Mohcine Chraibi Committed by GitHub

train interface (#409)

* Add files via upload

* Add files via upload

* WIP: Interface of trains

* Parsing train tables and types

- Parsing these information in two separate files
- Format in #300

* Adding train information to building

* Fix bug in parsing train doors

* New direction strategy 12 trains

* new train direction strategy

* open/close doors according to train time table

* correct distance calculation for train doors

* adapt xml format of train_types

* Change structure of Train_Type with length

* Add platform data structure

- timetable has platform_id

* bug in parsing wall's type

* Flag existance of train constraints

* Data structure ready for train arrivals

* Hack to keep agents without goal in the simu

* Avoid SegFault in Router

* platforms have pointer to subroom (not id)

* Reset changes to geometry

* Debugging: SegFault after adding Trans

* Refactoring simulation and init router

still does not work!!

* First Working train schedule

- Works only for model=3 + ff_quickest + strategy 8
- Later will be extended to other models

* write train files in trajectory txt

* set type of newy added trans (track)

* Remove trans also from Building

* Regulate flow through trains

* Implement second case to handle curved geometries

* Fix bug while erasing from vectors

* timestamp vtk-files

* Last part of correct train geometry

* Silence some warnings from router

* Transform coordinates of doors relatively to track

* disable some warnings

* bug in train doors (wrong id incrementation)

* Changed to ReInit router

geometries may change during simulation

* Fix problem of intersection of doors

Sometimes train's doors are exactly on the edges of walls.
This commit fixes this problem.

* path issues with trajectories

this commit solves issues addressed in:

- #324
- #326

* flow name for case rate

* adapt test to new flow file

* write out all files with abs path

- Changes to  ProjectRootDir: probable side effects.
--> needs testing

* Fix a compile problem

* inifile can be original structure now

* np.linspace is used in master_ini file

* refactoring parse header and fixing CI

* remove unnecessary files
parent 80851780
...@@ -60,7 +60,9 @@ void GeoFileParser::LoadBuilding(Building* building) ...@@ -60,7 +60,9 @@ void GeoFileParser::LoadBuilding(Building* building)
bool GeoFileParser::LoadGeometry(Building* building) bool GeoFileParser::LoadGeometry(Building* building)
{ {
std::string geoFilenameWithPath = _configuration->GetProjectRootDir()+_configuration->GetGeometryFile(); fs::path rootDir(_configuration->GetProjectRootDir());
std::string geoFilenameWithPath = (rootDir/fs::path(_configuration->GetGeometryFile())).string();
std::cout << "\nLoadGeometry: file: " << geoFilenameWithPath << "\n"; std::cout << "\nLoadGeometry: file: " << geoFilenameWithPath << "\n";
TiXmlDocument docGeo(geoFilenameWithPath); TiXmlDocument docGeo(geoFilenameWithPath);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
using namespace std; using namespace std;
namespace fs = std::filesystem;
IODispatcher::IODispatcher() IODispatcher::IODispatcher()
...@@ -466,6 +467,8 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i ...@@ -466,6 +467,8 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
std::string eventFileName = getEventFileName(building->GetProjectFilename()); std::string eventFileName = getEventFileName(building->GetProjectFilename());
std::string trainTimeTableFileName = getTrainTimeTableFileName(building->GetProjectFilename()); std::string trainTimeTableFileName = getTrainTimeTableFileName(building->GetProjectFilename());
std::string trainTypeFileName = getTrainTypeFileName(building->GetProjectFilename()); std::string trainTypeFileName = getTrainTypeFileName(building->GetProjectFilename());
fs::path projRoot(building->GetProjectRootDir());
(void) seed; (void) nPeds; (void) seed; (void) nPeds;
char tmp[100] = ""; char tmp[100] = "";
sprintf(tmp, "#description: jpscore (%s)", JPSCORE_VERSION); sprintf(tmp, "#description: jpscore (%s)", JPSCORE_VERSION);
...@@ -474,31 +477,37 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i ...@@ -474,31 +477,37 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
Write(tmp); Write(tmp);
sprintf(tmp, "#framerate: %0.2f",fps); sprintf(tmp, "#framerate: %0.2f",fps);
Write(tmp); Write(tmp);
sprintf(tmp,"#geometry: %s",building->GetGeometryFilename().c_str()); std::string tmpGeo= (projRoot/fs::path(building->GetGeometryFilename())).string();
sprintf(tmp,"#geometry: %s", tmpGeo.c_str());
Write(tmp); Write(tmp);
if(sourceFileName != "") if(sourceFileName != "")
{ {
sprintf(tmp,"#sources: %s", sourceFileName.c_str()); std::string tmpSource= (projRoot/fs::path(sourceFileName)).string();
sprintf(tmp,"#sources: %s", tmpSource.c_str());
Write(tmp); Write(tmp);
} }
if(goalFileName != "") if(goalFileName != "")
{ {
sprintf(tmp,"#goals: %s", goalFileName.c_str()); std::string tmpGoal= (projRoot/fs::path(goalFileName)).string();
sprintf(tmp,"#goals: %s", tmpGoal.c_str());
Write(tmp); Write(tmp);
} }
if( eventFileName != "") if( eventFileName != "")
{ {
sprintf(tmp,"#events: %s", eventFileName.c_str()); std::string tmpEvent= (projRoot/fs::path(eventFileName)).string();
sprintf(tmp,"#events: %s", tmpEvent.c_str());
Write(tmp); Write(tmp);
} }
if( trainTimeTableFileName != "") if( trainTimeTableFileName != "")
{ {
sprintf(tmp,"#trainTimeTable: %s", trainTimeTableFileName.c_str()); std::string tmpTTT= (projRoot/fs::path(trainTimeTableFileName)).string();
sprintf(tmp,"#trainTimeTable: %s", tmpTTT.c_str());
Write(tmp); Write(tmp);
} }
if( trainTypeFileName != "") if( trainTypeFileName != "")
{ {
sprintf(tmp,"#trainType: %s", trainTypeFileName.c_str()); std::string tmpTT= (projRoot/fs::path(trainTypeFileName)).string();
sprintf(tmp,"#trainType: %s", tmpTT.c_str());
Write(tmp); Write(tmp);
} }
Write("#ID: the agent ID"); Write("#ID: the agent ID");
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <cstring> #include <cstring>
#include <vector> #include <vector>
#include <filesystem>
extern OutputHandler* Log; extern OutputHandler* Log;
class Trajectories; class Trajectories;
......
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
#include "../routing/ff_router_trips/ffRouterTrips.h" #include "../routing/ff_router_trips/ffRouterTrips.h"
#include "../routing/trips_router/TripsRouter.h" #include "../routing/trips_router/TripsRouter.h"
namespace fs = std::filesystem;
/* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */ /* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */
std::string ver_string(int a, int b, int c) { std::string ver_string(int a, int b, int c) {
std::ostringstream ss; std::ostringstream ss;
...@@ -95,15 +98,9 @@ bool IniFileParser::Parse(std::string iniFile) ...@@ -95,15 +98,9 @@ bool IniFileParser::Parse(std::string iniFile)
// and as I just realized, I called it configuration. We should be consistent here anything else // and as I just realized, I called it configuration. We should be consistent here anything else
// is confusing [gl march '16] // is confusing [gl march '16]
fs::path root(iniFile);
fs::path q(iniFile);
//extract and set the project root dir _config->SetProjectRootDir(fs::absolute(q.parent_path()).string());
size_t found = iniFile.find_last_of("/\\");
if (found!=std::string::npos) {
_config->SetProjectRootDir(iniFile.substr(0, found)+"/");
} else {
_config->SetProjectRootDir("./");
}
TiXmlDocument doc(iniFile); TiXmlDocument doc(iniFile);
if (!doc.LoadFile()) { if (!doc.LoadFile()) {
...@@ -135,157 +132,17 @@ bool IniFileParser::Parse(std::string iniFile) ...@@ -135,157 +132,17 @@ bool IniFileParser::Parse(std::string iniFile)
return false; return false;
} }
//logfile //check the structure of inifile
if (xMainNode->FirstChild("logfile")) { if (xMainNode->FirstChild("header")) {
_config->SetErrorLogFile( TiXmlNode* xHeader = xMainNode->FirstChild("header");
_config->GetProjectRootDir()+xMainNode->FirstChild("logfile")->FirstChild()->Value()); ParseHeader(xHeader);
_config->SetLog(2); }//if header
Log->Write("INFO:\tlogfile <%s>", _config->GetErrorLogFile().c_str()); else {
} ParseHeader(xMainNode);
}//else header
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 (xMainNode->FirstChild("seed")) {
TiXmlNode* seedNode = xMainNode->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 (xMainNode->FirstChild("max_sim_time")) {
const char* tmax =
xMainNode->FirstChildElement("max_sim_time")->FirstChild()->Value();
_config->SetTmax(atof(tmax));
Log->Write("INFO: \tMaximal simulation time <%.2f> seconds", _config->GetTmax());
}
// Progressbar
if (xMainNode->FirstChild("progressbar")) {
_config->SetPRB(true);
Log->Write("INFO: \tUse Progressbar");
}
// geometry file name
if (xMainNode->FirstChild("geometry")) {
std::string filename = xMainNode->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 (xMainNode->FirstChild("num_threads")) {
TiXmlNode* numthreads = xMainNode->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 (xMainNode->FirstChild("show_statistics")) {
std::string value = xMainNode->FirstChild("show_statistics")->FirstChild()->Value();
_config->SetShowStatistics(value=="true");
Log->Write("INFO: \tShow statistics: %s", value.c_str());
}
//trajectories
TiXmlNode* xTrajectories = xMainNode->FirstChild("trajectories");
if (xTrajectories) {
double fps;
xMainNode->FirstChildElement("trajectories")->Attribute("fps", &fps);
_config->SetFps(fps);
string format =
xMainNode->FirstChildElement("trajectories")->Attribute(
"format") ?
xMainNode->FirstChildElement("trajectories")->Attribute(
"format") :
"xml-plain";
int embedMesh = 0;
if (xMainNode->FirstChildElement("trajectories")->Attribute(
"embed_mesh")) {
embedMesh =
string(xMainNode->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 =
xMainNode->FirstChildElement("trajectories")->Attribute(
"color_mode") ?
xMainNode->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");
if (tmp.c_str())
_config->SetTrajectoriesFile(_config->GetProjectRootDir()+tmp);
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());
}
}
// JPSfire // JPSfire
// ------------------------------------- // -------------------------------------
...@@ -393,6 +250,170 @@ bool IniFileParser::Parse(std::string iniFile) ...@@ -393,6 +250,170 @@ bool IniFileParser::Parse(std::string iniFile)
return true; return true;
} }
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());
}
}
}
bool IniFileParser::ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMainNode) bool IniFileParser::ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMainNode)
{ {
Log->Write("\nINFO:\tUsing the GCFM model"); Log->Write("\nINFO:\tUsing the GCFM model");
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define JPSCORE_INIFILEPARSER_H #define JPSCORE_INIFILEPARSER_H
#include <string> #include <string>
#include <filesystem>
#include "../general/Configuration.h" #include "../general/Configuration.h"
#include "../routing/DirectionStrategy.h" #include "../routing/DirectionStrategy.h"
...@@ -44,6 +44,8 @@ public: ...@@ -44,6 +44,8 @@ public:
bool Parse(std::string iniFile); bool Parse(std::string iniFile);
private: private:
bool ParseHeader(TiXmlNode* xHeader);
bool ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMain); bool ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMain);
bool ParseKrauszModel(TiXmlElement* xKrausz, TiXmlElement* xMain); bool ParseKrauszModel(TiXmlElement* xKrausz, TiXmlElement* xMain);
......
...@@ -152,18 +152,31 @@ bool Simulation::InitArgs() ...@@ -152,18 +152,31 @@ bool Simulation::InitArgs()
} }
if (!_config->GetTrajectoriesFile().empty()) { if (!_config->GetTrajectoriesFile().empty()) {
fs::path p(_config->GetTrajectoriesFile());
fs::path curr_abs_path = fs::current_path();
fs::path rel_path = _config->GetTrajectoriesFile();
fs::path combined = (curr_abs_path /= rel_path);
std::string traj = combined.string();
_config->SetTrajectoriesFile(combined);
if(!fs::exists(traj))
fs::create_directories(combined.parent_path());
switch (_config->GetFileFormat()) { switch (_config->GetFileFormat()) {
case FORMAT_XML_PLAIN: { case FORMAT_XML_PLAIN: {
OutputHandler* tofile = new FileHandler( OutputHandler* tofile = new FileHandler(
_config->GetTrajectoriesFile().c_str()); traj.c_str());
Trajectories* output = new TrajectoriesJPSV05(); Trajectories* output = new TrajectoriesJPSV05();
output->SetOutputHandler(tofile); output->SetOutputHandler(tofile);
_iod->AddIO(output); _iod->AddIO(output);
break; break;
} }
case FORMAT_PLAIN: { case FORMAT_PLAIN: {
OutputHandler* file = new FileHandler( OutputHandler* file = new FileHandler(
_config->GetTrajectoriesFile().c_str()); traj.c_str());
outputTXT = new TrajectoriesFLAT(); outputTXT = new TrajectoriesFLAT();
outputTXT->SetOutputHandler(file); outputTXT->SetOutputHandler(file);
_iod->AddIO(outputTXT); _iod->AddIO(outputTXT);
...@@ -172,7 +185,7 @@ bool Simulation::InitArgs() ...@@ -172,7 +185,7 @@ bool Simulation::InitArgs()
case FORMAT_VTK: { case FORMAT_VTK: {
Log->Write("INFO: \tFormat vtk not yet supported\n"); Log->Write("INFO: \tFormat vtk not yet supported\n");
OutputHandler* file = new FileHandler( OutputHandler* file = new FileHandler(
(_config->GetTrajectoriesFile()+".vtk").c_str()); (traj+".vtk").c_str());
Trajectories* output = new TrajectoriesVTK(); Trajectories* output = new TrajectoriesVTK();
output->SetOutputHandler(file); output->SetOutputHandler(file);
_iod->AddIO(output); _iod->AddIO(output);
...@@ -453,12 +466,14 @@ void Simulation::PrintStatistics(double simTime) ...@@ -453,12 +466,14 @@ void Simulation::PrintStatistics(double simTime)
goal->GetID(), goal->GetDoorUsage(), goal->GetID(), goal->GetDoorUsage(),
goal->GetLastPassingTime()); goal->GetLastPassingTime());
string statsfile = "flow_exit_id_"+to_string(goal->GetID())+".txt"; fs::path p(_config->GetOriginalTrajectoriesFile());
string statsfile = "flow_exit_id_"+to_string(goal->GetID())+"_"+p.stem().string()+".txt";
if(goal->GetOutflowRate() < (std::numeric_limits<double>::max)()) if(goal->GetOutflowRate() < (std::numeric_limits<double>::max)())
{ {
char tmp[50]; char tmp[50];
sprintf(tmp, "%.2f", goal->GetOutflowRate()); sprintf(tmp, "%.2f_", goal->GetOutflowRate());
statsfile = "flow_exit_id_"+to_string(goal->GetID())+"_rate_"+tmp+".txt"; statsfile = "flow_exit_id_"+to_string(goal->GetID())+"_rate_"+tmp+p.stem().string()+".txt";
} }
Log->Write("More Information in the file: %s", statsfile.c_str()); Log->Write("More Information in the file: %s", statsfile.c_str());
{ {
...@@ -708,6 +723,7 @@ bool Simulation::WriteTrajectories(std::string trajectoryName) ...@@ -708,6 +723,7 @@ bool Simulation::WriteTrajectories(std::string trajectoryName)
if(_config-> GetFileFormat() == FORMAT_PLAIN) if(_config-> GetFileFormat() == FORMAT_PLAIN)
{ {
fs::path p = _config->GetTrajectoriesFile(); fs::path p = _config->GetTrajectoriesFile();
fs::path parent = p.parent_path();
int sf = fs::file_size(p); int sf = fs::file_size(p);
if(sf>_maxFileSize*1024*1024) if(sf>_maxFileSize*1024*1024)
{