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
bb7ff837
Commit
bb7ff837
authored
Aug 21, 2015
by
Andrijana Brkic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-added function VoronoiAdjustSpeedNeighbour
parent
99be7b68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
32 deletions
+44
-32
pedestrian/AgentsSourcesManager.cpp
pedestrian/AgentsSourcesManager.cpp
+38
-28
pedestrian/AgentsSourcesManager.h
pedestrian/AgentsSourcesManager.h
+6
-4
No files found.
pedestrian/AgentsSourcesManager.cpp
View file @
bb7ff837
...
...
@@ -305,7 +305,7 @@ void AgentsSourcesManager::ComputeBestPositionVoronoiBoost2(AgentsSource* src,
double
speed
=
ped
->
GetV0Norm
();
v
=
v
*
speed
;
ped
->
SetV
(
v
);
}
}
//0
else
if
(
existing_peds
.
size
()
==
1
)
{
...
...
@@ -327,7 +327,7 @@ void AgentsSourcesManager::ComputeBestPositionVoronoiBoost2(AgentsSource* src,
v
=
v
*
speed
;
ped
->
SetV
(
v
);
}
}
}
//1
else
if
(
existing_peds
.
size
()
==
2
)
{
...
...
@@ -382,7 +382,7 @@ void AgentsSourcesManager::ComputeBestPositionVoronoiBoost2(AgentsSource* src,
t2
.
SetX
(
(
x1
+
x2
)
/
2.0
+
alpha
*
(
y2
-
y1
)
);
t2
.
SetY
(
(
y1
+
y2
)
/
2.0
+
alpha
*
(
x1
-
x2
)
);
}
}
}
//2
else
{
...
...
@@ -409,36 +409,47 @@ void AgentsSourcesManager::ComputeBestPositionVoronoiBoost2(AgentsSource* src,
voronoi_diagram
<
double
>::
const_vertex_iterator
chosen_it
=
vd
.
vertices
().
begin
();
double
dis
=
0
;
VoronoiBestVertexRand
(
discrete_positions
,
vd
,
subroom
,
factor
,
chosen_it
,
dis
);
//max_dis is the squared distance!
VoronoiBestVertexRand
(
discrete_positions
,
vd
,
subroom
,
factor
,
chosen_it
,
dis
);
//dis is the squared distance!
//VoronoiBestVertexRandMax(discrete_positions, vd, subroom, factor, chosen_it, dis );
//VoronoiBestVertexMax(discrete_positions, vd, subroom, factor, chosen_it, dis );
//giving the position and velocity
Point
pos
(
chosen_it
->
x
()
/
factor
,
chosen_it
->
y
()
/
factor
);
//check!
if
(
dis
>
radius
*
factor
*
radius
*
factor
)
// be careful with the factor!! radius*factor
{
ped
->
SetPos
(
pos
,
true
);
//finding the neighbors (nearest pedestrians) of the chosen vertex
const
voronoi_diagram
<
double
>::
vertex_type
&
vertex
=
*
chosen_it
;
const
voronoi_diagram
<
double
>::
edge_type
*
edge
=
vertex
.
incident_edge
();
double
sum_x
=
0
,
sum_y
=
0
;
int
no
=
0
;
std
::
size_t
index
;
do
{
no
++
;
index
=
(
edge
->
cell
()
)
->
source_index
();
const
Point
&
v
=
velocities_vector
[
index
];
sum_x
+=
v
.
GetX
();
sum_y
+=
v
.
GetY
();
edge
=
edge
->
rot_next
();
}
while
(
edge
!=
vertex
.
incident_edge
());
Point
v
(
sum_x
/
no
,
sum_y
/
no
);
ped
->
SetV
(
v
);
VoronoiAdjustSpeedNeighbour
(
vd
,
chosen_it
,
ped
,
velocities_vector
);
}
}
}
//3
existing_peds
.
push_back
(
ped
);
}
}
//for loop
}
//gives an agent the mean velocity of his voronoi-neighbors
void
AgentsSourcesManager
::
VoronoiAdjustSpeedNeighbour
(
const
voronoi_diagram
<
double
>&
vd
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
chosen_it
,
Pedestrian
*
ped
,
const
std
::
vector
<
Point
>&
velocities_vector
)
const
{
//finding the neighbors (nearest pedestrians) of the chosen vertex
const
voronoi_diagram
<
double
>::
vertex_type
&
vertex
=
*
chosen_it
;
const
voronoi_diagram
<
double
>::
edge_type
*
edge
=
vertex
.
incident_edge
();
double
sum_x
=
0
,
sum_y
=
0
;
int
no
=
0
;
std
::
size_t
index
;
do
{
no
++
;
index
=
(
edge
->
cell
()
)
->
source_index
();
const
Point
&
v
=
velocities_vector
[
index
];
sum_x
+=
v
.
GetX
();
sum_y
+=
v
.
GetY
();
edge
=
edge
->
rot_next
();
}
while
(
edge
!=
vertex
.
incident_edge
());
Point
v
(
sum_x
/
no
,
sum_y
/
no
);
ped
->
SetV
(
v
);
}
//gives the voronoi vertex with max distance
...
...
@@ -467,7 +478,6 @@ void AgentsSourcesManager::VoronoiBestVertexMax (const std::vector<Point>& discr
}
}
//gives random voronoi vertex but with weights proportional to squared distances
void
AgentsSourcesManager
::
VoronoiBestVertexRandMax
(
const
std
::
vector
<
Point
>&
discrete_positions
,
const
voronoi_diagram
<
double
>&
vd
,
SubRoom
*
subroom
,
int
factor
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
chosen_it
,
double
&
dis
)
const
...
...
@@ -522,7 +532,7 @@ void AgentsSourcesManager::VoronoiBestVertexRandMax (const std::vector<Point>& d
}
//gives a random voronoi vertex
void
AgentsSourcesManager
::
VoronoiBestVertexRand
(
const
std
::
vector
<
Point
>&
discrete_positions
,
const
voronoi_diagram
<
double
>&
vd
,
SubRoom
*
subroom
,
int
factor
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
chosen_it
,
double
&
dis
)
const
{
...
...
pedestrian/AgentsSourcesManager.h
View file @
bb7ff837
...
...
@@ -155,17 +155,19 @@ private:
voronoi_diagram
<
double
>::
const_vertex_iterator
&
max_it
,
double
&
max_dis
)
const
;
/**Position incoming pedestrian on the vertex with greater probability for greater distances
*
*/
*
*/
void
VoronoiBestVertexRandMax
(
const
std
::
vector
<
Point
>&
discrete_positions
,
const
voronoi_diagram
<
double
>&
vd
,
SubRoom
*
subroom
,
int
factor
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
max_it
,
double
&
max_dis
)
const
;
/**Position incoming pedestrian on a random vertex
*
*/
*
*/
void
VoronoiBestVertexRand
(
const
std
::
vector
<
Point
>&
discrete_positions
,
const
voronoi_diagram
<
double
>&
vd
,
SubRoom
*
subroom
,
int
factor
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
max_it
,
double
&
max_dis
)
const
;
void
VoronoiAdjustSpeedNeighbour
(
const
voronoi_diagram
<
double
>&
vd
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
chosen_it
,
Pedestrian
*
ped
,
const
std
::
vector
<
Point
>&
velocities_vector
)
const
;
/**
* Position incoming pedestrians randomly
...
...
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