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
7eaa59c7
Commit
7eaa59c7
authored
Sep 08, 2015
by
Ulrich Kemloh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Agents that could not be placed using vorovoi are now requeued
parent
f9940660
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
357 additions
and
326 deletions
+357
-326
pedestrian/AgentsSource.cpp
pedestrian/AgentsSource.cpp
+5
-0
pedestrian/AgentsSource.h
pedestrian/AgentsSource.h
+7
-0
pedestrian/AgentsSourcesManager.cpp
pedestrian/AgentsSourcesManager.cpp
+39
-39
voronoi-boost/VoronoiPositionGenerator.cpp
voronoi-boost/VoronoiPositionGenerator.cpp
+306
-287
No files found.
pedestrian/AgentsSource.cpp
View file @
7eaa59c7
...
...
@@ -71,6 +71,11 @@ void AgentsSource::RemoveAgentsFromPool(std::vector<Pedestrian*>& ped, int count
}
}
void
AgentsSource
::
AddAgentsToPool
(
std
::
vector
<
Pedestrian
*>&
peds
)
{
_agents
.
insert
(
_agents
.
begin
(),
peds
.
begin
(),
peds
.
end
());
}
int
AgentsSource
::
GetPoolSize
()
const
{
return
_agents
.
size
();
...
...
pedestrian/AgentsSource.h
View file @
7eaa59c7
...
...
@@ -85,6 +85,13 @@ public:
*/
void
RemoveAgentsFromPool
(
std
::
vector
<
Pedestrian
*>&
peds
,
int
count
);
/**
* Add the agents to the pool. This might be important in the case the removed agents could not
* be placed correctly. They can be requeued using this function.
* @param peds
*/
void
AddAgentsToPool
(
std
::
vector
<
Pedestrian
*>&
peds
);
/**
* @return the number of agents remaining
*/
...
...
pedestrian/AgentsSourcesManager.cpp
View file @
7eaa59c7
...
...
@@ -91,7 +91,7 @@ void AgentsSourcesManager::Run()
_lastUpdateTime
=
current_time
;
}
//wait some time
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
while
(
!
finished
);
Log
->
Write
(
"INFO:
\t
Terminating agent manager thread"
);
_isCompleted
=
true
;
...
...
@@ -104,14 +104,14 @@ bool AgentsSourcesManager::ProcessAllSources() const
{
if
(
src
->
GetPoolSize
())
{
vector
<
Pedestrian
*>
peds
;
vector
<
Pedestrian
*>
peds
;
src
->
RemoveAgentsFromPool
(
peds
,
src
->
GetFrequency
());
Log
->
Write
(
"INFO:
\t
Source %d generating %d agents (%d remaining)"
,
src
->
GetId
(),
peds
.
size
(),
src
->
GetPoolSize
());
//ComputeBestPositionRandom(src.get(), peds);
//todo: compute the optimal position for insertion using voronoi
if
(
!
ComputeBestPositionVoronoiBoost
(
src
.
get
(),
peds
,
_building
)
)
Log
->
Write
(
"INFO:
\t
there was no place for some pedestrians"
);
Log
->
Write
(
"INFO:
\t
there was no place for some pedestrians"
);
//ComputeBestPositionTotalRandom(src.get(), peds );
//ComputeBestPositionDummy( src.get(), peds );
/*for (auto&& ped : peds)
...
...
@@ -131,49 +131,49 @@ bool AgentsSourcesManager::ProcessAllSources() const
void
AgentsSourcesManager
::
ComputeBestPositionDummy
(
AgentsSource
*
src
,
vector
<
Pedestrian
*>&
peds
)
const
{
peds
[
0
]
->
SetPos
(
Point
(
10
,
5.5
)
);
peds
[
1
]
->
SetPos
(
Point
(
10
,
4.9
)
);
peds
[
2
]
->
SetPos
(
Point
(
10
,
4.3
)
);
peds
[
3
]
->
SetPos
(
Point
(
10
,
3.7
)
);
peds
[
0
]
->
SetPos
(
Point
(
10
,
5.5
)
);
peds
[
1
]
->
SetPos
(
Point
(
10
,
4.9
)
);
peds
[
2
]
->
SetPos
(
Point
(
10
,
4.3
)
);
peds
[
3
]
->
SetPos
(
Point
(
10
,
3.7
)
);
/*peds[0]->SetPos( Point(10,5.4) );
/*peds[0]->SetPos( Point(10,5.4) );
peds[1]->SetPos( Point(10,4.6) );
peds[2]->SetPos( Point(10,3.8) );*/
for
(
auto
&&
ped
:
peds
)
{
Point
v
=
(
ped
->
GetExitLine
()
->
ShortestPoint
(
ped
->
GetPos
())
-
ped
->
GetPos
()).
Normalized
();
double
speed
=
ped
->
GetV0Norm
();
v
=
v
*
speed
;
ped
->
SetV
(
v
);
}
for
(
auto
&&
ped
:
peds
)
{
Point
v
=
(
ped
->
GetExitLine
()
->
ShortestPoint
(
ped
->
GetPos
())
-
ped
->
GetPos
()).
Normalized
();
double
speed
=
ped
->
GetV0Norm
();
v
=
v
*
speed
;
ped
->
SetV
(
v
);
}
}
void
AgentsSourcesManager
::
ComputeBestPositionCompleteRandom
(
AgentsSource
*
src
,
vector
<
Pedestrian
*>&
peds
)
const
vector
<
Pedestrian
*>&
peds
)
const
{
auto
dist
=
src
->
GetStartDistribution
();
auto
subroom
=
_building
->
GetRoom
(
dist
->
GetRoomId
())
->
GetSubRoom
(
dist
->
GetSubroomID
());
vector
<
Point
>
positions
=
PedDistributor
::
PossiblePositions
(
*
subroom
);
srand
(
time
(
NULL
));
for
(
auto
&
ped
:
peds
)
{
if
(
positions
.
size
()
)
{
int
index
=
rand
()
%
positions
.
size
();
Point
new_pos
=
positions
[
index
];
positions
.
erase
(
positions
.
begin
()
+
index
);
ped
->
SetPos
(
new_pos
,
true
);
AdjustVelocityByNeighbour
(
ped
);
}
else
{
Log
->
Write
(
"
\t
No place for a pedestrian"
);
break
;
}
}
auto
dist
=
src
->
GetStartDistribution
();
auto
subroom
=
_building
->
GetRoom
(
dist
->
GetRoomId
())
->
GetSubRoom
(
dist
->
GetSubroomID
());
vector
<
Point
>
positions
=
PedDistributor
::
PossiblePositions
(
*
subroom
);
srand
(
time
(
NULL
));
for
(
auto
&
ped
:
peds
)
{
if
(
positions
.
size
()
)
{
int
index
=
rand
()
%
positions
.
size
();
Point
new_pos
=
positions
[
index
];
positions
.
erase
(
positions
.
begin
()
+
index
);
ped
->
SetPos
(
new_pos
,
true
);
AdjustVelocityByNeighbour
(
ped
);
}
else
{
Log
->
Write
(
"
\t
No place for a pedestrian"
);
break
;
}
}
}
...
...
@@ -294,7 +294,7 @@ void AgentsSourcesManager::ComputeBestPositionVoronoi(AgentsSource* src,
//compute the best position
//exit(0);
}
*/
*/
...
...
voronoi-boost/VoronoiPositionGenerator.cpp
View file @
7eaa59c7
This diff is collapsed.
Click to expand it.
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