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
138e6066
Commit
138e6066
authored
Dec 11, 2018
by
tobias schroedter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP Commit, needs to clean up CMakeLists.txt
parent
5b35dc65
Changes
63
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
14167 additions
and
192 deletions
+14167
-192
CMakeLists.txt
CMakeLists.txt
+245
-128
IO/GeoFileParser.cpp
IO/GeoFileParser.cpp
+26
-24
IO/GeoFileParser.h
IO/GeoFileParser.h
+1
-1
IO/IniFileParser.cpp
IO/IniFileParser.cpp
+55
-3
Simulation.cpp
Simulation.cpp
+7
-2
Simulation.h
Simulation.h
+1
-0
general/ArgumentParser.cpp
general/ArgumentParser.cpp
+1
-0
general/Macros.h
general/Macros.h
+2
-0
geometry/Trips.cpp
geometry/Trips.cpp
+2
-8
geometry/Trips.h
geometry/Trips.h
+0
-0
routing/Router.cpp
routing/Router.cpp
+4
-0
routing/Router.h
routing/Router.h
+3
-1
routing/RoutingEngine.cpp
routing/RoutingEngine.cpp
+21
-15
routing/RoutingEngine.h
routing/RoutingEngine.h
+9
-8
routing/ai_router_trips/BrainStorage.cpp
routing/ai_router_trips/BrainStorage.cpp
+383
-0
routing/ai_router_trips/BrainStorage.h
routing/ai_router_trips/BrainStorage.h
+92
-0
routing/ai_router_trips/Cortex.cpp
routing/ai_router_trips/Cortex.cpp
+554
-0
routing/ai_router_trips/Cortex.h
routing/ai_router_trips/Cortex.h
+65
-0
routing/ai_router_trips/cognitiveMap/associations.cpp
routing/ai_router_trips/cognitiveMap/associations.cpp
+61
-0
routing/ai_router_trips/cognitiveMap/associations.h
routing/ai_router_trips/cognitiveMap/associations.h
+26
-0
routing/ai_router_trips/cognitiveMap/cognitivemap.cpp
routing/ai_router_trips/cognitiveMap/cognitivemap.cpp
+679
-0
routing/ai_router_trips/cognitiveMap/cognitivemap.h
routing/ai_router_trips/cognitiveMap/cognitivemap.h
+87
-0
routing/ai_router_trips/cognitiveMap/connection.cpp
routing/ai_router_trips/cognitiveMap/connection.cpp
+53
-0
routing/ai_router_trips/cognitiveMap/connection.h
routing/ai_router_trips/cognitiveMap/connection.h
+35
-0
routing/ai_router_trips/cognitiveMap/internnavigationnetwork.cpp
.../ai_router_trips/cognitiveMap/internnavigationnetwork.cpp
+184
-0
routing/ai_router_trips/cognitiveMap/internnavigationnetwork.h
...ng/ai_router_trips/cognitiveMap/internnavigationnetwork.h
+62
-0
routing/ai_router_trips/cognitiveMap/landmark.cpp
routing/ai_router_trips/cognitiveMap/landmark.cpp
+198
-0
routing/ai_router_trips/cognitiveMap/landmark.h
routing/ai_router_trips/cognitiveMap/landmark.h
+82
-0
routing/ai_router_trips/cognitiveMap/landmarknetwork.cpp
routing/ai_router_trips/cognitiveMap/landmarknetwork.cpp
+258
-0
routing/ai_router_trips/cognitiveMap/landmarknetwork.h
routing/ai_router_trips/cognitiveMap/landmarknetwork.h
+52
-0
routing/ai_router_trips/cognitiveMap/region.cpp
routing/ai_router_trips/cognitiveMap/region.cpp
+112
-0
routing/ai_router_trips/cognitiveMap/region.h
routing/ai_router_trips/cognitiveMap/region.h
+46
-0
routing/ai_router_trips/perception/cgalgeometry.cpp
routing/ai_router_trips/perception/cgalgeometry.cpp
+268
-0
routing/ai_router_trips/perception/cgalgeometry.h
routing/ai_router_trips/perception/cgalgeometry.h
+53
-0
routing/ai_router_trips/perception/sign.cpp
routing/ai_router_trips/perception/sign.cpp
+83
-0
routing/ai_router_trips/perception/sign.h
routing/ai_router_trips/perception/sign.h
+50
-0
routing/ai_router_trips/perception/visibleenvironment.cpp
routing/ai_router_trips/perception/visibleenvironment.cpp
+234
-0
routing/ai_router_trips/perception/visibleenvironment.h
routing/ai_router_trips/perception/visibleenvironment.h
+40
-0
routing/ai_router_trips/perception/visualsystem.cpp
routing/ai_router_trips/perception/visualsystem.cpp
+684
-0
routing/ai_router_trips/perception/visualsystem.h
routing/ai_router_trips/perception/visualsystem.h
+87
-0
routing/ff_router_trips/FFKit.cpp
routing/ff_router_trips/FFKit.cpp
+43
-0
routing/ff_router_trips/FFKit.h
routing/ff_router_trips/FFKit.h
+103
-0
routing/ff_router_trips/FloorfieldViaFM.cpp
routing/ff_router_trips/FloorfieldViaFM.cpp
+1785
-0
routing/ff_router_trips/FloorfieldViaFM.h
routing/ff_router_trips/FloorfieldViaFM.h
+226
-0
routing/ff_router_trips/LocalFloorfieldViaFM.cpp
routing/ff_router_trips/LocalFloorfieldViaFM.cpp
+519
-0
routing/ff_router_trips/LocalFloorfieldViaFM.h
routing/ff_router_trips/LocalFloorfieldViaFM.h
+86
-0
routing/ff_router_trips/UnivFFviaFM.cpp
routing/ff_router_trips/UnivFFviaFM.cpp
+1881
-0
routing/ff_router_trips/UnivFFviaFM.h
routing/ff_router_trips/UnivFFviaFM.h
+179
-0
routing/ff_router_trips/ffRouterTrips.cpp
routing/ff_router_trips/ffRouterTrips.cpp
+664
-0
routing/ff_router_trips/ffRouterTrips.h
routing/ff_router_trips/ffRouterTrips.h
+232
-0
routing/ff_router_trips/mesh/RectGrid.h
routing/ff_router_trips/mesh/RectGrid.h
+257
-0
routing/ff_router_trips/mesh/Trial.h
routing/ff_router_trips/mesh/Trial.h
+172
-0
routing/global_shortest_trips/AccessPoint.cpp
routing/global_shortest_trips/AccessPoint.cpp
+315
-0
routing/global_shortest_trips/AccessPoint.h
routing/global_shortest_trips/AccessPoint.h
+228
-0
routing/global_shortest_trips/ConvexDecomp.h
routing/global_shortest_trips/ConvexDecomp.h
+327
-0
routing/global_shortest_trips/DTriangulation.cpp
routing/global_shortest_trips/DTriangulation.cpp
+78
-0
routing/global_shortest_trips/DTriangulation.h
routing/global_shortest_trips/DTriangulation.h
+96
-0
routing/global_shortest_trips/GlobalRouterTrips.cpp
routing/global_shortest_trips/GlobalRouterTrips.cpp
+1612
-0
routing/global_shortest_trips/GlobalRouterTrips.h
routing/global_shortest_trips/GlobalRouterTrips.h
+244
-0
routing/global_shortest_trips/Triangulation.h
routing/global_shortest_trips/Triangulation.h
+130
-0
routing/quickest/QuickestPathRouter.h
routing/quickest/QuickestPathRouter.h
+5
-2
routing/trips_router/TripsRouter.cpp
routing/trips_router/TripsRouter.cpp
+43
-0
routing/trips_router/TripsRouter.h
routing/trips_router/TripsRouter.h
+37
-0
No files found.
CMakeLists.txt
View file @
138e6066
This diff is collapsed.
Click to expand it.
IO/GeoFileParser.cpp
View file @
138e6066
...
...
@@ -482,34 +482,36 @@ bool GeoFileParser::LoadRoutingInfo(Building* building)
std
::
cout
<<
waitingArea
->
toString
()
<<
std
::
endl
;
}
// building->AddTrip(trips);
_configuration
->
GetRoutingEngine
()
->
AddTrip
(
trips
);
std
::
cout
<<
trips
;
}
//load routes
TiXmlNode
*
xTripsNode
=
xRootNode
->
FirstChild
(
"routing"
)
->
FirstChild
(
"routes"
);
if
(
xTripsNode
)
for
(
TiXmlElement
*
trip
=
xTripsNode
->
FirstChildElement
(
"route"
);
trip
;
trip
=
trip
->
NextSiblingElement
(
"route"
))
{
double
id
=
xmltof
(
trip
->
Attribute
(
"id"
),
-
1
);
if
(
id
==-
1
)
{
Log
->
Write
(
"ERROR:
\t
id missing for trip"
);
return
false
;
}
std
::
string
sTrip
=
trip
->
FirstChild
()
->
ValueStr
();
std
::
vector
<
std
::
string
>
vTrip
;
vTrip
.
clear
();
char
*
str
=
(
char
*
)
sTrip
.
c_str
();
char
*
p
=
strtok
(
str
,
":"
);
while
(
p
)
{
vTrip
.
push_back
(
xmltoa
(
p
));
p
=
strtok
(
NULL
,
":"
);
}
_configuration
->
GetRoutingEngine
()
->
AddTrip
(
vTrip
);
}
//
TiXmlNode* xTripsNode = xRootNode->FirstChild("routing")->FirstChild("routes");
//
//
if (xTripsNode)
//
for (TiXmlElement* trip = xTripsNode->FirstChildElement("route"); trip;
//
trip = trip->NextSiblingElement("route")) {
//
//
double id = xmltof(trip->Attribute("id"), -1);
//
if (id==-1) {
//
Log->Write("ERROR:\t id missing for trip");
//
return false;
//
}
//
std::string sTrip = trip->FirstChild()->ValueStr();
//
std::vector<std::string> vTrip;
//
vTrip.clear();
//
//
char* str = (char*) sTrip.c_str();
//
char* p = strtok(str, ":");
//
while (p) {
//
vTrip.push_back(xmltoa(p));
//
p = strtok(NULL, ":");
//
}
//
_configuration->GetRoutingEngine()->AddTrip(vTrip);
//
}
Log
->
Write
(
"INFO:
\t
done with loading extra routing information"
);
return
true
;
}
...
...
IO/GeoFileParser.h
View file @
138e6066
...
...
@@ -25,7 +25,7 @@
#include "../general/Configuration.h"
#include "../geometry/Building.h"
#include "../geometry/GeometryReader.h"
#include "Trips.h"
#include "
../geometry/
Trips.h"
//TODO: the class name GeoFileParser is misleading as the ``geometry'' file contains among others also relations (transitions)
//TODO: between geometries/rooms. Probably, EnvironmentFileParser would be better, still parts of the environment are
...
...
IO/IniFileParser.cpp
View file @
138e6066
...
...
@@ -40,10 +40,13 @@
#include "../math/GradientModel.h"
#include "../math/VelocityModel.h"
#include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/global_shortest_trips/GlobalRouterTrips.h"
#include "../routing/quickest/QuickestPathRouter.h"
#include "../routing/smoke_router/SmokeRouter.h"
#include "../routing/ai_router/AIRouter.h"
#include "../routing/ff_router/ffRouter.h"
#include "../routing/ff_router_trips/ffRouterTrips.h"
#include "../routing/trips_router/TripsRouter.h"
/* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */
std
::
string
ver_string
(
int
a
,
int
b
,
int
c
)
{
...
...
@@ -1134,6 +1137,13 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
Router
*
r
=
new
GlobalRouter
(
id
,
ROUTING_GLOBAL_SHORTEST
);
_config
->
GetRoutingEngine
()
->
AddRouter
(
r
);
}
else
if
((
strategy
==
"global_shortest_trips"
)
&&
(
std
::
find
(
usedRouter
.
begin
(),
usedRouter
.
end
(),
id
)
!=
usedRouter
.
end
())
)
{
//pRoutingStrategies.push_back(make_pair(id, ROUTING_GLOBAL_SHORTEST));
Router
*
r
=
new
GlobalRouterTrips
(
id
,
ROUTING_GLOBAL_SHORTEST
);
_config
->
GetRoutingEngine
()
->
AddRouter
(
r
);
}
else
if
((
strategy
==
"quickest"
)
&&
(
std
::
find
(
usedRouter
.
begin
(),
usedRouter
.
end
(),
id
)
!=
usedRouter
.
end
())
)
{
//pRoutingStrategies.push_back(make_pair(id, ROUTING_QUICKEST));
...
...
@@ -1169,14 +1179,30 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
exit
(
EXIT_FAILURE
);
#endif
}
else
if
((
strategy
==
"ff_global_shortest"
)
&&
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
(
"
\n
INFO:
\t
Using AIRouter Trips"
);
///Parsing additional options
if
(
!
ParseAIOpts
(
e
))
return
false
;
#else
std
::
cerr
<<
"
\n
Can not use AI Router. Rerun cmake with option -DAIROUTER=true and recompile.
\n
"
;
exit
(
EXIT_FAILURE
);
#endif
}
else
if
((
strategy
==
"ff_global_shortest_trips"
)
&&
(
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
);
Router
*
r
=
new
FFRouter
Trips
(
id
,
ROUTING_FF_GLOBAL_SHORTEST
,
hasSpecificGoals
,
_config
);
_config
->
GetRoutingEngine
()
->
AddRouter
(
r
);
if
((
_exit_strat_number
==
8
)
||
(
_exit_strat_number
==
9
)){
Log
->
Write
(
"
\n
INFO:
\t
Using FF Global Shortest Router"
);
Log
->
Write
(
"
\n
INFO:
\t
Using FF Global Shortest Router
Trips
"
);
}
else
{
Log
->
Write
(
"
\n
WARNING:
\t
Exit Strategy Number is not 8 or 9!!!"
);
...
...
@@ -1188,6 +1214,26 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
return
false
;
}
}
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
(
"
\n
INFO:
\t
Using FF Global Shortest Router"
);
}
else
{
Log
->
Write
(
"
\n
WARNING:
\t
Exit 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
;
}
}
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));
...
...
@@ -1221,6 +1267,12 @@ bool IniFileParser::ParseRoutingStrategies(TiXmlNode* routingNode, TiXmlNode* ag
return
false
;
}
}
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
);
}
else
if
(
std
::
find
(
usedRouter
.
begin
(),
usedRouter
.
end
(),
id
)
!=
usedRouter
.
end
())
{
Log
->
Write
(
"ERROR:
\t
wrong value for routing strategy [%s]!!!
\n
"
,
strategy
.
c_str
());
...
...
Simulation.cpp
View file @
138e6066
...
...
@@ -299,6 +299,12 @@ void Simulation::UpdateRoutesAndLocations()
const
map
<
int
,
Goal
*>&
goals
=
_building
->
GetAllGoals
();
auto
allRooms
=
_building
->
GetAllRooms
();
// for (signed int p = 0; p < allPeds.size(); ++p) {
// Pedestrian* ped = allPeds[p];
//
// std::cout << "FinalDestination of [" << ped->GetID() << "] in (" << ped->GetRoomID() << ", " << ped->GetSubRoomID() << "/" << ped->GetSubRoomUID() << "): " << ped->GetFinalDestination() << std::endl;
// }
#pragma omp parallel for shared(pedsToRemove, allRooms)
for
(
signed
int
p
=
0
;
p
<
allPeds
.
size
();
++
p
)
{
auto
ped
=
allPeds
[
p
];
...
...
@@ -307,8 +313,7 @@ void Simulation::UpdateRoutesAndLocations()
//set the new room if needed
if
((
ped
->
GetFinalDestination
()
==
FINAL_DEST_OUT
)
&&
(
room
->
GetCaption
()
==
"outside"
))
{
&&
(
room
->
GetCaption
()
==
"outside"
))
{
//TODO Hier aendern fuer inside goals?
#pragma omp critical(Simulation_Update_pedsToRemove)
pedsToRemove
.
insert
(
ped
);
}
else
if
((
ped
->
GetFinalDestination
()
!=
FINAL_DEST_OUT
)
...
...
Simulation.h
View file @
138e6066
...
...
@@ -41,6 +41,7 @@
#include "math/OperationalModel.h"
#include "math/ODESolver.h"
#include "routing/global_shortest/GlobalRouter.h"
#include "routing/global_shortest_trips/GlobalRouterTrips.h"
#include "routing/quickest/QuickestPathRouter.h"
#include "routing/DirectionStrategy.h"
#include "routing/RoutingEngine.h"
...
...
general/ArgumentParser.cpp
View file @
138e6066
...
...
@@ -43,6 +43,7 @@
#include "ArgumentParser.h"
#include "../pedestrian/AgentsParameters.h"
#include "../routing/global_shortest/GlobalRouter.h"
#include "../routing/global_shortest_trips/GlobalRouterTrips.h"
#include "../routing/quickest/QuickestPathRouter.h"
#include "../routing/smoke_router/SmokeRouter.h"
#include "../IO/IniFileParser.h"
...
...
general/Macros.h
View file @
138e6066
...
...
@@ -128,10 +128,12 @@ enum RoutingStrategy {
ROUTING_FROM_FILE
,
ROUTING_SMOKE
,
ROUTING_AI
,
ROUTING_AI_TRIPS
,
ROUTING_FLOORFIELD
,
ROUTING_FF_GLOBAL_SHORTEST
,
ROUTING_FF_LOCAL_SHORTEST
,
ROUTING_FF_QUICKEST
,
ROUTING_TRIPS
,
ROUTING_UNDEFINED
=-
1
};
...
...
IO
/Trips.cpp
→
geometry
/Trips.cpp
View file @
138e6066
...
...
@@ -3,7 +3,6 @@
//
#include "Trips.h"
//#include <random>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp>
...
...
@@ -39,7 +38,8 @@ VertexItr Trips::getGoal(int id)
for
(
boost
::
tie
(
vi
,
vi_end
)
=
boost
::
vertices
(
trips
);
vi
!=
vi_end
;
++
vi
)
{
if
(
trips
[
*
vi
].
getID
()
==
id
)
return
vi
;
}
return
vi_end
;}
return
vi_end
;
}
void
Trips
::
addConnection
(
int
sourceId
,
int
destinationId
,
EdgeProperty
&
weight
)
{
...
...
@@ -87,12 +87,6 @@ int Trips::getNextGoal(int id)
}
// Random number generator
// std::random_device rd;
// std::mt19937 gen(rd());
//
// std::default_random_engine generator;
// std::discrete_distribution<double> distribution (weights.begin(), weights.end());
boost
::
mt19937
gen
;
boost
::
random
::
discrete_distribution
<>
dist
(
weights
.
begin
(),
weights
.
end
());
...
...
IO
/Trips.h
→
geometry
/Trips.h
View file @
138e6066
File moved
routing/Router.cpp
View file @
138e6066
...
...
@@ -94,3 +94,7 @@ RoutingStrategy Router::GetStrategy() const
return
_strategy
;
}
void
Router
::
SetTrips
(
const
Trips
&
trips
){
_trips
=
trips
;
std
::
cout
<<
_trips
<<
std
::
endl
;
}
routing/Router.h
View file @
138e6066
...
...
@@ -34,7 +34,7 @@
#include <vector>
#include "../general/Macros.h"
#include "../
IO
/Trips.h"
#include "../
geometry
/Trips.h"
class
Building
;
class
Pedestrian
;
...
...
@@ -140,6 +140,8 @@ public:
*/
virtual
bool
ParseAdditionalParameters
(){
return
true
;};
void
SetTrips
(
const
Trips
&
trips
);
};
#endif
/* _ROUTING_H */
routing/RoutingEngine.cpp
View file @
138e6066
...
...
@@ -28,6 +28,7 @@
#include "RoutingEngine.h"
#include "../pedestrian/Pedestrian.h"
#include "../geometry/Trips.h"
using
namespace
std
;
...
...
@@ -68,19 +69,19 @@ void RoutingEngine::AddRouter(Router* router)
}
_routersCollection
.
push_back
(
router
);
}
const
vector
<
string
>&
RoutingEngine
::
GetTrip
(
int
index
)
const
{
if
((
index
>=
0
)
&&
(
index
<
(
int
)
_tripsCollection
.
size
()))
return
_tripsCollection
[
index
];
else
{
char
tmp
[
CLENGTH
];
sprintf
(
tmp
,
"ERROR:
\t
Wrong 'index' [%d] > [%d] in Routing::GetTrip()"
,
index
,
int
(
_tripsCollection
.
size
()));
Log
->
Write
(
tmp
);
exit
(
EXIT_FAILURE
);
}
}
//
//
const vector<string>& RoutingEngine::GetTrip(int index) const
//
{
//
if ((index >= 0) && (index < (int) _tripsCollection.size()))
//
return _tripsCollection[index];
//
else {
//
char tmp[CLENGTH];
//
sprintf(tmp, "ERROR: \tWrong 'index' [%d] > [%d] in Routing::GetTrip()",
//
index, int(_tripsCollection.size()));
//
Log->Write(tmp);
//
exit(EXIT_FAILURE);
//
}
//
}
const
std
::
vector
<
Router
*>
RoutingEngine
::
GetAvailableRouters
()
const
{
...
...
@@ -110,9 +111,14 @@ Router* RoutingEngine::GetRouter(int id) const
return
/*(Router*)*/
nullptr
;
}
void
RoutingEngine
::
AddTrip
(
vector
<
string
>
trip
)
void
RoutingEngine
::
AddTrip
(
Trips
trip
)
{
_tripsCollection
.
push_back
(
trip
);
// _tripsCollection.push_back(trip);
// _tripsCollection = trip;
for
(
Router
*
router
:
_routersCollection
)
{
router
->
SetTrips
(
trip
);
}
}
bool
RoutingEngine
::
Init
(
Building
*
building
)
...
...
routing/RoutingEngine.h
View file @
138e6066
...
...
@@ -36,6 +36,7 @@
class
Pedestrian
;
class
Trips
;
class
RoutingEngine
{
public:
...
...
@@ -60,14 +61,14 @@ public:
* Add a new trip to the system. Individual pedestrian can be assigned a particular trip.
* @param trip
*/
void
AddTrip
(
std
::
vector
<
std
::
string
>
trip
);
void
AddTrip
(
Trips
trip
);
/**
* Return a trip/route with the particular id
* @param id, the trip id
* @return the corresponding trip
*/
const
std
::
vector
<
std
::
string
>&
GetTrip
(
int
id
)
const
;
//
/**
//
* Return a trip/route with the particular id
//
* @param id, the trip id
//
* @return the corresponding trip
//
*/
//
const std::vector<std::string>& GetTrip(int id) const;
/**
* @return all available routers
...
...
@@ -111,7 +112,7 @@ private:
/// collections of all routers used
std
::
vector
<
Router
*>
_routersCollection
;
/// collection of all trips/routes
std
::
vector
<
std
::
vector
<
std
::
string
>
>
_tripsCollection
;
Trips
_tripsCollection
;
};
#endif
/* ROUTINGENGINE_H_ */
routing/ai_router_trips/BrainStorage.cpp
0 → 100644
View file @
138e6066
/**
* \file CognitiveMapStorage.cpp
* \date Feb 1, 2014
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \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/>.
*
* \section Description
* Cognitive Map Storage
*
*
**/
#include "BrainStorage.h"
#include "cognitiveMap/internnavigationnetwork.h"
#include "../../tinyxml/tinyxml.h"
#include <memory>
#include "../../geometry/Building.h"
#include "../../pedestrian/Pedestrian.h"
//#include "NavigationGraph.h"
AIBrainStorage
::
AIBrainStorage
(
const
Building
*
const
b
,
const
std
::
string
&
cogMapFiles
,
const
std
::
string
&
signFiles
)
:
_building
(
b
),
_visibleEnv
(
VisibleEnvironment
(
b
)),
_cogMapFiles
(
cogMapFiles
),
_signFiles
(
signFiles
)
{
//Set signs
ParseSigns
();
}
Cortex
*
AIBrainStorage
::
operator
[]
(
BStorageKeyType
key
)
{
BStorageType
::
iterator
it
=
_corteces
.
find
(
key
);
if
(
it
==
_corteces
.
end
())
{
CreateCortex
(
key
);
}
return
_corteces
[
key
].
get
();
}
void
AIBrainStorage
::
ParseCogMap
(
BStorageKeyType
ped
)
{
_regions
.
clear
();
//create filename
int
groupId
=
ped
->
GetGroup
();
if
(
_cogMapFiles
==
""
)
return
;
std
::
string
cMFileName
=
_cogMapFiles
;
cMFileName
.
replace
(
cMFileName
.
size
()
-
4
,
4
,
std
::
to_string
(
groupId
)
+
".xml"
);
std
::
string
cogMapFilenameWithPath
=
_building
->
GetProjectRootDir
()
+
cMFileName
;
Log
->
Write
(
cogMapFilenameWithPath
);
TiXmlDocument
doccogMap
(
cogMapFilenameWithPath
);
if
(
!
doccogMap
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
doccogMap
.
ErrorDesc
());
Log
->
Write
(
"
\t
could not parse the cognitive map file"
);
Log
->
Write
(
"Cognitive map not specified"
);
return
;
}
TiXmlElement
*
xRootNode
=
doccogMap
.
RootElement
();
if
(
!
xRootNode
)
{
Log
->
Write
(
"ERROR:
\t
Root element does not exist"
);
Log
->
Write
(
"Cognitive map not specified"
);
return
;
}
if
(
xRootNode
->
ValueStr
()
!=
"cognitiveMap"
)
{
Log
->
Write
(
"ERROR:
\t
Root element value is not 'cognitiveMap'."
);
Log
->
Write
(
"Cognitive map not specified"
);
return
;
}
if
(
xRootNode
->
Attribute
(
"unit"
))
if
(
std
::
string
(
xRootNode
->
Attribute
(
"unit"
))
!=
"m"
)
{
Log
->
Write
(
"ERROR:
\t
Only the unit m (meters) is supported.
\n\t
You supplied [%s]"
,
xRootNode
->
Attribute
(
"unit"
));
Log
->
Write
(
"Cognitive map not specified"
);
return
;
}
double
version
=
xmltof
(
xRootNode
->
Attribute
(
"version"
),
-
1
);
if
(
version
<
std
::
stod
(
JPS_OLD_VERSION
)
)
{
Log
->
Write
(
"
\t
Wrong geometry version!"
);
Log
->
Write
(
"
\t
Only version >= %s supported"
,
JPS_VERSION
);
Log
->
Write
(
"
\t
Please update the version of your geometry file to %s"
,
JPS_VERSION
);
Log
->
Write
(
"Cognitive map not specified"
);
return
;
}
//processing the regions node
TiXmlNode
*
xRegionsNode
=
xRootNode
->
FirstChild
(
"regions"
);
if
(
!
xRegionsNode
)
{
Log
->
Write
(
"ERROR:
\t
Cognitive map file without region definition!"
);
Log
->
Write
(
"Cognitive map not specified"
);
return
;
}
for
(
TiXmlElement
*
xRegion
=
xRegionsNode
->
FirstChildElement
(
"region"
);
xRegion
;
xRegion
=
xRegion
->
NextSiblingElement
(
"region"
))
{
std
::
string
idR
=
xmltoa
(
xRegion
->
Attribute
(
"id"
),
"-1"
);
std
::
string
captionR
=
xmltoa
(
xRegion
->
Attribute
(
"caption"
));
std
::
string
pxinmapR
=
xmltoa
(
xRegion
->
Attribute
(
"px"
),
"-1"
);
std
::
string
pyinmapR
=
xmltoa
(
xRegion
->
Attribute
(
"py"
),
"-1"
);
std
::
string
aR
=
xmltoa
(
xRegion
->
Attribute
(
"a"
),
"-1"
);
std
::
string
bR
=
xmltoa
(
xRegion
->
Attribute
(
"b"
),
"-1"
);
AIRegion
region
(
Point
(
std
::
stod
(
pxinmapR
),
std
::
stod
(
pyinmapR
)));
region
.
SetId
(
std
::
stoi
(
idR
));
region
.
SetCaption
(
captionR
);
region
.
SetPosInMap
(
Point
(
std
::
stod
(
pxinmapR
),
std
::
stod
(
pyinmapR
)));
region
.
SetA
(
std
::
stod
(
aR
));
region
.
SetB
(
std
::
stod
(
bR
));
//processing the landmarks node
TiXmlNode
*
xLandmarksNode
=
xRegion
->
FirstChild
(
"landmarks"
);
if
(
!
xLandmarksNode
)
{
Log
->
Write
(
"ERROR:
\t
Cognitive map file without landmark definition!"
);
Log
->
Write
(
"No landmarks specified"
);
return
;
}
for
(
TiXmlElement
*
xLandmark
=
xLandmarksNode
->
FirstChildElement
(
"landmark"
);
xLandmark
;
xLandmark
=
xLandmark
->
NextSiblingElement
(
"landmark"
))
{
std
::
string
id
=
xmltoa
(
xLandmark
->
Attribute
(
"id"
),
"-1"
);
std
::
string
caption
=
xmltoa
(
xLandmark
->
Attribute
(
"caption"
));
std
::
string
type
=
xmltoa
(
xLandmark
->
Attribute
(
"type"
),
"-1"
);
std
::
string
roomId
=
xmltoa
(
xLandmark
->
Attribute
(
"subroom1_id"
),
"-1"
);
std
::
string
pxreal
=
xmltoa
(
xLandmark
->
Attribute
(
"pxreal"
),
"-1"
);
std
::
string
pyreal
=
xmltoa
(
xLandmark
->
Attribute
(
"pyreal"
),
"-1"
);
std
::
string
pxinmap
=
xmltoa
(
xLandmark
->
Attribute
(
"px"
),
"-1"
);
std
::
string
pyinmap
=
xmltoa
(
xLandmark
->
Attribute
(
"py"
),
"-1"
);
std
::
string
a
=
xmltoa
(
xLandmark
->
Attribute
(
"a"
),
"-1"
);
std
::
string
b
=
xmltoa
(
xLandmark
->
Attribute
(
"b"
),
"-1"
);
AILandmark
landmark
(
Point
(
std
::
stod
(
pxreal
),
std
::
stod
(
pyreal
)));
if
(
roomId
==
"NaN"
)
{
Log
->
Write
(
"ERROR:
\t
Subroom Id is NaN!"
);
return
;
}
landmark
.
SetId
(
std
::
stoi
(
id
));
landmark
.
SetCaption
(
caption
);
landmark
.
SetType
(
type
);
landmark
.
SetRealPos
(
Point
(
std
::
stod
(
pxreal
),
std
::
stod
(
pyreal
)));
landmark
.
SetPosInMap
(
Point
(
std
::
stod
(
pxinmap
),
std
::
stod
(
pyinmap
)));
landmark
.
SetA
(
std
::
stod
(
a
));
landmark
.
SetB
(
std
::
stod
(
b
));
//landmark->SetRoom(_building->GetSubRoomByUID(std::stoi(roomId)));
//processing the rooms node
TiXmlNode
*
xAssociationsNode
=
xLandmark
->
FirstChild
(
"associations"
);
if
(
!
xAssociationsNode
)
{
Log
->
Write
(
"Landmark with no association!"
);
continue
;
}
for
(
TiXmlElement
*
xAsso
=
xAssociationsNode
->
FirstChildElement
(
"association"
);
xAsso
;
xAsso
=
xAsso
->
NextSiblingElement
(
"association"
))
{
std
::
string
asso_id
=
xmltoa
(
xAsso
->
Attribute
(
"id"
),
"-1"
);
std
::
string
asso_caption
=
xmltoa
(
xAsso
->
Attribute
(
"caption"
),
"0"
);
//std::string asso_type = xmltoa(xAsso->Attribute("type"),"-1");
std
::
string
asso_x
=
xmltoa
(
xAsso
->
Attribute
(
"px"
),
"-1"
);
std
::
string
asso_y
=
xmltoa
(
xAsso
->
Attribute
(
"py"
),
"-1"
);
std
::
string
asso_a
=
xmltoa
(
xAsso
->
Attribute
(
"a"
),
"-1"
);
std
::
string
asso_b
=
xmltoa
(
xAsso
->
Attribute
(
"b"
),
"-1"
);
int
connection
=
std
::
stoi
(
xmltoa
(
xAsso
->
Attribute
(
"connectedwith"
),
"-1"
));
//std::string priority = xmltoa(xAsso->Attribute("priority"),"-1");
AILandmark
assolandmark
(
Point
(
std
::
stod
(
asso_x
),
std
::
stod
(
asso_y
)),
std
::
stod
(
asso_a
),
std
::
stod
(
asso_b
));
assolandmark
.
SetId
(
std
::
stod
(
asso_id
));
//std::cout << assolandmark.GetId() << std::endl;
assolandmark
.
SetCaption
(
asso_caption
);
//assolandmark->AddConnection(std::stoi(connection));
//assolandmark->SetPriority(std::stod(priority));
bool
connected
=
false
;
if
(
connection
==
landmark
.
GetId
())
connected
=
true
;
landmark
.
AddAssociation
(
AIAssociation
(
&
landmark
,
&
assolandmark
,
connected
));
region
.
AddLandmarkSubCs
(
assolandmark
);
}
region
.
AddLandmark
(
landmark
);
Log
->
Write
(
"INFO:
\t
Landmark added!"
);
}
//processing the connections node
TiXmlNode
*
xConnectionsNode
=
xRegion
->
FirstChild
(
"connections"
);