Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
vadere
vadere
Commits
c4004ac3
Commit
c4004ac3
authored
Sep 25, 2018
by
Marion Goedel
Browse files
Merge branch 'master' of
https://gitlab.lrz.de/vadere/vadere
parents
4bd49640
df8b7ca8
Pipeline
#70006
canceled with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/control/GroupSourceController.java
View file @
c4004ac3
...
...
@@ -52,7 +52,7 @@ public class GroupSourceController extends SourceController {
while
(
iter
.
hasNext
())
{
int
groupSize
=
iter
.
next
();
List
<
VPoint
>
newGroup
=
spawnArray
.
getNextGroup
(
groupSize
,
random
,
getDynElementsAtSource
());
if
(
newGroup
.
size
()
==
0
)
if
(
newGroup
.
isEmpty
()
)
throw
new
RuntimeException
(
"Cannot spawn new Group. Source "
+
source
.
getId
()
+
" is set "
+
"to useFreeSpaceOnly == false but no space is left to spawn group without exactly"
+
"overlapping with neighbours which can cause numerical problems. Use useFreeSpaceOnly == true (default)"
+
...
...
@@ -69,7 +69,7 @@ public class GroupSourceController extends SourceController {
while
(
iter
.
hasNext
())
{
int
groupSize
=
iter
.
next
();
List
<
VPoint
>
newGroup
=
spawnArray
.
getNextFreeGroup
(
groupSize
,
getDynElementsAtSource
());
if
(
newGroup
!=
null
)
{
if
(
newGroup
!=
null
&&
!
newGroup
.
isEmpty
()
)
{
// add immediately to Scenario to update DynElementsAtSource
addElementToScenario
(
newGroup
);
iter
.
remove
();
...
...
@@ -82,7 +82,7 @@ public class GroupSourceController extends SourceController {
while
(
iter
.
hasNext
())
{
int
groupSize
=
iter
.
next
();
List
<
VPoint
>
newGroup
=
spawnArray
.
getNextGroup
(
groupSize
,
getDynElementsAtSource
());
if
(
newGroup
==
null
)
if
(
newGroup
==
null
||
newGroup
.
isEmpty
()
)
throw
new
RuntimeException
(
"Cannot spawn new Group. Source "
+
source
.
getId
()
+
" is set "
+
"to useFreeSpaceOnly == false but no space is left to spawn group without exactly"
+
"overlapping with neighbours which can cause numerical problems. Use useFreeSpaceOnly == true (default)"
+
...
...
@@ -100,9 +100,9 @@ public class GroupSourceController extends SourceController {
}
private
void
addElementToScenario
(
List
<
VPoint
>
group
)
{
if
(!
isMaximumNumberOfSpawnedElementsReached
())
{
if
(
!
group
.
isEmpty
()
&&
!
isMaximumNumberOfSpawnedElementsReached
())
{
addNewAgentToScenario
(
group
);
dynamicElementsCreatedTotal
++
;
dynamicElementsCreatedTotal
+=
group
.
size
()
;
}
}
...
...
VadereSimulator/src/org/vadere/simulator/control/SourceController.java
View file @
c4004ac3
...
...
@@ -106,7 +106,7 @@ public abstract class SourceController {
return
maxNumber
!=
AttributesSource
.
NO_MAX_SPAWN_NUMBER_TOTAL
&&
dynamicElementsCreatedTotal
>=
maxNumber
;
}
abstract
protected
boolean
isQueueEmpty
();
abstract
protected
void
determineNumberOfSpawnsAndNextEvent
(
double
simTimeInSec
);
...
...
VadereSimulator/tests/org/vadere/simulator/control/GroupSourceControllerTest.java
View file @
c4004ac3
...
...
@@ -329,8 +329,9 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
@Test
public
void
testMaxSpawnNumberTotalWithSmallEndTime
()
{
int
maxSpawnNumberTotal
=
4
;
SourceTestAttributesBuilder
builder
=
new
SourceTestAttributesBuilder
()
.
setMaxSpawnNumberTotal
(
4
)
// <-- not exhausted
.
setMaxSpawnNumberTotal
(
maxSpawnNumberTotal
)
// <-- not exhausted
.
setEndTime
(
2
)
.
setSourceDim
(
5.0
,
5.0
)
.
setGroupSizeDistribution
(
0.0
,
0.0
,
0.25
,
0.75
)
...
...
@@ -341,7 +342,7 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
first
().
sourceController
.
update
(
2
);
first
().
sourceController
.
update
(
3
);
assertEquals
(
7
,
countPedestrians
(
0
));
assertEquals
(
maxSpawnNumberTotal
,
countPedestrians
(
0
));
}
@Test
...
...
@@ -353,12 +354,13 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
.
setMaxSpawnNumberTotal
(
maxSpawnNumberTotal
)
// <-- exhausted!
.
setSourceDim
(
5.0
,
5.0
)
.
setGroupSizeDistribution
(
0.0
,
0.0
,
0.25
,
0.75
)
.
setGroupSizeDistributionMock
(
4
,
3
,
4
,
4
);
.
setGroupSizeDistributionMock
(
4
,
3
,
4
,
4
)
.
setUseFreeSpaceOnly
(
false
);
initialize
(
builder
);
doUpdates
(
0
,
50
,
0
,
200
);
assertEquals
(
15
,
countPedestrians
(
0
));
assertEquals
(
maxSpawnNumberTotal
,
countPedestrians
(
0
));
}
...
...
@@ -377,7 +379,7 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
doUpdates
(
0
,
50
,
0
,
200
);
assertEquals
(
15
,
countPedestrians
(
0
));
assertEquals
(
maxSpawnNumberTotal
,
countPedestrians
(
0
));
}
@Test
...
...
@@ -387,14 +389,16 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
.
setGroupSizeDistribution
(
0.0
,
0.0
,
0.25
,
0.75
)
.
setSourceDim
(
new
VRectangle
(
0
,
0
,
3
,
4
))
.
setEndTime
(
4
)
.
setMaxSpawnNumberTotal
(
4
)
.
setMaxSpawnNumberTotal
(
6
)
.
setUseFreeSpaceOnly
(
false
)
.
setGroupSizeDistributionMock
(
3
,
4
,
4
,
4
,
3
);
SourceTestAttributesBuilder
builder2
=
new
SourceTestAttributesBuilder
()
.
setDistributionClass
(
TestSourceControllerUsingDistributions
.
ConstantTestDistribution
.
class
)
.
setGroupSizeDistribution
(
0.0
,
1.0
)
.
setSourceDim
(
new
VRectangle
(
20
,
20
,
3
,
2
))
.
setEndTime
(
6
)
.
setMaxSpawnNumberTotal
(
6
)
.
setMaxSpawnNumberTotal
(
20
)
.
setUseFreeSpaceOnly
(
false
)
.
setGroupSizeDistributionMock
(
2
,
2
,
2
,
2
,
2
,
2
);
initialize
(
builder1
);
...
...
@@ -408,7 +412,7 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
first
().
sourceController
.
update
(
2
);
first
().
sourceController
.
update
(
3
);
assertEquals
(
3
+
4
+
4
,
countPedestrians
(
0
));
assertEquals
(
3
+
4
,
countPedestrians
(
0
));
second
().
sourceController
.
update
(
2
);
second
().
sourceController
.
update
(
3
);
...
...
VadereState/src/org/vadere/state/attributes/scenario/SourceTestAttributesBuilder.java
View file @
c4004ac3
...
...
@@ -147,7 +147,7 @@ public class SourceTestAttributesBuilder {
+
",\"distributionParameters\": "
+
Arrays
.
toString
(
distributionParams
)
+
",\"startTime\": "
+
startTime
+
",\"endTime\": "
+
endTime
+
",\"spawnAtRandomPositions\":
tru
e"
+
",\"spawnAtRandomPositions\":
fals
e"
+
",\"useFreeSpaceOnly\": "
+
useFreeSpaceOnly
+
",\"groupSizeDistribution\" : "
+
groupSizeDistribution
()
+
"\n"
+
",\"targetIds\": [1]}"
;
...
...
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