Commit ecb03290 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

change NaN to POSITIVE_INFINITY for evauation times of pedestrians that do not reach their target.

parent 80e4aadb
Pipeline #65789 failed with stages
in 46 minutes and 35 seconds
......@@ -7,6 +7,7 @@ import org.vadere.simulator.projects.dataprocessing.datakey.NoDataKey;
import org.vadere.state.attributes.processor.AttributesMeanPedestrianEvacuationTimeProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
......@@ -37,16 +38,9 @@ public class MeanPedestrianEvacuationTimeProcessor extends DataProcessor<NoDataK
@Override
public void postLoop(final SimulationState state) {
this.pedEvacTimeProc.postLoop(state);
List<Double> nonNans = this.pedEvacTimeProc.getValues().stream()
.filter(val -> !val.isNaN())
.collect(Collectors.toList());
int count = nonNans.size();
this.putValue(NoDataKey.key(), count > 0
? nonNans.parallelStream().reduce(0.0, (val1, val2) -> val1 + val2) / count
: Double.NaN);
pedEvacTimeProc.postLoop(state);
Collection<Double> evacTimes = pedEvacTimeProc.getValues();
putValue(NoDataKey.key(), evacTimes.parallelStream().reduce(0.0, (val1, val2) -> val1 + val2) / evacTimes.size());
}
@Override
......
......@@ -25,7 +25,7 @@ public class PedestrianEndTimeProcessor extends DataProcessor<PedestrianIdKey, D
@Override
public void postLoop(final SimulationState state) {
this.setValues(state.getTopography().getElements(Pedestrian.class), Double.NaN);
this.setValues(state.getTopography().getElements(Pedestrian.class), Double.POSITIVE_INFINITY);
}
@Override
......
......@@ -73,7 +73,7 @@ public class EvacuationTimeProcessorTestEnv extends ProcessorTestEnv<NoDataKey,
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(40.0);
addToExpectedOutput(NoDataKey.key(), Double.NaN);
addToExpectedOutput(NoDataKey.key(), Double.POSITIVE_INFINITY);
}
});
......
......@@ -76,7 +76,7 @@ public class MeanPedestrianEvacuationTimeProcessorTestEnv extends ProcessorTestE
addSimState(new SimulationStateMock(3) {
@Override
public void mockIt() {
b.clear().add(1, 2, 3, 4, 5, 6);
b.clear().add(1, 2, 3, 4, 5);
Mockito.when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
Mockito.when(state.getSimTimeInSec()).thenReturn(10.0);
}
......@@ -85,7 +85,7 @@ public class MeanPedestrianEvacuationTimeProcessorTestEnv extends ProcessorTestE
addSimState(new SimulationStateMock(4) {
@Override
public void mockIt() {
b.clear().add(6);
b.clear();
Mockito.when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
Mockito.when(state.getSimTimeInSec()).thenReturn(15.0);
......
......@@ -103,8 +103,8 @@ public class PedestrianEndTimeProcessorTestEnv extends ProcessorTestEnv<Pedestri
Mockito.when(state.getTopography().getElements(Pedestrian.class)).thenReturn(peds);
double time = state.getSimTimeInSec();
addToExpectedOutput(new PedestrianIdKey(8), Double.NaN);
addToExpectedOutput(new PedestrianIdKey(10), Double.NaN);
addToExpectedOutput(new PedestrianIdKey(8), Double.POSITIVE_INFINITY);
addToExpectedOutput(new PedestrianIdKey(10), Double.POSITIVE_INFINITY);
}
});
}
......
......@@ -119,7 +119,7 @@ public class PedestrianEvacuationTimeProcessorTestEnv extends ProcessorTestEnv<P
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(40.0);
addToExpectedOutput(new PedestrianIdKey(1), Double.NaN);
addToExpectedOutput(new PedestrianIdKey(1), Double.POSITIVE_INFINITY);
}
});
......
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