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
d4e52325
Commit
d4e52325
authored
May 29, 2017
by
Arne Graf
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ctor wip
parent
de41f9a8
Pipeline
#2383
failed with stages
in 31 seconds
Changes
11
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1030 additions
and
331 deletions
+1030
-331
CMakeLists.txt
CMakeLists.txt
+2
-0
Simulation.cpp
Simulation.cpp
+5
-9
general/Macros.h
general/Macros.h
+39
-7
pedestrian/Pedestrian.cpp
pedestrian/Pedestrian.cpp
+4
-10
pedestrian/Pedestrian.h
pedestrian/Pedestrian.h
+1
-1
routing/DirectionStrategy.cpp
routing/DirectionStrategy.cpp
+0
-41
routing/DirectionStrategy.h
routing/DirectionStrategy.h
+0
-11
routing/ff_router/UnivFFviaFM.cpp
routing/ff_router/UnivFFviaFM.cpp
+624
-0
routing/ff_router/UnivFFviaFM.h
routing/ff_router/UnivFFviaFM.h
+136
-0
routing/ff_router/ffRouter.cpp
routing/ff_router/ffRouter.cpp
+217
-244
routing/ff_router/ffRouter.h
routing/ff_router/ffRouter.h
+2
-8
No files found.
CMakeLists.txt
View file @
d4e52325
...
...
@@ -290,6 +290,7 @@ set(source_files
routing/ff_router/LocalFloorfieldViaFM.cpp
routing/ff_router/FloorfieldViaFM.cpp
#routing/ff_router/FFKit.cpp
routing/ff_router/UnivFFviaFM.cpp
#global_shortest
routing/global_shortest/AccessPoint.cpp
...
...
@@ -355,6 +356,7 @@ set(header_files
routing/ff_router/LocalFloorfieldViaFM.h
routing/ff_router/FloorfieldViaFM.h
#routing/ff_router/FFKit.h
routing/ff_router/UnivFFviaFM.h
#general
routing/DirectionStrategy.h
...
...
Simulation.cpp
View file @
d4e52325
...
...
@@ -249,10 +249,6 @@ bool Simulation::InitArgs()
// This should be done after the initialization of the operationalModel
// because then, invalid pedestrians have been deleted and FindExit()
// has been called.
Log
->
Write
(
"INFO:
\t
PreSim of DirectionStrategy starting ..."
);
if
(
!
_operationalModel
->
GetDirection
()
->
PreSim
(
_building
.
get
()))
return
false
;
Log
->
Write
(
"INFO:
\t
PreSim of DirectionStrategy done"
);
//other initializations
for
(
auto
&&
ped
:
_building
->
GetAllPedestrians
())
{
...
...
@@ -509,11 +505,11 @@ double Simulation::RunBody(double maxSimTime)
if
(
0
==
frameNr
%
writeInterval
)
{
_iod
->
WriteFrame
(
frameNr
/
writeInterval
,
_building
.
get
());
}
if
(
!
_gotSources
&&
!
_periodic
/*&& _printPB*/
)
// @todo: option for print progressbar
// Log->ProgressBar(initialnPeds, initialnPeds-_nPeds, t);
//
bar->Progressed(initialnPeds-_nPeds);
else
printf
(
"time: %.2f | %.2f
\n
"
,
t
,
maxSimTime
);
//
if(!_gotSources && !_periodic /*&& _printPB*/) // @todo: option for print progressbar
//
// Log->ProgressBar(initialnPeds, initialnPeds-_nPeds, t);
//
bar->Progressed(initialnPeds-_nPeds);
//
else
//
printf("time: %.2f | %.2f\n", t , maxSimTime);
// needed to control the execution time PART 2
// time(&endtime);
...
...
general/Macros.h
View file @
d4e52325
...
...
@@ -162,13 +162,14 @@ enum FFRouterMode {
};
enum
GridCode
{
//used in floor fields
WALL
=
0
,
INSIDE
,
OUTSIDE
,
OPEN_CROSSING
,
OPEN_TRANSITION
,
CLOSED_CROSSING
,
//closed crossings and transitions are marked as walls in "parseBuilding"
CLOSED_TRANSITION
WALL
=
-
10
,
INSIDE
=
-
11
,
OUTSIDE
=
-
12
,
//instead of constants, GridCode stores UID of doors
OPEN_CROSSING
=
-
13
,
OPEN_TRANSITION
=
-
14
,
CLOSED_CROSSING
=
-
15
,
//closed crossings and transitions are marked as walls in "parseBuilding"
CLOSED_TRANSITION
=
-
16
};
enum
FastMarchingFlags
{
...
...
@@ -181,6 +182,37 @@ enum FastMarchingFlags {
FM_OUTSIDE
=
-
7
};
enum
FloorfieldMode
{
FF_CENTRALPOINT
,
FF_FULL_LINE
,
FF_WALL_AVOID
,
FF_HOMO_SPEED
};
enum
MagicNumbers
{
UNKNOWN_DISTANCE
,
UNKNOWN_COST
,
WALL_ON_COSTARRAY
,
TARGET_REGION
};
constexpr
double
magicnum
(
int
i
)
{
return
(
i
==
UNKNOWN_DISTANCE
)
?
-
3.0
:
(
i
==
UNKNOWN_COST
)
?
-
2.0
:
(
i
==
WALL_ON_COSTARRAY
)
?
-
7.0
:
(
i
==
TARGET_REGION
)
?
0.0
:
NAN
;
Mohcine Chraibi
@chraibi1
·
Jul 26, 2017
Owner
@Arne2 Do you mean
J_NAN
? Because
NAN
is not defined
@Arne2 Do you mean `J_NAN`? Because `NAN` is not defined
Arne Graf
@graf2
·
Jul 29, 2017
Maintainer
J_NAN works for me, I will change it.
J_NAN works for me, I will change it.
Please
register
or
sign in
to reply
// switch (i) {
// case UNKNOWN_DISTANCE:
// return -3.0;
// case UNKNOWN_COST:
// return -2.0;
// case WALL_ON_COSTARRAY:
// return -7.0;
// case TARGET_REGION:
// return 0.0;
// default:
// std::cerr << "ERROR: \tunknown magic number " << i << std::endl;
// return NAN;
// }
}
//global functions for convenience
inline
char
xmltob
(
const
char
*
t
,
char
v
=
0
)
...
...
pedestrian/Pedestrian.cpp
View file @
d4e52325
...
...
@@ -147,7 +147,6 @@ Pedestrian::Pedestrian(const StartDistribution& agentsParameters, Building& buil
_tmpFirstOrientation
=
true
;
_turninAngle
=
0.0
;
_ellipse
=
JEllipse
();
//_navLine = new NavLine(); //FIXME? argraf : rather nullptr and Setter includes correct uid (done below)
_navLine
=
nullptr
;
_router
=
NULL
;
_building
=
NULL
;
...
...
@@ -254,16 +253,11 @@ void Pedestrian::SetExitIndex(int i)
void
Pedestrian
::
SetExitLine
(
const
NavLine
*
l
)
//FIXME? argraf : _navLine = new NavLine(*l); this would have a navLine with consistent uid (done below)
{
//_navLine = l;
//_navLine->SetPoint1(l->GetPoint1());
//_navLine->SetPoint2(l->GetPoint2());
if
(
l
)
{
_navLine
=
std
::
unique_ptr
<
NavLine
>
(
new
NavLine
(
*
l
));
}
/*else if(l && _navLine && *l != *_navLine && l->GetUniqueID() != _navLine->GetUniqueID()){
if
(
_navLine
)
delete
_navLine
;
if
(
l
)
{
_navLine
=
new
NavLine
(
*
l
);
}
*/
}
}
void
Pedestrian
::
SetPos
(
const
Point
&
pos
,
bool
initial
)
...
...
@@ -392,7 +386,7 @@ int Pedestrian::GetExitIndex() const
NavLine
*
Pedestrian
::
GetExitLine
()
const
{
return
_navLine
.
get
()
;
return
_navLine
;
}
const
vector
<
int
>&
Pedestrian
::
GetTrip
()
const
...
...
pedestrian/Pedestrian.h
View file @
d4e52325
...
...
@@ -91,7 +91,7 @@ private:
int
_oldSubRoomID
;
Point
_lastE0
;
std
::
unique_ptr
<
NavLine
>
_navLine
;
// current exit line
NavLine
*
_navLine
;
// current exit line
std
::
map
<
int
,
int
>
_mentalMap
;
// map the actual room to a destination
std
::
vector
<
int
>
_destHistory
;
std
::
vector
<
int
>
_trip
;
...
...
routing/DirectionStrategy.cpp
View file @
d4e52325
...
...
@@ -410,48 +410,7 @@ void DirectionLocalFloorfield::Init(Building* buildingArg, double stepsize,
_initDone
=
true
;
}
bool
DirectionLocalFloorfield
::
PreSim
(
Building
*
building
)
{
std
::
map
<
int
,
std
::
vector
<
int
>>
doorsInRoom
;
doorsInRoom
.
clear
();
Log
->
Write
(
"INFO:
\t
DirectionLocalFloorfield::PreSim"
);
std
::
set
<
std
::
pair
<
int
,
int
>>
roomsDoorsSet
;
roomsDoorsSet
.
clear
();
auto
allPeds
=
building
->
GetAllPedestrians
();
#pragma omp parallel
{
#pragma omp for
for
(
size_t
i
=
0
;
i
<
allPeds
.
size
();
++
i
)
{
auto
ped
=
allPeds
.
begin
();
std
::
advance
(
ped
,
i
);
if
(
auto
router
=
dynamic_cast
<
FFRouter
*>
((
*
ped
)
->
GetRouter
()))
{
auto
pedSubroomsDoorSet
=
router
->
GetPresumableExitRoute
(
*
ped
);
#pragma omp critical(roomsDoorsSet)
for
(
auto
it
:
pedSubroomsDoorSet
)
{
roomsDoorsSet
.
insert
(
std
::
make_pair
(
it
.
first
->
GetRoomID
(),
it
.
second
));
}
}
}
#pragma omp for
for
(
size_t
i
=
0
;
i
<
roomsDoorsSet
.
size
();
++
i
)
{
auto
rdIt
=
roomsDoorsSet
.
begin
();
// suboptimal, because a set doesn't provide random-access iterators
std
::
advance
(
rdIt
,
i
);
CalcFloorfield
(
rdIt
->
first
,
rdIt
->
second
);
#pragma omp critical(doorsInRoom)
doorsInRoom
[
rdIt
->
first
].
push_back
(
rdIt
->
second
);
}
}
for
(
size_t
i
=
0
;
i
<
doorsInRoom
.
size
();
++
i
)
{
auto
roomIt
=
doorsInRoom
.
begin
();
std
::
advance
(
roomIt
,
i
);
//@todo: ar.graf: plz make switch in ini file and dependand on ini write yes/no (issue 208)
//writeFF(roomIt->first, roomIt->second);
}
return
true
;
}
void
DirectionLocalFloorfield
::
CalcFloorfield
(
int
room
,
int
destUID
)
{
Point
dummy
;
...
...
routing/DirectionStrategy.h
View file @
d4e52325
...
...
@@ -46,41 +46,33 @@ public:
DirectionStrategy
();
virtual
~
DirectionStrategy
();
// Allow the DirectionStrategy to perform some pre-simulation calculation, with all pedestrians
// already set and a valid _exitIndex. Returns true if the initialization was successful.
virtual
bool
PreSim
(
Building
*
building
)
=
0
;
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
=
0
;
};
class
DirectionMiddlePoint
:
public
DirectionStrategy
{
public:
virtual
bool
PreSim
(
Building
*
building
)
{(
void
)
building
;
return
true
;};
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
};
class
DirectionMinSeperation
:
public
DirectionStrategy
{
public:
virtual
bool
PreSim
(
Building
*
building
)
{(
void
)
building
;
return
true
;};
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
};
class
DirectionMinSeperationShorterLine
:
public
DirectionStrategy
{
public:
virtual
bool
PreSim
(
Building
*
building
)
{(
void
)
building
;
return
true
;};
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
};
class
DirectionInRangeBottleneck
:
public
DirectionStrategy
{
public:
virtual
bool
PreSim
(
Building
*
building
)
{(
void
)
building
;
return
true
;};
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
};
class
DirectionGeneral
:
public
DirectionStrategy
{
public:
virtual
bool
PreSim
(
Building
*
building
)
{(
void
)
building
;
return
true
;};
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
};
...
...
@@ -88,7 +80,6 @@ class DirectionFloorfield : public DirectionStrategy {
public:
DirectionFloorfield
();
void
Init
(
Building
*
building
,
double
stepsize
,
double
threshold
,
bool
useDistancMap
);
virtual
bool
PreSim
(
Building
*
building
)
{(
void
)
building
;
return
true
;};
~
DirectionFloorfield
();
//void Init();
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
...
...
@@ -105,7 +96,6 @@ public:
DirectionLocalFloorfield
();
void
Init
(
Building
*
building
,
double
stepsize
,
double
threshold
,
bool
useDistancMap
);
virtual
bool
PreSim
(
Building
*
building
);
~
DirectionLocalFloorfield
();
//void Init();
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
...
...
@@ -132,7 +122,6 @@ public:
DirectionSubLocalFloorfield
();
void
Init
(
Building
*
building
,
double
stepsize
,
double
threshold
,
bool
useDistancMap
);
virtual
bool
PreSim
(
Building
*
building
)
{(
void
)
building
;
return
true
;};
~
DirectionSubLocalFloorfield
();
//void Init();
virtual
Point
GetTarget
(
Room
*
room
,
Pedestrian
*
ped
)
const
;
...
...
routing/ff_router/UnivFFviaFM.cpp
0 → 100644
View file @
d4e52325
This diff is collapsed.
Click to expand it.
routing/ff_router/UnivFFviaFM.h
0 → 100644
View file @
d4e52325
//
// Created by arne on 5/9/17.
//
/**
* \file UnivFFviaFM.h
* \date May 09, 2017
* \version N/A (v0.8.x)
* \copyright <2017-2020> 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
* Implementation of classes for a reworked floorfield. A floorfield in general
* yields a cost field to a specific goal and a correlated vectorfield for the
* optimal path in terms of the cost value.
*
* Rework focused on a cleaner structure and less inheritance (no diamond) and
* less workarounds.
*
*
**/
#ifndef JPSCORE_UNIVFFVIAFM_H
#define JPSCORE_UNIVFFVIAFM_H
#include <string>
#include <vector>
#include <map>
#include <float.h>
class
Room
;
class
SubRoom
;
class
Building
;
class
Configuration
;
class
Point
;
class
RectGrid
;
class
Line
;
enum
SPEEDFIELD
{
//this enum is used as index in _speedFieldSelector
INITIAL_SPEED
=
0
,
//homogen speed in walkable area, nealy zero in walls
REDU_WALL_SPEED
=
1
,
//reduced wall speed
PED_SPEED
=
2
//standing agents reduce speed, so that jams will be considered in ff
};
enum
TARGETMODE
{
LINESEGMENT
=
0
,
CENTERPOINT
};
enum
USERMODE
{
DISTANCE_MEASUREMENTS_ONLY
,
DISTANCE_AND_DIRECTIONS_USED
};
class
CompareCost
{
//this class is used in std::priority_queue in UnivFFviaFM::calcFF
public:
CompareCost
(
double
*
costarray
)
:
_costarray
(
costarray
)
{}
bool
operator
()
(
const
int
a
,
const
int
b
)
const
{
return
_costarray
[
a
]
>
_costarray
[
b
];
}
private:
double
*
_costarray
=
nullptr
;
};
class
UnivFFviaFM
{
public:
UnivFFviaFM
(
Room
*
a
,
Building
*
b
,
double
c
,
double
d
,
double
e
,
bool
f
);
UnivFFviaFM
(
SubRoom
*
a
,
Building
*
b
,
double
c
,
double
d
,
double
e
,
bool
f
);
UnivFFviaFM
(
Room
*
a
,
const
Configuration
*
b
,
double
c
,
double
d
,
double
e
,
bool
f
);
UnivFFviaFM
(
SubRoom
*
a
,
const
Configuration
*
b
,
double
c
,
double
d
,
double
e
,
bool
f
);
UnivFFviaFM
(
std
::
vector
<
Line
>&
walls
,
std
::
map
<
int
,
Line
>&
doors
,
std
::
vector
<
int
>
targetUIDs
,
int
mode
,
double
spacing
);
UnivFFviaFM
()
{};
UnivFFviaFM
(
UnivFFviaFM
&
){};
~
UnivFFviaFM
(){};
void
addTarget
(
const
int
uid
,
Line
*
door
);
std
::
vector
<
int
>
getKnownDoorUIDs
();
double
getCostToDestination
(
const
int
destID
,
const
Point
&
position
,
int
mode
)
{
return
0.
;};
double
getCostToDestination
(
const
int
destID
,
const
Point
&
position
)
{
return
0.
;};
RectGrid
*
getGrid
(){
return
nullptr
;};
virtual
void
getDirectionToUID
(
int
destID
,
const
long
int
key
,
Point
&
direction
,
int
mode
){};
void
getDirectionToUID
(
int
destID
,
const
long
int
key
,
Point
&
direction
){};
void
writeFF
(
const
std
::
string
&
,
std
::
vector
<
int
>
targetID
);
void
createRectGrid
(
std
::
vector
<
Line
>&
walls
,
std
::
map
<
int
,
Line
>&
doors
,
double
spacing
);
void
processGeometry
(
std
::
vector
<
Line
>&
walls
,
std
::
map
<
int
,
Line
>&
doors
);
void
drawLinesOnGrid
(
std
::
map
<
int
,
Line
>&
doors
,
int
*
const
grid
);
template
<
typename
T
>
void
drawLinesOnGrid
(
std
::
vector
<
Line
>&
wallArg
,
T
*
const
target
,
const
T
value
);
template
<
typename
T
>
void
drawLinesOnGrid
(
Line
&
line
,
T
*
const
target
,
const
T
value
);
void
calcFF
(
double
*
,
Point
*
,
const
double
*
const
);
void
calcCost
(
const
long
int
key
,
double
*
cost
,
Point
*
dir
,
const
double
*
const
speed
);
inline
double
onesidedCalc
(
double
xy
,
double
hDivF
);
inline
double
twosidedCalc
(
double
x
,
double
y
,
double
hDivF
);
private:
Building
*
_building
=
nullptr
;
Configuration
*
_configuration
=
nullptr
;
int
_mode
=
LINESEGMENT
;
//default
int
_user
=
DISTANCE_AND_DIRECTIONS_USED
;
//default
RectGrid
*
_grid
=
nullptr
;
long
int
_nPoints
=
0
;
std
::
vector
<
double
*>
_speedFieldSelector
;
int
*
_gridCode
=
nullptr
;
double
_wallAvoidDistance
=
0.
;
bool
_useWallAvoidance
=
false
;
//the following maps are responsible for dealloc the arrays
std
::
map
<
int
,
double
*>
_costFieldWithKey
;
std
::
map
<
int
,
Point
*>
_directionFieldWithKey
;
std
::
vector
<
int
>
_uids
;
std
::
map
<
int
,
Line
>
_doors
;
};
#endif //JPSCORE_UNIVFFVIAFM_H
routing/ff_router/ffRouter.cpp
View file @
d4e52325
This diff is collapsed.
Click to expand it.
routing/ff_router/ffRouter.h
View file @
d4e52325
...
...
@@ -64,6 +64,7 @@
#include "../../general/Macros.h"
#include "../../geometry/Building.h"
#include "LocalFloorfieldViaFM.h"
#include "UnivFFviaFM.h"
class
Building
;
class
Pedestrian
;
...
...
@@ -181,13 +182,6 @@ public:
*/
void
SetMode
(
std
::
string
s
);
/*!
* \brief Get the route the pedestrian p wants to take (according to _pathsMatrix)
* @param p The pedestrian in question
* @return A set containing (subroom*, doorUID) pairs. The floorfields needed are inside the subroom, originating from the door.
*/
std
::
set
<
std
::
pair
<
SubRoom
*
,
int
>>
GetPresumableExitRoute
(
Pedestrian
*
p
);
private:
protected:
...
...
@@ -198,7 +192,7 @@ protected:
std
::
vector
<
int
>
_allDoorUIDs
;
std
::
vector
<
int
>
_localShortestSafedPeds
;
const
Building
*
_building
;
std
::
map
<
int
,
LocalFloorfieldV
iaFM
*>
_locffviafm
;
// the actual type might be CentrePointLocalFFViaFM
std
::
map
<
int
,
UnivFFv
iaFM
*>
_locffviafm
;
// the actual type might be CentrePointLocalFFViaFM
FloorfieldViaFM
*
_globalFF
;
std
::
map
<
int
,
Transition
*>
_TransByUID
;
std
::
map
<
int
,
Transition
*>
_ExitsByUID
;
...
...
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