Commit 9a67c708 authored by Mario Teixeira Parente's avatar Mario Teixeira Parente
Browse files

Rename addValue to setValue

Values are not added always, they are also changed.
parent dbf91d0f
......@@ -18,6 +18,6 @@ public abstract class AreaDensityProcessor extends AreaDataProcessor<Double> {
@Override
protected void doUpdate(final SimulationState state) {
this.addValue(new TimestepKey(state.getStep()), this.densAlg.getDensity(state));
this.setValue(new TimestepKey(state.getStep()), this.densAlg.getDensity(state));
}
}
......@@ -45,7 +45,7 @@ public class AreaSpeedProcessor extends AreaDataProcessor<Double> {
}
}
this.addValue(new TimestepKey(step), sumVelocities / pedCount);
this.setValue(new TimestepKey(step), sumVelocities / pedCount);
}
@Override
......
......@@ -20,7 +20,7 @@ import java.util.TreeMap;
*
* The method <tt>doUpdate</tt> gets called after every simulation step with the current <tt>SimulationState</tt>.
* Here, one gets the opportunity to compute a new value or to update the state for a computation in <tt>postLoop</tt>.
* The computed value can be stored afterwards in the data by using the <tt>addValue</tt> method.
* The computed value can be stored afterwards in the data by using the <tt>setValue</tt> method.
*
* To get specific attributes defined in JSON or access to the <tt>MainModel</tt>, one has to use the <tt>init</tt> method which
* gives access to all significant things via the argument <tt>manager</tt> of type <tt>ProcessorManager</tt>.
......@@ -96,7 +96,7 @@ public abstract class DataProcessor<K extends DataKey<K>, V> {
return data.get(key);
}
protected void addValue(final K key, final V value) {
protected void setValue(final K key, final V value) {
this.data.put(key, value);
}
......
......@@ -36,7 +36,7 @@ public class EvacuationTimeProcessor extends DataProcessor<NoDataKey, Double> {
: Collections.max(this.pedEvacTimeProc.getValues());
}
this.addValue(NoDataKey.key(), result);
this.setValue(NoDataKey.key(), result);
}
@Override
......
......@@ -13,7 +13,7 @@ public class FloorFieldGridProcessor extends DataProcessor<TimestepRowKey, Floor
protected void doUpdate(SimulationState state) {
// First try, TODO: Implementation
for (int i = 0; i < 50; ++i) {
this.addValue(new TimestepRowKey(state.getStep(), i), new FloorFieldGridRow(50));
this.setValue(new TimestepRowKey(state.getStep(), i), new FloorFieldGridRow(50));
}
}
......
......@@ -40,7 +40,7 @@ public class MeanPedestrianEvacuationTimeProcessor extends DataProcessor<NoDataK
.collect(Collectors.toList());
int count = nonNans.size();
this.addValue(NoDataKey.key(), count > 0
this.setValue(NoDataKey.key(), count > 0
? nonNans.stream().reduce(0.0, (val1, val2) -> val1 + val2) / count
: Double.NaN);
}
......
......@@ -25,7 +25,7 @@ public abstract class PedestrianDensityProcessor extends DataProcessor<TimestepP
this.pedPosProc.update(state);
state.getTopography().getElements(Pedestrian.class).stream()
.forEach(ped -> this.addValue(new TimestepPedestrianIdKey(state.getStep(), ped.getId()),
.forEach(ped -> this.setValue(new TimestepPedestrianIdKey(state.getStep(), ped.getId()),
this.densAlg.getDensity(ped.getPosition(), state)));
}
......
......@@ -34,6 +34,6 @@ public class PedestrianEndTimeProcessor extends DataProcessor<PedestrianIdKey, D
private void setValues(Collection<Pedestrian> peds, double value) {
peds.stream().map(ped -> new PedestrianIdKey(ped.getId()))
.forEach(key -> this.addValue(key, value));
.forEach(key -> this.setValue(key, value));
}
}
......@@ -24,14 +24,14 @@ public class PedestrianEvacuationTimeProcessor extends DataProcessor<PedestrianI
state.getTopography().getElements(Pedestrian.class).stream()
.map(ped -> new PedestrianIdKey(ped.getId()))
.forEach(key -> this.addValue(key, state.getSimTimeInSec() - this.pedStTimeProc.getValue(key)));
.forEach(key -> this.setValue(key, state.getSimTimeInSec() - this.pedStTimeProc.getValue(key)));
}
@Override
public void postLoop(final SimulationState state) {
state.getTopography().getElements(Pedestrian.class).stream()
.map(ped -> new PedestrianIdKey(ped.getId()))
.forEach(key -> this.addValue(key, Double.NaN));
.forEach(key -> this.setValue(key, Double.NaN));
}
@Override
......
......@@ -32,7 +32,7 @@ public class PedestrianFlowProcessor extends DataProcessor<TimestepPedestrianIdK
double velocity = this.pedVelProc.getValue(key);
double density = this.pedDensProc.getValue(key);
this.addValue(key, velocity * density);
this.setValue(key, velocity * density);
}
}
......
......@@ -26,7 +26,7 @@ public class PedestrianLastPositionProcessor extends DataProcessor<PedestrianIdK
this.pedPosProc.update(state);
Map<Integer, VPoint> pedPosMap = state.getPedestrianPositionMap();
pedPosMap.keySet().forEach(pedId -> this.addValue(new PedestrianIdKey(pedId),
pedPosMap.keySet().forEach(pedId -> this.setValue(new PedestrianIdKey(pedId),
this.pedPosProc.getValue(new TimestepPedestrianIdKey(state.getStep(), pedId))));
}
......
......@@ -27,7 +27,7 @@ public class PedestrianOSMStrideLengthProcessor extends DataProcessor<TimestepPe
protected void doUpdate(final SimulationState state) {
Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
// TODO: if osm != null then compute stridelength
peds.forEach(ped -> this.addValue(new TimestepPedestrianIdKey(state.getStep(), ped.getId()), this.osm == null ? Double.NaN : 0.0));
peds.forEach(ped -> this.setValue(new TimestepPedestrianIdKey(state.getStep(), ped.getId()), this.osm == null ? Double.NaN : 0.0));
// TODO Use this comment from the old implementation for this implementation
// @Override
......
......@@ -24,7 +24,7 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
protected void doUpdate(final SimulationState state) {
Map<Integer, VPoint> pedPosMap = state.getPedestrianPositionMap();
pedPosMap.entrySet().forEach(entry -> this.addValue(new TimestepPedestrianIdKey(state.getStep(), entry.getKey()), this.calculateOverlaps(pedPosMap, entry.getValue())));
pedPosMap.entrySet().forEach(entry -> this.setValue(new TimestepPedestrianIdKey(state.getStep(), entry.getKey()), this.calculateOverlaps(pedPosMap, entry.getValue())));
}
@Override
......
......@@ -37,7 +37,7 @@ public class PedestrianPositionProcessor extends DataProcessor<TimestepPedestria
Integer pedId = entry.getKey();
VPoint pos = entry.getValue();
this.addValue(new TimestepPedestrianIdKey(timeStep, pedId), pos);
this.setValue(new TimestepPedestrianIdKey(timeStep, pedId), pos);
}
}
......
......@@ -26,7 +26,7 @@ public class PedestrianSourceIdProcessor extends DataProcessor<PedestrianIdKey,
peds.forEach(p -> {
final Source s = p.getSource();
final int sourceId = (s == null) ? -1 : s.getId();
this.addValue(new PedestrianIdKey(p.getId()), sourceId);
this.setValue(new PedestrianIdKey(p.getId()), sourceId);
});
}
......
......@@ -33,6 +33,6 @@ public class PedestrianStartTimeProcessor extends DataProcessor<PedestrianIdKey,
Set<PedestrianIdKey> keys = this.getKeys();
if (!keys.contains(pedIdKey))
this.addValue(pedIdKey, startTime);
this.setValue(pedIdKey, startTime);
}
}
......@@ -22,7 +22,7 @@ public class PedestrianTargetIdProcessor extends DataProcessor<TimestepPedestria
public void doUpdate(final SimulationState state) {
Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
peds.forEach(p -> this.addValue(new TimestepPedestrianIdKey(state.getStep(), p.getId()),
peds.forEach(p -> this.setValue(new TimestepPedestrianIdKey(state.getStep(), p.getId()),
p.getTargets().isEmpty() ? -1 : p.getTargets().getFirst()));
}
......
......@@ -35,7 +35,7 @@ public class PedestrianVelocityProcessor extends DataProcessor<TimestepPedestria
Integer timeStep = state.getStep();
Stream<Integer> pedIds = state.getTopography().getElements(Pedestrian.class).stream().map(ped -> ped.getId());
pedIds.forEach(pedId -> this.addValue(new TimestepPedestrianIdKey(timeStep, pedId),
pedIds.forEach(pedId -> this.setValue(new TimestepPedestrianIdKey(timeStep, pedId),
this.getVelocity(timeStep, state.getSimTimeInSec(), pedId)));
if (this.lastSimTimes.size() >= this.backSteps)
......
......@@ -31,7 +31,7 @@ public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianI
if (this.waitingArea.contains(pos)) {
PedestrianIdKey key = new PedestrianIdKey(pedId);
this.addValue(key, state.getSimTimeInSec());
this.setValue(key, state.getSimTimeInSec());
}
}
}
......
......@@ -36,7 +36,7 @@ public class PedestrianWaitingTimeProcessor extends DataProcessor<PedestrianIdKe
if (this.waitingArea.contains(pos)) {
PedestrianIdKey key = new PedestrianIdKey(pedId);
this.addValue(key, (this.hasValue(key) ? this.getValue(key) : 0.0) + dt);
this.setValue(key, (this.hasValue(key) ? this.getValue(key) : 0.0) + dt);
}
}
......
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