24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit af25b04e authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

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
......@@ -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
......
......@@ -80,7 +80,7 @@ import java.util.stream.IntStream;
public class SpawnArray {
private static Logger logger = LogManager.getLogger(SpawnArray.class);
private static final double EPSILON = 0.01;
public 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));
}
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment