Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
JPScore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
92
Issues
92
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JuPedSim
JPScore
Commits
297365e3
Verified
Commit
297365e3
authored
Jul 01, 2019
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'trajectories' into develop
parents
e8bd8ffe
17630d03
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
32 deletions
+72
-32
IO/GeoFileParser.cpp
IO/GeoFileParser.cpp
+3
-1
IO/IODispatcher.cpp
IO/IODispatcher.cpp
+15
-6
IO/IODispatcher.h
IO/IODispatcher.h
+1
-1
IO/IniFileParser.cpp
IO/IniFileParser.cpp
+19
-11
IO/IniFileParser.h
IO/IniFileParser.h
+1
-1
Simulation.cpp
Simulation.cpp
+24
-9
Utest/develop_tests/doors/runtest_dev_1.py
Utest/develop_tests/doors/runtest_dev_1.py
+2
-2
general/Configuration.h
general/Configuration.h
+7
-1
No files found.
IO/GeoFileParser.cpp
View file @
297365e3
...
...
@@ -60,7 +60,9 @@ void GeoFileParser::LoadBuilding(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
<<
"
\n
LoadGeometry: file: "
<<
geoFilenameWithPath
<<
"
\n
"
;
TiXmlDocument
docGeo
(
geoFilenameWithPath
);
...
...
IO/IODispatcher.cpp
View file @
297365e3
...
...
@@ -35,6 +35,7 @@
#define _USE_MATH_DEFINES
using
namespace
std
;
namespace
fs
=
std
::
filesystem
;
IODispatcher
::
IODispatcher
()
...
...
@@ -466,6 +467,8 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
std
::
string
eventFileName
=
getEventFileName
(
building
->
GetProjectFilename
());
std
::
string
trainTimeTableFileName
=
getTrainTimeTableFileName
(
building
->
GetProjectFilename
());
std
::
string
trainTypeFileName
=
getTrainTypeFileName
(
building
->
GetProjectFilename
());
fs
::
path
projRoot
(
building
->
GetProjectRootDir
());
(
void
)
seed
;
(
void
)
nPeds
;
char
tmp
[
100
]
=
""
;
sprintf
(
tmp
,
"#description: jpscore (%s)"
,
JPSCORE_VERSION
);
...
...
@@ -474,31 +477,37 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
Write
(
tmp
);
sprintf
(
tmp
,
"#framerate: %0.2f"
,
fps
);
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
);
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
);
}
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
);
}
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
);
}
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
);
}
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
(
"#ID: the agent ID"
);
...
...
IO/IODispatcher.h
View file @
297365e3
...
...
@@ -33,7 +33,7 @@
#include <cstring>
#include <vector>
#include <filesystem>
extern
OutputHandler
*
Log
;
class
Trajectories
;
...
...
IO/IniFileParser.cpp
View file @
297365e3
...
...
@@ -47,6 +47,9 @@
#include "../routing/ff_router_trips/ffRouterTrips.h"
#include "../routing/trips_router/TripsRouter.h"
namespace
fs
=
std
::
filesystem
;
/* 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
;
...
...
@@ -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
// is confusing [gl march '16]
//extract and set the project root dir
size_t
found
=
iniFile
.
find_last_of
(
"/
\\
"
);
if
(
found
!=
std
::
string
::
npos
)
{
_config
->
SetProjectRootDir
(
iniFile
.
substr
(
0
,
found
)
+
"/"
);
}
else
{
_config
->
SetProjectRootDir
(
"./"
);
}
fs
::
path
root
(
iniFile
);
fs
::
path
q
(
iniFile
);
_config
->
SetProjectRootDir
(
fs
::
absolute
(
q
.
parent_path
()).
string
());
TiXmlDocument
doc
(
iniFile
);
if
(
!
doc
.
LoadFile
())
{
...
...
@@ -268,8 +265,19 @@ bool IniFileParser::Parse(std::string iniFile)
std
::
string
tmp
;
tmp
=
xTrajectories
->
FirstChildElement
(
"file"
)
->
Attribute
(
"location"
);
if
(
tmp
.
c_str
())
_config
->
SetTrajectoriesFile
(
_config
->
GetProjectRootDir
()
+
tmp
);
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:
\t
output file <%s>"
,
_config
->
GetTrajectoriesFile
().
c_str
());
Log
->
Write
(
"INFO:
\t
in format <%s> at <%.0f> frames per seconds"
,
format
.
c_str
(),
_config
->
GetFps
());
}
...
...
IO/IniFileParser.h
View file @
297365e3
...
...
@@ -23,7 +23,7 @@
#define JPSCORE_INIFILEPARSER_H
#include <string>
#include <filesystem>
#include "../general/Configuration.h"
#include "../routing/DirectionStrategy.h"
...
...
Simulation.cpp
View file @
297365e3
...
...
@@ -152,18 +152,31 @@ bool Simulation::InitArgs()
}
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
())
{
case
FORMAT_XML_PLAIN
:
{
OutputHandler
*
tofile
=
new
FileHandler
(
_config
->
GetTrajectoriesFile
()
.
c_str
());
traj
.
c_str
());
Trajectories
*
output
=
new
TrajectoriesJPSV05
();
output
->
SetOutputHandler
(
tofile
);
_iod
->
AddIO
(
output
);
break
;
}
case
FORMAT_PLAIN
:
{
OutputHandler
*
file
=
new
FileHandler
(
_config
->
GetTrajectoriesFile
()
.
c_str
());
traj
.
c_str
());
outputTXT
=
new
TrajectoriesFLAT
();
outputTXT
->
SetOutputHandler
(
file
);
_iod
->
AddIO
(
outputTXT
);
...
...
@@ -172,7 +185,7 @@ bool Simulation::InitArgs()
case
FORMAT_VTK
:
{
Log
->
Write
(
"INFO:
\t
Format vtk not yet supported
\n
"
);
OutputHandler
*
file
=
new
FileHandler
(
(
_config
->
GetTrajectoriesFile
()
+
".vtk"
).
c_str
());
(
traj
+
".vtk"
).
c_str
());
Trajectories
*
output
=
new
TrajectoriesVTK
();
output
->
SetOutputHandler
(
file
);
_iod
->
AddIO
(
output
);
...
...
@@ -453,12 +466,14 @@ void Simulation::PrintStatistics(double simTime)
goal
->
GetID
(),
goal
->
GetDoorUsage
(),
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
)())
{
char
tmp
[
50
];
sprintf
(
tmp
,
"%.2f"
,
goal
->
GetOutflowRate
());
statsfile
=
"flow_exit_id_"
+
to_string
(
goal
->
GetID
())
+
"_rate_"
+
tmp
+
".txt"
;
sprintf
(
tmp
,
"%.2f
_
"
,
goal
->
GetOutflowRate
());
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
());
{
...
...
@@ -708,6 +723,7 @@ bool Simulation::WriteTrajectories(std::string trajectoryName)
if
(
_config
->
GetFileFormat
()
==
FORMAT_PLAIN
)
{
fs
::
path
p
=
_config
->
GetTrajectoriesFile
();
fs
::
path
parent
=
p
.
parent_path
();
int
sf
=
fs
::
file_size
(
p
);
if
(
sf
>
_maxFileSize
*
1024
*
1024
)
{
...
...
@@ -715,7 +731,8 @@ bool Simulation::WriteTrajectories(std::string trajectoryName)
this
->
incrementCountTraj
();
char
tmp_traj_name
[
100
];
sprintf
(
tmp_traj_name
,
"%s_%.4d_%s"
,
trajectoryName
.
c_str
(),
_countTraj
,
extention
.
c_str
());
_config
->
SetTrajectoriesFile
(
tmp_traj_name
);
fs
::
path
abs_traj_name
=
parent
/
fs
::
path
(
tmp_traj_name
);
_config
->
SetTrajectoriesFile
(
abs_traj_name
.
string
());
Log
->
Write
(
"INFO:
\t
New trajectory file <%s>"
,
tmp_traj_name
);
OutputHandler
*
file
=
new
FileHandler
(
_config
->
GetTrajectoriesFile
().
c_str
());
outputTXT
->
SetOutputHandler
(
file
);
...
...
@@ -770,7 +787,6 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::shared
std
::
cout
<<
KBLU
<<
"Enter correctGeometry: Building Has "
<<
building
->
GetAllTransitions
().
size
()
<<
" Transitions
\n
"
<<
RESET
;
std
::
cout
<<
"room: "
<<
room_id
<<
" subroom_id "
<<
subroom_id
<<
"
\n
"
;
if
(
mytrack
.
empty
()
||
subroom
==
nullptr
)
return
false
;
...
...
@@ -985,7 +1001,6 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::shared
}
_routingEngine
->
setNeedUpdate
(
true
);
return
true
;
}
void
Simulation
::
RunFooter
()
{
...
...
Utest/develop_tests/doors/runtest_dev_1.py
View file @
297365e3
...
...
@@ -15,7 +15,7 @@ def runtest(inifile, trajfile):
failure
=
0
ids
,
outflow
=
get_outflow
(
inifile
)
for
(
i
,
o
)
in
zip
(
ids
,
outflow
):
filename
=
"flow_exit_id_%d_rate_%.2f
.txt"
%
(
i
,
o
)
filename
=
"flow_exit_id_%d_rate_%.2f
_%s.txt"
%
(
i
,
o
,
os
.
path
.
basename
(
trajfile
).
split
(
"."
)[
0
]
)
if
not
os
.
path
.
exists
(
filename
):
logging
.
info
(
"ERROR: can not find statistics file %s"
%
filename
)
exit
(
FAILURE
)
...
...
@@ -31,7 +31,7 @@ def runtest(inifile, trajfile):
if
abs
(
J
-
o
)
>
tolerance
:
failure
=
1
logging
.
info
(
"Plot to flow.png"
)
plt
.
savefig
(
"flow.png"
)
if
failure
:
logging
.
info
(
"flow from statistics files does not much expected flow from inifile"
)
...
...
general/Configuration.h
View file @
297365e3
...
...
@@ -99,6 +99,7 @@ public:
_hostname
=
"localhost"
;
_trajectoriesFile
=
"trajectories.xml"
;
_originalTrajectoriesFile
=
"trajectories.xml"
;
_errorLogFile
=
"log.txt"
;
_projectFile
=
""
;
_geometryFile
=
""
;
...
...
@@ -125,7 +126,7 @@ public:
// _dirSubLocal = nullptr;
// _dirLocal = nullptr;
_dirStrategy
=
nullptr
;
//for random numbers
//for random numbers
_rdGenerator
=
RandomNumberGenerator
();
...
...
@@ -315,6 +316,10 @@ public:
void
SetTrajectoriesFile
(
std
::
string
trajectoriesFile
)
{
_trajectoriesFile
=
trajectoriesFile
;
};
const
std
::
string
&
GetOriginalTrajectoriesFile
()
const
{
return
_originalTrajectoriesFile
;
};
void
SetOriginalTrajectoriesFile
(
std
::
string
trajectoriesFile
)
{
_originalTrajectoriesFile
=
trajectoriesFile
;
};
const
std
::
string
&
GetErrorLogFile
()
const
{
return
_errorLogFile
;
};
void
SetErrorLogFile
(
std
::
string
errorLogFile
)
{
_errorLogFile
=
errorLogFile
;
};
...
...
@@ -431,6 +436,7 @@ private:
std
::
string
_hostname
;
std
::
string
_trajectoriesFile
;
std
::
string
_originalTrajectoriesFile
;
std
::
string
_errorLogFile
;
std
::
string
_projectFile
;
std
::
string
_geometryFile
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment