Commit 92eca5e3 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

fix a problem with the AreaSoeedProcessorTest and...

fix a problem with the AreaSoeedProcessorTest and PedestrianVelocityProcessorTest: Wrong expected values.
parent 5fb72709
Pipeline #79626 failed with stages
in 106 minutes and 24 seconds
......@@ -49,7 +49,7 @@ public class AreaSpeedProcessor extends AreaDataProcessor<Double> {
}
}
this.putValue(new TimestepKey(step), sumVelocities / pedCount);
this.putValue(new TimestepKey(step), (pedCount > 0 ? sumVelocities / pedCount : 0.0));
}
@Override
......
......@@ -64,9 +64,9 @@ public class PedestrianVelocityProcessor extends APedestrianVelocityProcessor {
private double getVelocity(int timeStep, double currentSimTime, int pedId) {
int pastStep = timeStep - backSteps;
int pastStep = Math.max(1, timeStep - backSteps);
double velocity = 0.0;
if(pastStep >= 1) {
if(timeStep > 1) {
VPoint pastPosition = pedestrianPositionProcessor.getValue(new TimestepPedestrianIdKey(pastStep, pedId));
VPoint position = pedestrianPositionProcessor.getValue(new TimestepPedestrianIdKey(timeStep, pedId));
......
......@@ -82,10 +82,11 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
.add(3, new VPoint(8.0, 4.0)); //not in area
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(2.0);
double simTime = 1.0;
when(state.getSimTimeInSec()).thenReturn(simTime);
int step = state.getStep();
double time = 2.0 - 0.0;
double time = simTime - 0.0;
double areaSpeed = (1.0 / time + 5.0 / time) / 2; // 2 = noOfPeds
addToExpectedOutput(new TimestepKey(step), areaSpeed);
}
......@@ -99,10 +100,11 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
.add(3, new VPoint(8.0, 8.0)); //not in area
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(3.0);
double simTime = 2.0;
when(state.getSimTimeInSec()).thenReturn(simTime);
int step = state.getStep();
double time = 3.0 - 2.0; // time in this step
double time = simTime - 1.0; // time in this step
double areaSpeed = (2.0 / time) / 1; // 1 = noOfPeds
addToExpectedOutput(new TimestepKey(step), areaSpeed);
}
......@@ -116,10 +118,11 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
.add(3, new VPoint(9.0, 8.0)); // not in area
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(3.0);
double simTime = 3.0;
when(state.getSimTimeInSec()).thenReturn(simTime);
int step = state.getStep();
addToExpectedOutput(new TimestepKey(step), Double.NaN);
addToExpectedOutput(new TimestepKey(step), 0.0);
}
});
}
......
......@@ -32,7 +32,7 @@ public class PedestrianVelocityProcessorTest extends ProcessorTest {
super.doUpdate();
}
@Test public void withBackstepTow() throws Exception {
@Test public void withBackstepTwo() throws Exception {
AttributesPedestrianVelocityProcessor attr =
(AttributesPedestrianVelocityProcessor) p.getAttributes();
attr.setBackSteps(2);
......
......@@ -115,8 +115,8 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
when(state.getSimTimeInSec()).thenReturn(2.0);
int step = state.getStep();
addToExpectedOutput(new TimestepPedestrianIdKey(step, 1), 0.5);
addToExpectedOutput(new TimestepPedestrianIdKey(step, 2), 5.0);
addToExpectedOutput(new TimestepPedestrianIdKey(step, 1), 0.25);
addToExpectedOutput(new TimestepPedestrianIdKey(step, 2), 2.5);
addToExpectedOutput(new TimestepPedestrianIdKey(step, 3), 0.0);
}
......
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