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
50537e39
Commit
50537e39
authored
Nov 10, 2014
by
Ulrich Kemloh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing functions signature from void to bool.
Geometry functions now return false on failure.
parent
a5161e99
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
460 additions
and
401 deletions
+460
-401
IO/IODispatcher.cpp
IO/IODispatcher.cpp
+71
-67
Simulation.cpp
Simulation.cpp
+171
-141
Simulation.h
Simulation.h
+1
-1
events/EventManager.cpp
events/EventManager.cpp
+16
-13
general/Macros.h
general/Macros.h
+3
-0
geometry/Building.cpp
geometry/Building.cpp
+37
-25
geometry/Building.h
geometry/Building.h
+5
-5
geometry/Goal.cpp
geometry/Goal.cpp
+3
-4
geometry/Goal.h
geometry/Goal.h
+1
-1
geometry/Obstacle.cpp
geometry/Obstacle.cpp
+7
-5
geometry/Obstacle.h
geometry/Obstacle.h
+1
-1
geometry/SubRoom.cpp
geometry/SubRoom.cpp
+10
-8
geometry/SubRoom.h
geometry/SubRoom.h
+4
-4
main.cpp
main.cpp
+28
-26
math/GCFMModel.cpp
math/GCFMModel.cpp
+3
-13
math/GCFMModel.h
math/GCFMModel.h
+8
-11
math/GompertzModel.cpp
math/GompertzModel.cpp
+5
-7
math/GompertzModel.h
math/GompertzModel.h
+5
-9
math/OperationalModel.h
math/OperationalModel.h
+2
-1
pedestrian/Pedestrian.cpp
pedestrian/Pedestrian.cpp
+1
-1
routing/CognitiveMapRouter.cpp
routing/CognitiveMapRouter.cpp
+2
-1
routing/CognitiveMapRouter.h
routing/CognitiveMapRouter.h
+1
-1
routing/DirectionStrategy.cpp
routing/DirectionStrategy.cpp
+34
-30
routing/DummyRouter.cpp
routing/DummyRouter.cpp
+2
-1
routing/DummyRouter.h
routing/DummyRouter.h
+1
-1
routing/GlobalRouter.cpp
routing/GlobalRouter.cpp
+3
-1
routing/GlobalRouter.h
routing/GlobalRouter.h
+2
-2
routing/GraphRouter.cpp
routing/GraphRouter.cpp
+4
-2
routing/GraphRouter.h
routing/GraphRouter.h
+1
-1
routing/MeshRouter.cpp
routing/MeshRouter.cpp
+2
-1
routing/MeshRouter.h
routing/MeshRouter.h
+1
-1
routing/QuickestPathRouter.cpp
routing/QuickestPathRouter.cpp
+4
-2
routing/QuickestPathRouter.h
routing/QuickestPathRouter.h
+1
-1
routing/Router.h
routing/Router.h
+1
-1
routing/RoutingEngine.cpp
routing/RoutingEngine.cpp
+5
-2
routing/RoutingEngine.h
routing/RoutingEngine.h
+2
-1
routing/SafestPathRouter.cpp
routing/SafestPathRouter.cpp
+7
-3
routing/SafestPathRouter.h
routing/SafestPathRouter.h
+1
-2
routing/graph/RoutingGraph.cpp
routing/graph/RoutingGraph.cpp
+4
-4
No files found.
IO/IODispatcher.cpp
View file @
50537e39
...
...
@@ -315,9 +315,9 @@ void TrajectoriesJPSV04::WriteFrame(int frameNr, Building* building)
string
caption
=
r
->
GetCaption
();
if
((
rooms_to_plot
.
empty
()
==
false
)
&&
(
IsElementInVector
(
rooms_to_plot
,
caption
)
==
false
))
{
continue
;
}
&&
(
IsElementInVector
(
rooms_to_plot
,
caption
)
==
false
))
{
continue
;
}
data
.
append
(
WritePed
(
ped
));
}
...
...
@@ -341,6 +341,7 @@ TrajectoriesFLAT::TrajectoriesFLAT() : Trajectories()
void
TrajectoriesFLAT
::
WriteHeader
(
int
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
{
(
void
)
seed
;
(
void
)
nPeds
;
char
tmp
[
CLENGTH
]
=
""
;
Write
(
"#description: my super simulation"
);
sprintf
(
tmp
,
"#framerate: %0.2f"
,
fps
);
...
...
@@ -356,7 +357,7 @@ void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, in
void
TrajectoriesFLAT
::
WriteGeometry
(
Building
*
building
)
{
(
void
)
building
;
}
void
TrajectoriesFLAT
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
...
...
@@ -392,6 +393,8 @@ TrajectoriesVTK::TrajectoriesVTK()
void
TrajectoriesVTK
::
WriteHeader
(
int
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
{
//suppress unused warnings
(
void
)
nPeds
;
(
void
)
fps
;
(
void
)
seed
;
Write
(
"# vtk DataFile Version 4.0"
);
Write
(
building
->
GetCaption
());
Write
(
"ASCII"
);
...
...
@@ -447,6 +450,7 @@ void TrajectoriesVTK::WriteGeometry(Building* building)
void
TrajectoriesVTK
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
{
(
void
)
frameNr
;
(
void
)
building
;
}
void
TrajectoriesVTK
::
WriteFooter
()
...
...
@@ -481,24 +485,24 @@ void TrajectoriesJPSV06::WriteHeader(int nPeds, double fps, Building* building,
void
TrajectoriesJPSV06
::
WriteGeometry
(
Building
*
building
)
{
// just put a link to the geometry file
// string embed_geometry;
// embed_geometry.append("\t<geometry>\n");
// char file_location[CLENGTH] = "";
// sprintf(file_location, "\t<file location= \"%s\"/>\n", building->GetGeometryFilename().c_str());
// embed_geometry.append(file_location);
// //embed_geometry.append("\t</geometry>\n");
//
// const map<int, Hline*>& hlines=building->GetAllHlines();
// if(hlines.size()>0){
// //embed_geometry.append("\t<geometry>\n");
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// {
// embed_geometry.append(it->second->WriteElement());
// }
// //embed_geometry.append("\t</geometry>\n");
// }
// embed_geometry.append("\t</geometry>\n");
// Write(embed_geometry);
// string embed_geometry;
// embed_geometry.append("\t<geometry>\n");
// char file_location[CLENGTH] = "";
// sprintf(file_location, "\t<file location= \"%s\"/>\n", building->GetGeometryFilename().c_str());
// embed_geometry.append(file_location);
// //embed_geometry.append("\t</geometry>\n");
//
// const map<int, Hline*>& hlines=building->GetAllHlines();
// if(hlines.size()>0){
// //embed_geometry.append("\t<geometry>\n");
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// {
// embed_geometry.append(it->second->WriteElement());
// }
// //embed_geometry.append("\t</geometry>\n");
// }
// embed_geometry.append("\t</geometry>\n");
// Write(embed_geometry);
//set the content of the file
string
fileName
=
building
->
GetProjectRootDir
()
+
"/"
+
building
->
GetGeometryFilename
().
c_str
();
...
...
@@ -510,51 +514,51 @@ void TrajectoriesJPSV06::WriteGeometry(Building* building)
buffer
<<
t
.
rdbuf
();
embed_geometry
=
buffer
.
str
();
Write
(
embed_geometry
);
//
//
// //collecting the hlines
// std::stringstream hlines_buffer;
// // add the header
// hlines_buffer<<" <routing version=\"0.5\" "
// <<"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
// <<"xsi:noNamespaceSchemaLocation=\"http://134.94.2.137/jps_routing.xsd\" >"<<endl
// <<"<Hlines> "<<endl;
//
// const map<int, Hline*>& hlines=building->GetAllHlines();
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// {
// Hline* hl=it->second;
// hlines_buffer <<"\t<Hline id=\""<< hl->GetID()<<"\" room_id=\""<<hl->GetRoom1()->GetID()
// <<"\" subroom_id=\""<< hl->GetSubRoom1()->GetSubRoomID()<<"\">"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint1()._x<<"\" py=\""<< hl->GetPoint1()._y<<"\" />"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint2()._x<<"\" py=\""<< hl->GetPoint2()._y<<"\" />"<<endl;
// hlines_buffer <<"\t</Hline>"<<endl;
// }
// hlines_buffer<<"</Hlines> "<<endl;
// hlines_buffer<<"</routing> "<<endl;
//
// string hline_string=hlines_buffer.str();
// string to_replace="</geometry>";
// hline_string.append(to_replace);
//
// size_t start_pos = embed_geometry.find(to_replace);
// if(start_pos == std::string::npos)
// {
// Log->Write("WARNING:\t missing %s tag while writing the geometry in the trajectory file.",to_replace.c_str());
// }
//
// embed_geometry.replace(start_pos, to_replace.length(), hline_string);
// Write(embed_geometry);
// Write("\t<AttributeDescription>");
// Write("\t\t<property tag=\"x\" description=\"xPosition\"/>");
// Write("\t\t<property tag=\"y\" description=\"yPosition\"/>");
// Write("\t\t<property tag=\"z\" description=\"zPosition\"/>");
// Write("\t\t<property tag=\"rA\" description=\"radiusA\"/>");
// Write("\t\t<property tag=\"rB\" description=\"radiusB\"/>");
// Write("\t\t<property tag=\"eC\" description=\"ellipseColor\"/>");
// Write("\t\t<property tag=\"eO\" description=\"ellipseOrientation\"/>");
// Write("\t</AttributeDescription>\n");
//
//
// //collecting the hlines
// std::stringstream hlines_buffer;
// // add the header
// hlines_buffer<<" <routing version=\"0.5\" "
// <<"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
// <<"xsi:noNamespaceSchemaLocation=\"http://134.94.2.137/jps_routing.xsd\" >"<<endl
// <<"<Hlines> "<<endl;
//
// const map<int, Hline*>& hlines=building->GetAllHlines();
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// {
// Hline* hl=it->second;
// hlines_buffer <<"\t<Hline id=\""<< hl->GetID()<<"\" room_id=\""<<hl->GetRoom1()->GetID()
// <<"\" subroom_id=\""<< hl->GetSubRoom1()->GetSubRoomID()<<"\">"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint1()._x<<"\" py=\""<< hl->GetPoint1()._y<<"\" />"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint2()._x<<"\" py=\""<< hl->GetPoint2()._y<<"\" />"<<endl;
// hlines_buffer <<"\t</Hline>"<<endl;
// }
// hlines_buffer<<"</Hlines> "<<endl;
// hlines_buffer<<"</routing> "<<endl;
//
// string hline_string=hlines_buffer.str();
// string to_replace="</geometry>";
// hline_string.append(to_replace);
//
// size_t start_pos = embed_geometry.find(to_replace);
// if(start_pos == std::string::npos)
// {
// Log->Write("WARNING:\t missing %s tag while writing the geometry in the trajectory file.",to_replace.c_str());
// }
//
// embed_geometry.replace(start_pos, to_replace.length(), hline_string);
// Write(embed_geometry);
// Write("\t<AttributeDescription>");
// Write("\t\t<property tag=\"x\" description=\"xPosition\"/>");
// Write("\t\t<property tag=\"y\" description=\"yPosition\"/>");
// Write("\t\t<property tag=\"z\" description=\"zPosition\"/>");
// Write("\t\t<property tag=\"rA\" description=\"radiusA\"/>");
// Write("\t\t<property tag=\"rB\" description=\"radiusB\"/>");
// Write("\t\t<property tag=\"eC\" description=\"ellipseColor\"/>");
// Write("\t\t<property tag=\"eO\" description=\"ellipseOrientation\"/>");
// Write("\t</AttributeDescription>\n");
}
void
TrajectoriesJPSV06
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
...
...
Simulation.cpp
View file @
50537e39
...
...
@@ -28,7 +28,6 @@
*
**/
#include "Simulation.h"
#include "math/GCFMModel.h"
...
...
@@ -42,7 +41,6 @@
#define omp_get_max_threads() 1
#endif
using
namespace
std
;
OutputHandler
*
Log
;
...
...
@@ -51,7 +49,7 @@ Simulation::Simulation()
{
_nPeds
=
0
;
_tmax
=
0
;
_seed
=
8091983
;
_seed
=
8091983
;
_deltaT
=
0
;
_building
=
NULL
;
_distribution
=
NULL
;
...
...
@@ -59,11 +57,11 @@ Simulation::Simulation()
_operationalModel
=
NULL
;
_solver
=
NULL
;
_iod
=
new
IODispatcher
();
_fps
=
1
;
_em
=
NULL
;
_argsParser
=
NULL
;
_hpc
=
-
1
;
_profiling
=
false
;
_fps
=
1
;
_em
=
NULL
;
_argsParser
=
NULL
;
_hpc
=
-
1
;
_profiling
=
false
;
}
Simulation
::~
Simulation
()
...
...
@@ -82,57 +80,64 @@ int Simulation::GetPedsNumber() const
return
_nPeds
;
}
void
Simulation
::
InitArgs
(
ArgumentParser
*
args
)
bool
Simulation
::
InitArgs
(
ArgumentParser
*
args
)
{
char
tmp
[
CLENGTH
];
string
s
=
"Parameter:
\n
"
;
_argsParser
=
args
;
switch
(
args
->
GetLog
())
{
_argsParser
=
args
;
switch
(
args
->
GetLog
())
{
case
0
:
// no log file
//Log = new OutputHandler();
break
;
case
1
:
if
(
Log
)
delete
Log
;
if
(
Log
)
delete
Log
;
Log
=
new
STDIOHandler
();
break
;
case
2
:
{
char
name
[
CLENGTH
]
=
""
;
sprintf
(
name
,
"%s.P0.dat"
,
args
->
GetErrorLogFile
().
c_str
());
if
(
Log
)
delete
Log
;
char
name
[
CLENGTH
]
=
""
;
sprintf
(
name
,
"%s.P0.dat"
,
args
->
GetErrorLogFile
().
c_str
());
if
(
Log
)
delete
Log
;
Log
=
new
FileHandler
(
name
);
}
break
;
break
;
default:
printf
(
"Wrong option for Logfile!
\n\n
"
);
exit
(
0
)
;
return
false
;
}
if
(
args
->
GetPort
()
!=-
1
)
{
switch
(
args
->
GetFileFormat
())
{
if
(
args
->
GetPort
()
!=
-
1
)
{
switch
(
args
->
GetFileFormat
())
{
case
FORMAT_XML_PLAIN_WITH_MESH
:
case
FORMAT_XML_PLAIN
:
{
OutputHandler
*
travisto
=
new
SocketHandler
(
args
->
GetHostname
(),
args
->
GetPort
());
Trajectories
*
output
=
new
TrajectoriesJPSV06
();
OutputHandler
*
travisto
=
new
SocketHandler
(
args
->
GetHostname
(),
args
->
GetPort
());
Trajectories
*
output
=
new
TrajectoriesJPSV06
();
output
->
SetOutputHandler
(
travisto
);
_iod
->
AddIO
(
output
);
break
;
}
case
FORMAT_XML_BIN
:
{
Log
->
Write
(
"INFO:
\t
Format xml-bin not yet supported in streaming
\n
"
);
Log
->
Write
(
"INFO:
\t
Format xml-bin not yet supported in streaming
\n
"
);
//exit(0);
break
;
}
case
FORMAT_PLAIN
:
{
Log
->
Write
(
"INFO:
\t
Format plain not yet supported in streaming
\n
"
);
exit
(
0
);
Log
->
Write
(
"INFO:
\t
Format plain not yet supported in streaming
\n
"
);
return
false
;
break
;
}
case
FORMAT_VTK
:
{
Log
->
Write
(
"INFO:
\t
Format vtk not yet supported in streaming
\n
"
);
exit
(
0
);
Log
->
Write
(
"INFO:
\t
Format vtk not yet supported in streaming
\n
"
);
return
false
;
break
;
}
}
...
...
@@ -140,26 +145,30 @@ void Simulation::InitArgs(ArgumentParser* args)
s
.
append
(
"
\t
online streaming enabled
\n
"
);
}
if
(
args
->
GetTrajectoriesFile
().
empty
()
==
false
)
{
switch
(
args
->
GetFileFormat
())
{
if
(
args
->
GetTrajectoriesFile
().
empty
()
==
false
)
{
switch
(
args
->
GetFileFormat
())
{
case
FORMAT_XML_PLAIN
:
{
OutputHandler
*
tofile
=
new
FileHandler
(
args
->
GetTrajectoriesFile
().
c_str
());
Trajectories
*
output
=
new
TrajectoriesJPSV05
();
OutputHandler
*
tofile
=
new
FileHandler
(
args
->
GetTrajectoriesFile
().
c_str
());
Trajectories
*
output
=
new
TrajectoriesJPSV05
();
output
->
SetOutputHandler
(
tofile
);
_iod
->
AddIO
(
output
);
break
;
}
case
FORMAT_PLAIN
:
{
OutputHandler
*
file
=
new
FileHandler
(
args
->
GetTrajectoriesFile
().
c_str
());
Trajectories
*
output
=
new
TrajectoriesFLAT
();
OutputHandler
*
file
=
new
FileHandler
(
args
->
GetTrajectoriesFile
().
c_str
());
Trajectories
*
output
=
new
TrajectoriesFLAT
();
output
->
SetOutputHandler
(
file
);
_iod
->
AddIO
(
output
);
break
;
}
case
FORMAT_VTK
:
{
Log
->
Write
(
"INFO:
\t
Format vtk not yet supported
\n
"
);
OutputHandler
*
file
=
new
FileHandler
((
args
->
GetTrajectoriesFile
()
+
".vtk"
).
c_str
());
Trajectories
*
output
=
new
TrajectoriesVTK
();
OutputHandler
*
file
=
new
FileHandler
(
(
args
->
GetTrajectoriesFile
()
+
".vtk"
).
c_str
());
Trajectories
*
output
=
new
TrajectoriesVTK
();
output
->
SetOutputHandler
(
file
);
_iod
->
AddIO
(
output
);
break
;
...
...
@@ -190,7 +199,8 @@ void Simulation::InitArgs(ArgumentParser* args)
int
direction
=
args
->
GetExitStrategy
();
sprintf
(
tmp
,
"
\t
Direction to the exit: %d
\n
"
,
direction
);
s
.
append
(
tmp
);
switch
(
direction
)
{
switch
(
direction
)
{
case
1
:
_direction
=
new
DirectionMiddlePoint
();
break
;
...
...
@@ -205,17 +215,20 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
default:
_direction
=
new
DirectionMinSeperationShorterLine
();
sprintf
(
tmp
,
"
\t
Warning Direction %d is not in [1,4]. Fall back to 2
\n
"
,
direction
);
sprintf
(
tmp
,
"
\t
Warning Direction %d is not in [1,4]. Fall back to 2
\n
"
,
direction
);
s
.
append
(
tmp
);
break
;
}
int
model
=
args
->
GetModel
();
if
(
model
==
MODEL_GFCM
)
{
//GCFM
//if(args->GetHPCFlag()==0){
_operationalModel
=
new
GCFMModel
(
_direction
,
args
->
GetNuPed
(),
args
->
GetNuWall
(),
args
->
GetDistEffMaxPed
(),
args
->
GetDistEffMaxWall
(),
args
->
GetIntPWidthPed
(),
args
->
GetIntPWidthWall
(),
args
->
GetMaxFPed
(),
args
->
GetMaxFWall
());
int
model
=
args
->
GetModel
();
if
(
model
==
MODEL_GFCM
)
{
//GCFM
//if(args->GetHPCFlag()==0){
_operationalModel
=
new
GCFMModel
(
_direction
,
args
->
GetNuPed
(),
args
->
GetNuWall
(),
args
->
GetDistEffMaxPed
(),
args
->
GetDistEffMaxWall
(),
args
->
GetIntPWidthPed
(),
args
->
GetIntPWidthWall
(),
args
->
GetMaxFPed
(),
args
->
GetMaxFWall
());
s
.
append
(
"
\t
Model: GCFMModel
\n
"
);
s
.
append
(
_operationalModel
->
GetDescription
());
//}
...
...
@@ -233,11 +246,11 @@ void Simulation::InitArgs(ArgumentParser* args)
//s.append("\tModel: GCFMModel\n");
//s.append(_model->writeParameter());
//}
}
else
if
(
model
==
MODEL_GOMPERTZ
)
{
//Gompertz
_operationalModel
=
new
GompertzModel
(
_direction
,
args
->
GetNuPed
(),
args
->
GetaPed
(),
args
->
GetbPed
(),
args
->
GetcPed
(),
args
->
Get
NuWall
(),
args
->
GetaWall
(),
args
->
GetbWall
(),
args
->
GetcWall
()
);
}
else
if
(
model
==
MODEL_GOMPERTZ
)
{
//Gompertz
_operationalModel
=
new
GompertzModel
(
_direction
,
args
->
GetNuPed
(),
args
->
GetaPed
(),
args
->
GetbPed
(),
args
->
GetcPed
(),
args
->
GetNuWall
(),
args
->
GetaWall
(),
args
->
GetbWall
(),
args
->
Get
cWall
()
);
s
.
append
(
"
\t
Model: GompertzModel
\n
"
);
s
.
append
(
_operationalModel
->
GetDescription
());
}
...
...
@@ -248,14 +261,14 @@ void Simulation::InitArgs(ArgumentParser* args)
s
.
append
(
tmp
);
//switch (solver) {
//case 1:
//_solver = new EulerSolver(_model);
//break;
//case 2:
// _solver = new VelocityVerletSolver(_model);
// break;
//case 3:
// _solver = new LeapfrogSolver(_model);
// break;
//_solver = new EulerSolver(_model);
//break;
//case 2:
// _solver = new VelocityVerletSolver(_model);
// break;
//case 3:
// _solver = new LeapfrogSolver(_model);
// break;
//}
sprintf
(
tmp
,
"
\t
nCPU: %d
\n
"
,
args
->
GetMaxOpenMPThreads
());
s
.
append
(
tmp
);
...
...
@@ -266,23 +279,24 @@ void Simulation::InitArgs(ArgumentParser* args)
sprintf
(
tmp
,
"
\t
dt: %f
\n
"
,
_deltaT
);
s
.
append
(
tmp
);
_fps
=
args
->
Getfps
();
_fps
=
args
->
Getfps
();
sprintf
(
tmp
,
"
\t
fps: %f
\n
"
,
_fps
);
s
.
append
(
tmp
);
// Route choice
vector
<
pair
<
int
,
RoutingStrategy
>
>
routers
=
args
->
GetRoutingStrategy
();
RoutingEngine
*
routingEngine
=
new
RoutingEngine
();
vector
<
pair
<
int
,
RoutingStrategy
>
>
routers
=
args
->
GetRoutingStrategy
();
RoutingEngine
*
routingEngine
=
new
RoutingEngine
();
for
(
unsigned
int
r
=
0
;
r
<
routers
.
size
();
r
++
)
{
for
(
unsigned
int
r
=
0
;
r
<
routers
.
size
();
r
++
)
{
RoutingStrategy
strategy
=
routers
[
r
].
second
;
RoutingStrategy
strategy
=
routers
[
r
].
second
;
int
routerID
=
routers
[
r
].
first
;
int
routerID
=
routers
[
r
].
first
;
switch
(
strategy
)
{
switch
(
strategy
)
{
case
ROUTING_LOCAL_SHORTEST
:
{
Router
*
router
=
new
GlobalRouter
();
Router
*
router
=
new
GlobalRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -290,7 +304,7 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
}
case
ROUTING_GLOBAL_SHORTEST
:
{
Router
*
router
=
new
GlobalRouter
();
Router
*
router
=
new
GlobalRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -298,7 +312,7 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
}
case
ROUTING_QUICKEST
:
{
Router
*
router
=
new
QuickestPathRouter
();
Router
*
router
=
new
QuickestPathRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -306,7 +320,7 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
}
case
ROUTING_DYNAMIC
:
{
Router
*
router
=
new
GraphRouter
();
Router
*
router
=
new
GraphRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -314,7 +328,7 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
}
case
ROUTING_NAV_MESH
:
{
Router
*
router
=
new
MeshRouter
();
Router
*
router
=
new
MeshRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -322,7 +336,7 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
}
case
ROUTING_DUMMY
:
{
Router
*
router
=
new
DummyRouter
();
Router
*
router
=
new
DummyRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -330,7 +344,7 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
}
case
ROUTING_SAFEST
:
{
Router
*
router
=
new
SafestPathRouter
();
Router
*
router
=
new
SafestPathRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -338,7 +352,7 @@ void Simulation::InitArgs(ArgumentParser* args)
break
;
}
case
ROUTING_COGNITIVEMAP
:
{
Router
*
router
=
new
CognitiveMapRouter
();
Router
*
router
=
new
CognitiveMapRouter
();
router
->
SetID
(
routerID
);
router
->
SetStrategy
(
strategy
);
routingEngine
->
AddRouter
(
router
);
...
...
@@ -347,8 +361,8 @@ void Simulation::InitArgs(ArgumentParser* args)
}
case
ROUTING_UNDEFINED
:
default:
cout
<<
"router not available"
<<
endl
;
exit
(
EXIT_FAILURE
)
;
cout
<<
"router not available"
<<
endl
;
return
false
;
break
;
}
}
...
...
@@ -360,14 +374,20 @@ void Simulation::InitArgs(ArgumentParser* args)
_building
->
SetProjectFilename
(
args
->
GetProjectFile
());
_building
->
SetProjectRootDir
(
args
->
GetProjectRootDir
());
_building
->
LoadGeometry
();
_building
->
LoadRoutingInfo
(
args
->
GetProjectFile
());
if
(
!
_building
->
LoadGeometry
())
return
false
;
if
(
!
_building
->
LoadRoutingInfo
(
args
->
GetProjectFile
()))
return
false
;
//_building->AddSurroundingRoom();
_building
->
InitGeometry
();
// create the polygons
_building
->
LoadTrafficInfo
();
if
(
!
_building
->
InitGeometry
())
return
false
;
// create the polygons
if
(
!
_building
->
LoadTrafficInfo
())
return
false
;
_nPeds
=
_distribution
->
Distribute
(
_building
);
_nPeds
=
_distribution
->
Distribute
(
_building
);
//using linkedcells
if
(
args
->
GetLinkedCells
())
{
...
...
@@ -378,31 +398,35 @@ void Simulation::InitArgs(ArgumentParser* args)
}
// initialize the routing engine before doing any other things
routingEngine
->
Init
(
_building
);
if
(
routingEngine
->
Init
(
_building
)
==
false
)
return
false
;
//perform customs initialisation, like computing the phi for the gcfm
//this should be called after the routing engine has been initialised
// because a direction is needed for this initialisation.
_operationalModel
->
Init
(
_building
);
if
(
_operationalModel
->
Init
(
_building
)
==
false
)
return
false
;
//other initializations
const
vector
<
Pedestrian
*
>&
allPeds
=
_building
->
GetAllPedestrians
();
for
(
Pedestrian
*
ped
:
allPeds
)
{
ped
->
Setdt
(
_deltaT
);
}
const
vector
<
Pedestrian
*>&
allPeds
=
_building
->
GetAllPedestrians
();
for
(
Pedestrian
*
ped
:
allPeds
)
{
ped
->
Setdt
(
_deltaT
);
}
//pBuilding->WriteToErrorLog();
//get the seed
_seed
=
args
->
GetSeed
();
_seed
=
args
->
GetSeed
();
// perform a general check to the .
_building
->
SanityCheck
();
if
(
_building
->
SanityCheck
()
==
false
)
return
false
;
//size of the cells/GCFM/Gompertz
if
(
args
->
GetDistEffMaxPed
()
>
args
->
GetLinkedCellSize
()){
Log
->
Write
(
"ERROR: the linked-cell size [%f] should be bigger than the force range [%f]"
,
args
->
GetLinkedCellSize
(),
args
->
GetDistEffMaxPed
());
exit
(
EXIT_FAILURE
);
if
(
args
->
GetDistEffMaxPed
()
>
args
->
GetLinkedCellSize
())
{
Log
->
Write
(
"ERROR: the linked-cell size [%f] should be bigger than the force range [%f]"
,
args
->
GetLinkedCellSize
(),
args
->
GetDistEffMaxPed
());
return
false
;
}
//read the events
...
...
@@ -420,20 +444,22 @@ void Simulation::InitArgs(ArgumentParser* args)
//((GPU_ocl_GCFMModel*) _model)->initCL(_building->GetNumberOfPedestrians());
//}
//_building->SaveGeometry("test.sav.xml");
}
//everything went fine
return
true
;
}
int
Simulation
::
RunSimulation
()
{
int
frameNr
=
1
;
// Frame Number
int
writeInterval
=
(
int
)
((
1.
/
_fps
)
/
_deltaT
+
0.5
);
writeInterval
=
(
writeInterval
<=
0
)
?
1
:
writeInterval
;
// mustn't be <= 0
double
t
=
0.0
;
double
t
=
0.0
;
// writing the header
_iod
->
WriteHeader
(
_nPeds
,
_fps
,
_building
,
_seed
);
_iod
->
WriteHeader
(
_nPeds
,
_fps
,
_building
,
_seed
);
_iod
->
WriteGeometry
(
_building
);
_iod
->
WriteFrame
(
0
,
_building
);
_iod
->
WriteFrame
(
0
,
_building
);
//first initialisation needed by the linked-cells
UpdateRoutesAndLocations
();
...
...
@@ -444,29 +470,28 @@ int Simulation::RunSimulation()
//time(&starttime);
// main program loop
for
(
t
=
0
;
t
<
_tmax
&&
_nPeds
>
0
;
++
frameNr
)
{
for
(
t
=
0
;
t
<
_tmax
&&
_nPeds
>
0
;
++
frameNr
)
{
t
=
0
+
(
frameNr
-
1
)
*
_deltaT
;
// update the positions
_operationalModel
->