Commit 560d835f authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

add reason negativeSpeed and WorldRecordTEst to checkPedestrianSpeedSetup check

parent fa799376
......@@ -313,6 +313,8 @@ TopographyChecker.source.overlapWithObstacle=Source overlaps with Obstacle. This
TopographyChecker.stairs.wrongTreadDim=Stair treadDepth outside of allowed dimension.
TopographyChecker.target.unused=The target is not used in any source. Remove target to increase performance.
TopographyChecker.pedestrian.speedsetup=speedDistributionMean must be within min/max range.
TopographyChecker.pedestrian.speedNotLogical=Min or Max speed of pedestrian is bigger than world record.
TopographyChecker.pedestrian.speedIsNegative=Min or Max speed is negative.
#TopographyChecker.obstacles.overlap=
#TopographyChecker.source.overlap=
#TopographyChecker.target.overlap=
......
......@@ -308,8 +308,10 @@ TopographyChecker.source.noTargetIdAndNoSpawn=In der Quelle wurden keine Ziel Id
TopographyChecker.source.idNotUnique=Quellen haben keine eindeutige ID.
TopographyChecker.source.overlapWithObstacle=Quelle und Hinderniss \u00fcberlappen sich. Dies kann f\u00fcrt zuf\u00fchren, dass Personen im Hinderniss erzeugt werden.
TopographyChecker.stairs.wrongTreadDim=Stufentiefe ist au\u00dferhalb des Definitionsbereichs.
TopographyChecker.target.unused=Das Ziel wird von keiner Quelle verwendet. Entferne das Ziel um die Performance zu erh\u00fchen
TopographyChecker.target.unused=Das Ziel wird von keiner Quelle verwendet. Entferne das Ziel um die Performance zu erh\u00f6hen
TopographyChecker.pedestrian.speedsetup=speedDistributionMean muss im Bereich min/max liegen.
TopographyChecker.pedestrian.speedNotLogical=Min or Max Geschwindigkeit ist gr\u00f6\u00dfer als Weltrekord.
TopographyChecker.pedestrian.speedIsNegative=Min or Max Geschwindigkeit ist negativ.
#TopographyChecker.obstacles.overlap=
#TopographyChecker.source.overlap=
#TopographyChecker.target.overlap=
......
......@@ -10,7 +10,6 @@ import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
......@@ -83,12 +82,28 @@ public class TopographyChecker {
.error()
.target(p)
.reason(TopographyCheckerReason.PEDESTRIAN_SPEED_SETUP,
"(" + p.getAttributes().getMaximumSpeed()
+ " < treadDepth > "
"(" + p.getAttributes().getMinimumSpeed()
+ " < treadDepth < "
+ p.getAttributes().getMaximumSpeed() +
") current SpeedDistributionMean is: " + String.format("%.2f",speedMean))
.build());
}
if (p.getAttributes().getMinimumSpeed() > Pedestrian.HUMAN_MAX_SPEED || p.getAttributes().getMaximumSpeed() > Pedestrian.HUMAN_MAX_SPEED){
ret.add(msgBuilder
.warning()
.target(p)
.reason(TopographyCheckerReason.PEDESTRIAN_SPEED_NOT_LOGICAL,
String.format("[max: %.2f min: %.2f threshold: %.2f]", p.getAttributes().getMinimumSpeed(),
p.getAttributes().getMaximumSpeed(), Pedestrian.HUMAN_MAX_SPEED))
.build());
}
if (p.getAttributes().getMinimumSpeed() < 0 || p.getAttributes().getMaximumSpeed() < 0){
ret.add(msgBuilder
.error()
.target(p)
.reason(TopographyCheckerReason.PEDESTRIAN_SPEED_NEGATIVE)
.build());
}
});
return ret;
......
package org.vadere.simulator.util;
import org.jetbrains.annotations.NotNull;
import org.vadere.state.scenario.ScenarioElement;
import java.util.Comparator;
......@@ -70,21 +69,6 @@ public class TopographyCheckerMessage implements Comparable<TopographyCheckerMes
}
};
}
//
// private Comparator<TopographyCheckerMessage> sortByElement() {
// return (o1, o2) -> {
// if (o1.element.equals(o2.element))
// return 0;
//
// if (o1.element.getType().ordinal() > o2.element.getType().ordinal()) {
// return 1;
// } else if (o1.element.getType().ordinal() < o2.element.getType().ordinal()) {
// return -1;
// } else {
// return 0;
// }
// };
// }
private Comparator<TopographyCheckerMessage> defaultSort() {
return sortByType();
......@@ -94,4 +78,14 @@ public class TopographyCheckerMessage implements Comparable<TopographyCheckerMes
public int compareTo(@NotNull TopographyCheckerMessage o) {
return defaultSort().compare(this, o);
}
@Override
public String toString() {
return "TopographyCheckerMessage{" +
"reason=" + reason +
", reasonModifier='" + reasonModifier + '\'' +
", msgType=" + msgType +
", msgTarget=" + msgTarget +
'}';
}
}
package org.vadere.simulator.util;
import org.jetbrains.annotations.NotNull;
import org.vadere.state.scenario.ScenarioElement;
import java.util.ArrayList;
......@@ -45,5 +44,16 @@ public class TopographyCheckerMessageTarget {
return Objects.hash(targets);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("TopographyCheckerMessageTarget{ targets=");
sb.append("[");
targets.forEach(t -> sb.append(t.getClass().getSimpleName()).append(", "));
sb.setLength(sb.length() -2);
sb.append("]}");
return sb.toString();
}
}
......@@ -24,4 +24,11 @@ public enum TopographyCheckerMessageType {
public String getLocalTypeId() {
return msgId;
}
@Override
public String toString() {
return "TopographyCheckerMessageType{" +
"type='" + type + '\'' +
'}';
}
}
......@@ -19,7 +19,9 @@ public enum TopographyCheckerReason {
SOURCE_OVERLAP("TopographyChecker.source.overlap"),
TARGET_OVERLAP("TopographyChecker.target.overlap"),
STAIRS_OVERLAP("TopographyChecker.stairs.overlap"),
PEDESTRIAN_SPEED_SETUP("TopographyChecker.pedestrian.speedsetup");
PEDESTRIAN_SPEED_SETUP("TopographyChecker.pedestrian.speedsetup"),
PEDESTRIAN_SPEED_NOT_LOGICAL("TopographyChecker.pedestrian.speedNotLogical"),
PEDESTRIAN_SPEED_NEGATIVE("TopographyChecker.pedestrian.speedIsNegative");
private String msgId;
......
......@@ -448,6 +448,68 @@ public class TopographyCheckerTest {
hasNoElement(out);
}
@Test
public void testCheckPedestrianSpeedMinIsWorldRecord(){
AttributesAgentBuilder attrAgentB = AttributesAgentBuilder.anAttributesAgent();
builder.addPedestrian(attrAgentB
.minimumSpeed(13.0)
.maximumSpeed(17.0)
.speedDistributionStandardDeviation(2.0)
.speedDistributionMean(15.0)
.build());
Topography topography = builder.build();
TopographyChecker checker = new TopographyChecker(topography);
List<TopographyCheckerMessage> out = checker.checkPedestrianSpeedSetup();
TopographyCheckerMessage msg = hasOneElement(out);
isWarnMsg(msg);
assertEquals(TopographyCheckerReason.PEDESTRIAN_SPEED_NOT_LOGICAL, msg.getReason());
}
@Test
public void testCheckPedestrianSpeedMaxIsWorldRecord(){
AttributesAgentBuilder attrAgentB = AttributesAgentBuilder.anAttributesAgent();
builder.addPedestrian(attrAgentB
.minimumSpeed(10.0)
.maximumSpeed(17.0)
.speedDistributionMean(10.0)
.build());
Topography topography = builder.build();
TopographyChecker checker = new TopographyChecker(topography);
List<TopographyCheckerMessage> out = checker.checkPedestrianSpeedSetup();
TopographyCheckerMessage msg = hasOneElement(out);
isWarnMsg(msg);
assertEquals(TopographyCheckerReason.PEDESTRIAN_SPEED_NOT_LOGICAL, msg.getReason());
}
@Test
public void testCheckPedestrianSpeedSetupWithNegativSpeed(){
AttributesAgentBuilder attrAgentB = AttributesAgentBuilder.anAttributesAgent();
builder.addPedestrian(attrAgentB
.minimumSpeed(-0.5)
.maximumSpeed(2.2)
.speedDistributionMean(0.8)
.build());
Topography topography = builder.build();
TopographyChecker checker = new TopographyChecker(topography);
List<TopographyCheckerMessage> out = checker.checkPedestrianSpeedSetup();
TopographyCheckerMessage msg = hasOneElement(out);
isErrorMsg(msg);
assertEquals(TopographyCheckerReason.PEDESTRIAN_SPEED_NEGATIVE, msg.getReason());
}
private TopographyCheckerMessage hasOneElement(List<TopographyCheckerMessage> out){
assertEquals(1, out.size());
......
......@@ -12,6 +12,7 @@ import java.util.Random;
public class Pedestrian extends Agent {
public static double HUMAN_MAX_SPEED = 12.0; // ms^-1
/** Target ID if the pedestrian represents a target, -1 otherwise. */
private int idAsTarget; // TODO should actually be an attribute or a member of a subclass
private Map<Class<? extends ModelPedestrian>, ModelPedestrian> modelPedestrianMap;
......
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