Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
af25b04e
Commit
af25b04e
authored
Jul 27, 2018
by
Stefan Schuhbaeck
Browse files
increase min distance in overlap case becase an EPSILON of 0.01 is to low
parent
52b18a14
Pipeline
#64121
failed with stages
in 6 minutes and 29 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/tests/org/vadere/simulator/control/GroupSourceControllerTest.java
View file @
af25b04e
...
...
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import
java.util.Arrays
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
fail
;
public
class
GroupSourceControllerTest
extends
TestSourceControllerUsingConstantSpawnRate
{
...
...
@@ -230,7 +231,7 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
pedestrianCountEquals
(
3
);
}
@Test
@Test
(
expected
=
RuntimeException
.
class
)
public
void
testSpawnNumber
()
{
SourceTestAttributesBuilder
builder
=
new
SourceTestAttributesBuilder
()
.
setSpawnNumber
(
10
)
...
...
@@ -240,8 +241,11 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
first
().
sourceController
.
update
(
1
);
pedestrianCountEquals
(
10
*
4
);
first
().
sourceController
.
update
(
2
);
pedestrianCountEquals
(
20
*
4
);
first
().
sourceController
.
update
(
2
);
// use random positioning thus not
// not optimal and thus not enough
// space for all
fail
(
"should not be reached. Exception expected"
);
}
@Test
...
...
VadereState/src/org/vadere/state/util/SpawnArray.java
View file @
af25b04e
...
...
@@ -80,7 +80,7 @@ import java.util.stream.IntStream;
public
class
SpawnArray
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
SpawnArray
.
class
);
p
rivate
static
final
double
EPSILON
=
0.
01
;
p
ublic
static
final
double
OVERLAPP_
EPSILON
=
0.
4
;
private
final
VPoint
[]
spawnPoints
;
private
final
VRectangle
spawnElementBound
;
// number of spawn elements in x and y Dimension.
...
...
@@ -159,7 +159,7 @@ public class SpawnArray {
public
LinkedList
<
VPoint
>
getNextSpawnPoints
(
int
maxPoints
,
final
List
<
DynamicElement
>
neighbours
)
{
return
spawnPoints
(
maxPoints
,
neighbours
,
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
EPSILON
)
,
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
OVERLAPP_
EPSILON
)
,
len
->
startWith
(
nextIndex
,
len
));
// define spawn order (use next index)
}
...
...
@@ -170,7 +170,7 @@ public class SpawnArray {
public
LinkedList
<
VPoint
>
getNextRandomSpawnPoints
(
int
maxPoints
,
Random
rnd
,
final
List
<
DynamicElement
>
neighbours
)
{
return
spawnPoints
(
maxPoints
,
neighbours
,
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
EPSILON
)
,
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
OVERLAPP_
EPSILON
)
,
len
->
shufflePoints
(
rnd
,
len
));
// define spawn order (use random index)
}
...
...
@@ -262,7 +262,7 @@ public class SpawnArray {
GroupPlacementHelper
pHelper
=
getHelper
(
groupSize
);
return
nextFreeGroupPos
(
pHelper
,
neighbours
,
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
EPSILON
),
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
OVERLAPP_
EPSILON
),
len
->
startWith
(
nextGroupPos
.
getOrDefault
(
pHelper
.
getGroupSize
(),
0
),
len
));
}
...
...
@@ -270,7 +270,7 @@ public class SpawnArray {
GroupPlacementHelper
pHelper
=
getHelper
(
groupSize
);
return
nextFreeGroupPos
(
pHelper
,
neighbours
,
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
EPSILON
),
(
n
,
p
)
->
n
.
getShape
().
getCentroid
().
equals
(
p
,
OVERLAPP_
EPSILON
),
len
->
shufflePoints
(
rnd
,
len
));
}
...
...
VadereState/tests/org/vadere/state/util/SpawnArrayTest.java
View file @
af25b04e
...
...
@@ -126,10 +126,10 @@ public class SpawnArrayTest {
VPoint
[]
spawnPoints
=
spawnArray
.
getSpawnPoints
();
List
<
DynamicElement
>
dynamicElements2
=
createMock
(
0.5
,
spawnPoints
[
12
],
// direct match (use next)
spawnPoints
[
13
].
add
(
new
VPoint
(
0
,
0.0003
)),
// match within Epsilon (use next)
spawnPoints
[
14
].
add
(
new
VPoint
(
0.
3
,
0
))
// match outside Epsilon (use this one)
spawnPoints
[
13
].
add
(
new
VPoint
(
0
,
SpawnArray
.
OVERLAPP_EPSILON
-
0.1
)),
// match within Epsilon (use next)
spawnPoints
[
14
].
add
(
new
VPoint
(
SpawnArray
.
OVERLAPP_EPSILON
+
0.
1
,
0
))
// match outside Epsilon (use this one)
);
assertEquals
(
"Point does not match"
,
spawnArray
.
getNextSpawnPoints
(
1
,
dynamicElements2
).
getFirst
()
,
spawnPoints
[
14
]
);
assertEquals
(
"Point does not match"
,
spawnPoints
[
14
],
spawnArray
.
getNextSpawnPoints
(
1
,
dynamicElements2
).
getFirst
());
assertEquals
(
"Next Element does not match"
,
15
,
spawnArray
.
getNextSpawnPointIndex
());
}
...
...
@@ -326,8 +326,8 @@ public class SpawnArrayTest {
// do not directly overlap with each other.
List
<
DynamicElement
>
dynamicElements2
=
createMock
(
0.5
,
spawnPoints
[
1
],
// direct match (use next)
spawnPoints
[
2
].
add
(
new
VPoint
(
0.0003
,
0
)),
// match within Epsilon (use next)
spawnPoints
[
3
].
add
(
new
VPoint
(
0.
3
,
0.
3
))
// match outside Epsilon (use this one)
spawnPoints
[
2
].
add
(
new
VPoint
(
SpawnArray
.
OVERLAPP_EPSILON
-
0.1
,
0
)),
// match within Epsilon (use next)
spawnPoints
[
3
].
add
(
new
VPoint
(
SpawnArray
.
OVERLAPP_EPSILON
+
0.
1
,
SpawnArray
.
OVERLAPP_EPSILON
+
0.
1
))
// match outside Epsilon (use this one)
);
group
=
spawnArray
.
getNextGroup
(
6
,
dynamicElements2
);
assertEquals
(
spawnPoints
[
3
],
group
.
pollFirst
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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