Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit d30dc9c4 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

fix #167. Increase minimum circle radius of source. Add ScenarioChecker Test

This is needed because the SourceController spawns pedestrian based on
on the rectangular bound. Thus the pedestrian cannot be placed
*completely* within a circle with radius 0.4 although there would be
enough space.
parent fe8706e6
Pipeline #76304 failed with stages
in 76 minutes and 41 seconds
TopographyCreator.dotRadius=0.4
\ No newline at end of file
TopographyCreator.dotRadius=0.5
\ No newline at end of file
......@@ -15,6 +15,7 @@ ScenarioChecker.source.noTargetIdSet=No Target Ids set for Source.
ScenarioChecker.source.noTargetIdAndNoSpawn=No Target Ids set for Source with SpawnNumber 0. This might be an error.
ScenarioChecker.source.idNotUnique=Multiple Sources have the same ID.
ScenarioChecker.source.spawnAtRandomButNotAtFreeSpace=Combination isSpawnAtRandomPositions=true and isUseFreeSpaceOnly=false not allowed.
ScenarioChecker.source.toSmall=Source is to small
ScenarioChecker.source.spawnUseNotAtFreeSpace=useFreeSpaceOnly=false is Deprecated. Will be removed in future relases. Not all models can handle overlapping pedestrians.
ScenarioChecker.stairs.wrongTreadDim=Stair treadDepth outside of allowed dimension. Change the thread numbers to compensate.
ScenarioChecker.target.unused=The target is not used in any source. Remove target to increase performance.
......
......@@ -14,6 +14,7 @@ ScenarioChecker.source.targetIdNotFound=Die folgenden Ziel-IDs wurden nicht im S
ScenarioChecker.source.noTargetIdSet=In der Quelle wurden keine Ziel Ids vergeben.
ScenarioChecker.source.noTargetIdAndNoSpawn=In der Quelle wurden keine Ziel Ids vergeben, aber die Spawn Anzahl ist bei 0.
ScenarioChecker.source.spawnAtRandomButNotAtFreeSpace=Kombination aus isSpawnAtRandomPositions=true und isUseFreeSpaceOnly=false ist nicht erlaubt.
ScenarioChecker.source.toSmall=Quelle ist zu klein
ScenarioChecker.source.spawnUseNotAtFreeSpace=useFreeSpaceOnly=false ist Deprecated. Dieses Attribut wird in zuk\u00fcnfigen version entfernt. Nicht alle Modell k\u00f6nnen mit \u00fcberlappungen umgehen.
ScenarioChecker.source.idNotUnique=Quellen haben keine eindeutige ID.
ScenarioChecker.stairs.wrongTreadDim=Stufentiefe ist au\u00dferhalb des Definitionsbereichs. Passen Sie die Anzahl der Stufen entsprechend an.
......
......@@ -5,6 +5,7 @@ import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.utils.scenariochecker.checks.ScenarioCheckerTest;
import org.vadere.simulator.utils.scenariochecker.checks.simulation.SimulationTimeStepLengthCheck;
import org.vadere.simulator.utils.scenariochecker.checks.topography.PedestrianSpeedSetupCheck;
import org.vadere.simulator.utils.scenariochecker.checks.topography.SourceMinRadiusCheck;
import org.vadere.simulator.utils.scenariochecker.checks.topography.SourceSpawnSettingCheck;
import org.vadere.simulator.utils.scenariochecker.checks.topography.StairTreadSanityCheck;
import org.vadere.simulator.utils.scenariochecker.checks.topography.TopographyOverlapCheck;
......@@ -23,7 +24,7 @@ public class ScenarioChecker {
private final Topography topography;
private final Scenario scenario;
public ScenarioChecker(@NotNull final Topography topography){
public ScenarioChecker(@NotNull final Topography topography) {
Scenario s = new Scenario("");
s.setTopography(topography);
this.scenario = s;
......@@ -44,12 +45,12 @@ public class ScenarioChecker {
}
public PriorityQueue<ScenarioCheckerMessage> checkOverlap(){
public PriorityQueue<ScenarioCheckerMessage> checkOverlap() {
return runCheck(new TopographyOverlapCheck());
}
private PriorityQueue<ScenarioCheckerMessage> runCheck(ScenarioCheckerTest checkerTest){
private PriorityQueue<ScenarioCheckerMessage> runCheck(ScenarioCheckerTest checkerTest) {
return checkerTest.runScenarioCheckerTest(scenario);
}
......@@ -63,16 +64,21 @@ public class ScenarioChecker {
ret.addAll(checkOverlap());
ret.addAll(checkSimulationAttribues());
ret.addAll(checkSourceSpawnSetting());
ret.addAll(checkMinSourceRadius());
return ret;
}
public PriorityQueue<ScenarioCheckerMessage> checkSimulationAttribues(){
public PriorityQueue<ScenarioCheckerMessage> checkMinSourceRadius() {
return runCheck(new SourceMinRadiusCheck());
}
public PriorityQueue<ScenarioCheckerMessage> checkSimulationAttribues() {
PriorityQueue<ScenarioCheckerMessage> ret = new PriorityQueue<>();
ret.addAll(runCheck(new SimulationTimeStepLengthCheck()));
return ret;
}
public PriorityQueue<ScenarioCheckerMessage> checkSourceSpawnSetting(){
public PriorityQueue<ScenarioCheckerMessage> checkSourceSpawnSetting() {
return runCheck(new SourceSpawnSettingCheck());
}
......
......@@ -14,6 +14,7 @@ public enum ScenarioCheckerReason {
SOURCE_NO_TARGET_ID_NO_SPAWN("ScenarioChecker.source.noTargetIdAndNoSpawn"),
SOURCE_ID_NOT_UNIQUE("ScenarioChecker.source.idNotUnique"),
SOURCE_SPAWN_RND_POS_NOT_FREE_SPACE("ScenarioChecker.source.spawnAtRandomButNotAtFreeSpace"),
SOURCE_TO_SMALL("ScenarioChecker.source.toSmall"),
SOURCE_SPAWN_USE_NOT_FREE_SPACE("ScenarioChecker.source.spawnUseNotAtFreeSpace"),
STAIRS_TREAD_DIM_WRONG("ScenarioChecker.stairs.wrongTreadDim"),
......
package org.vadere.simulator.utils.scenariochecker.checks.topography;
import org.vadere.simulator.utils.scenariochecker.ScenarioCheckerMessage;
import org.vadere.simulator.utils.scenariochecker.ScenarioCheckerReason;
import org.vadere.simulator.utils.scenariochecker.checks.AbstractScenarioCheck;
import org.vadere.simulator.utils.scenariochecker.checks.TopographyCheckerTest;
import org.vadere.state.scenario.Source;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VCircle;
import java.util.List;
import java.util.PriorityQueue;
import java.util.stream.Collectors;
/**
* Test if a circular source has at least 0.5 diameter
*/
public class SourceMinRadiusCheck extends AbstractScenarioCheck implements TopographyCheckerTest {
private static final double MIN_RADIUS = 0.5;
@Override
public PriorityQueue<ScenarioCheckerMessage> runScenarioCheckerTest(Topography topography) {
List<Source> sourceList = topography.getSources()
.stream()
.filter(s -> s.getShape() instanceof VCircle)
.collect(Collectors.toList());
for (Source source : sourceList) {
double radius = ((VCircle) source.getShape()).getRadius();
if (radius < MIN_RADIUS) {
messages.add(msgBuilder.topographyWarning().target(source)
.reason(ScenarioCheckerReason.SOURCE_TO_SMALL, ", mind. radius=" + MIN_RADIUS).build());
}
}
return messages;
}
}
......@@ -23,106 +23,106 @@ public class TopographyTestBuilder {
ScenarioElement lastAddedElement;
Random rnd;
public TopographyTestBuilder(){
public TopographyTestBuilder() {
topography = new Topography();
rnd = new Random(1);
}
public Topography build(){
public Topography build() {
Topography ret = topography;
topography = new Topography();
return ret;
return ret;
}
public ScenarioElement getLastAddedElement(){
public ScenarioElement getLastAddedElement() {
return lastAddedElement;
}
TopographyTestBuilder addSource(){
public TopographyTestBuilder addSource() {
addSource(-1);
return this;
return this;
}
TopographyTestBuilder addSource(int id){
addSource(id, new VRectangle(0,0, 10, 10));
return this;
public TopographyTestBuilder addSource(int id) {
addSource(id, new VRectangle(0, 0, 10, 10));
return this;
}
TopographyTestBuilder addSource(int id, VShape s){
addSource(new AttributesSource(id,s));
return this;
public TopographyTestBuilder addSource(int id, VShape s) {
addSource(new AttributesSource(id, s));
return this;
}
TopographyTestBuilder addSource(AttributesSource attr){
public TopographyTestBuilder addSource(AttributesSource attr) {
Source source = new Source(attr);
lastAddedElement = source;
topography.addSource(source);
return this;
return this;
}
TopographyTestBuilder addTarget(){
public TopographyTestBuilder addTarget() {
addSource(-1);
return this;
}
TopographyTestBuilder addTarget(int id){
addTarget(id, new VRectangle(0,0,10,10));
public TopographyTestBuilder addTarget(int id) {
addTarget(id, new VRectangle(0, 0, 10, 10));
return this;
}
TopographyTestBuilder addTarget(int id, VShape s){
public TopographyTestBuilder addTarget(int id, VShape s) {
addTarget(new AttributesTarget(s, id, true));
return this;
}
TopographyTestBuilder addTarget(AttributesTarget attr){
public TopographyTestBuilder addTarget(AttributesTarget attr) {
Target target = new Target(attr);
lastAddedElement = target;
topography.addTarget(target);
return this;
}
TopographyTestBuilder addObstacle(){
public TopographyTestBuilder addObstacle() {
addObstacle(-1);
return this;
}
TopographyTestBuilder addObstacle(int id){
addObstacle(id, new VRectangle(0,0,10,10));
public TopographyTestBuilder addObstacle(int id) {
addObstacle(id, new VRectangle(0, 0, 10, 10));
return this;
}
TopographyTestBuilder addObstacle(int id, VShape s){
public TopographyTestBuilder addObstacle(int id, VShape s) {
addObstacle(new AttributesObstacle(id, s));
return this;
}
TopographyTestBuilder addObstacle(AttributesObstacle attr){
public TopographyTestBuilder addObstacle(AttributesObstacle attr) {
Obstacle obstacle = new Obstacle(attr);
lastAddedElement = obstacle;
topography.addObstacle(obstacle);
return this;
}
TopographyTestBuilder addStairs(){
public TopographyTestBuilder addStairs() {
addStairs(new AttributesStairs());
return this;
}
TopographyTestBuilder addStairs(AttributesStairs attr){
public TopographyTestBuilder addStairs(AttributesStairs attr) {
Stairs stairs = new Stairs(attr);
lastAddedElement = stairs;
topography.addStairs(stairs);
return this;
}
TopographyTestBuilder addPedestrian(){
public TopographyTestBuilder addPedestrian() {
return this;
}
TopographyTestBuilder addPedestrian(AttributesAgent attr){
public TopographyTestBuilder addPedestrian(AttributesAgent attr) {
Pedestrian pedestrian = new Pedestrian(attr, rnd);
lastAddedElement = pedestrian;
topography.addInitialElement(pedestrian);
......
package org.vadere.simulator.utils.scenariochecker.checks.topography;
import org.junit.Test;
import org.vadere.simulator.utils.TopographyTestBuilder;
import org.vadere.simulator.utils.scenariochecker.ScenarioCheckerMessage;
import org.vadere.simulator.utils.scenariochecker.ScenarioCheckerReason;
import org.vadere.util.geometry.shapes.VCircle;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.PriorityQueue;
import static org.junit.Assert.*;
public class SourceMinRadiusCheckTest {
@Test
public void TestSourceMinRadiusPositive() {
SourceMinRadiusCheck sourceMinRadiusCheck = new SourceMinRadiusCheck();
TopographyTestBuilder builder = new TopographyTestBuilder();
builder.addSource(1, new VCircle(10.0, 10.0, 0.4));
builder.addSource(2, new VRectangle(5.0, 5.0, 1.0, 1.0));
PriorityQueue<ScenarioCheckerMessage> ret = sourceMinRadiusCheck.runScenarioCheckerTest(builder.build());
assertEquals(1, ret.size());
assertEquals(ScenarioCheckerReason.SOURCE_TO_SMALL, ret.poll().getReason());
}
@Test
public void TestSourceMinRadiusNegative() {
SourceMinRadiusCheck sourceMinRadiusCheck = new SourceMinRadiusCheck();
TopographyTestBuilder builder = new TopographyTestBuilder();
builder.addSource(2, new VRectangle(5.0, 5.0, 0.4, 0.4));
PriorityQueue<ScenarioCheckerMessage> ret = sourceMinRadiusCheck.runScenarioCheckerTest(builder.build());
assertEquals(0, ret.size());
}
@Test
public void TestSourceMinRadiusPositive2() {
SourceMinRadiusCheck sourceMinRadiusCheck = new SourceMinRadiusCheck();
TopographyTestBuilder builder = new TopographyTestBuilder();
builder.addSource(1, new VCircle(10.0, 10.0, 4.0));
builder.addSource(2, new VRectangle(5.0, 5.0, 1.0, 1.0));
PriorityQueue<ScenarioCheckerMessage> ret = sourceMinRadiusCheck.runScenarioCheckerTest(builder.build());
assertEquals(0, ret.size());
}
}
\ No newline at end of file
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