Commit 83cb5e48 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

remove possible performance problems based on measurementArea

parents 6523d610 de166cff
Pipeline #102623 passed with stages
in 127 minutes
{ {
"name" : "Neues_Szenario", "name" : "Neues_Szenario",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "warning: no commit hash", "commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
...@@ -75,20 +75,8 @@ ...@@ -75,20 +75,8 @@
"id" : 6, "id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor", "attributesType" : "org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor",
"attributes" : { "attributes" : {
"measurementArea" : { "measurementAreaId" : 1,
"x" : 5.0, "voronoiMeasurementAreaId" : 1
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"voronoiArea" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
} }
}, { }, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.AreaSpeedProcessor", "type" : "org.vadere.simulator.projects.dataprocessing.processor.AreaSpeedProcessor",
...@@ -148,26 +136,14 @@ ...@@ -148,26 +136,14 @@
"id" : 15, "id" : 15,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingTimeProcessor", "attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingTimeProcessor",
"attributes" : { "attributes" : {
"waitingArea" : { "waitingAreaId" : 1
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
} }
}, { }, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianWaitingEndTimeProcessor", "type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianWaitingEndTimeProcessor",
"id" : 16, "id" : 16,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor", "attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor",
"attributes" : { "attributes" : {
"waitingArea" : { "waitingAreaId" : 1
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
} }
}, { }, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOSMStrideLengthProcessor", "type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOSMStrideLengthProcessor",
...@@ -341,7 +317,17 @@ ...@@ -341,7 +317,17 @@
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"dynamicElements" : [ ], "dynamicElements" : [ ],
"attributesCar" : null "attributesCar" : null,
"measurementAreas" : [ {
"shape" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"id" : 1
} ]
} }
} }
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import org.vadere.state.scenario.MeasurementArea; ...@@ -13,6 +13,7 @@ import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.simulation.VTrajectory; import org.vadere.state.simulation.VTrajectory;
import org.vadere.util.factory.processors.Flag; import org.vadere.util.factory.processors.Flag;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.logging.Logger; import org.vadere.util.logging.Logger;
import java.util.HashMap; import java.util.HashMap;
...@@ -40,6 +41,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey, ...@@ -40,6 +41,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
private static Logger logger = Logger.getLogger(Topography.class); private static Logger logger = Logger.getLogger(Topography.class);
private MeasurementArea measurementArea; private MeasurementArea measurementArea;
private VRectangle measurementAreaVRec;
private PedestrianTrajectoryProcessor pedestrianTrajectoryProcessor; private PedestrianTrajectoryProcessor pedestrianTrajectoryProcessor;
public FundamentalDiagramBProcessor() { public FundamentalDiagramBProcessor() {
...@@ -56,6 +58,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey, ...@@ -56,6 +58,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getMeasurementAreaId())); throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getMeasurementAreaId()));
if (!measurementArea.isRectangular()) if (!measurementArea.isRectangular())
throw new RuntimeException("DataProcessor only supports Rectangular measurement areas."); throw new RuntimeException("DataProcessor only supports Rectangular measurement areas.");
measurementAreaVRec = measurementArea.asVRectangle();
} }
@Override @Override
...@@ -89,7 +92,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey, ...@@ -89,7 +92,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
for(Map.Entry<PedestrianIdKey, VTrajectory> trajectoryEntry : trajectoryMap.entrySet()) { for(Map.Entry<PedestrianIdKey, VTrajectory> trajectoryEntry : trajectoryMap.entrySet()) {
PedestrianIdKey key = trajectoryEntry.getKey(); PedestrianIdKey key = trajectoryEntry.getKey();
VTrajectory trajectory = trajectoryEntry.getValue(); VTrajectory trajectory = trajectoryEntry.getValue();
VTrajectory clone = trajectory.cut(measurementArea.asVRectangle()); VTrajectory clone = trajectory.cut(measurementAreaVRec);
cutTrajectoryMap.put(key, clone); cutTrajectoryMap.put(key, clone);
} }
...@@ -120,7 +123,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey, ...@@ -120,7 +123,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
.sum(); .sum();
densityIntegral /= duration; densityIntegral /= duration;
densityIntegral /= measurementArea.asVRectangle().getArea(); densityIntegral /= measurementAreaVRec.getArea();
return densityIntegral; return densityIntegral;
/*List<Triple<Double, Double, Integer>> integralValues = new LinkedList<>(); /*List<Triple<Double, Double, Integer>> integralValues = new LinkedList<>();
......
...@@ -12,6 +12,7 @@ import org.vadere.state.attributes.processor.AttributesFundamentalDiagramCProces ...@@ -12,6 +12,7 @@ import org.vadere.state.attributes.processor.AttributesFundamentalDiagramCProces
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.factory.processors.Flag; import org.vadere.util.factory.processors.Flag;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.List; import java.util.List;
...@@ -30,6 +31,7 @@ import java.util.List; ...@@ -30,6 +31,7 @@ import java.util.List;
public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, Double>> implements UsesMeasurementArea { public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, Double>> implements UsesMeasurementArea {
private MeasurementArea measurementArea; private MeasurementArea measurementArea;
private VRectangle measurementAreaVRec;
private APedestrianVelocityProcessor pedestrianVelocityProcessor; private APedestrianVelocityProcessor pedestrianVelocityProcessor;
...@@ -47,6 +49,7 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, ...@@ -47,6 +49,7 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getMeasurementAreaId())); throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getMeasurementAreaId()));
if (!measurementArea.isRectangular()) if (!measurementArea.isRectangular())
throw new RuntimeException("DataProcessor only supports Rectangular measurement areas."); throw new RuntimeException("DataProcessor only supports Rectangular measurement areas.");
measurementAreaVRec = measurementArea.asVRectangle();
} }
@Override @Override
...@@ -67,11 +70,11 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, ...@@ -67,11 +70,11 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
pedestrianVelocityProcessor.update(state); pedestrianVelocityProcessor.update(state);
long N = state.getTopography().getPedestrianDynamicElements().getElements() long N = state.getTopography().getPedestrianDynamicElements().getElements()
.stream() .stream()
.filter(pedestrian -> measurementArea.asVRectangle().contains(pedestrian.getPosition())) .filter(pedestrian -> measurementAreaVRec.contains(pedestrian.getPosition()))
.count(); .count();
double velocity = state.getTopography().getPedestrianDynamicElements().getElements() double velocity = state.getTopography().getPedestrianDynamicElements().getElements()
.stream() .stream()
.filter(pedestrian -> measurementArea.asVRectangle().contains(pedestrian.getPosition())) .filter(pedestrian -> measurementAreaVRec.contains(pedestrian.getPosition()))
.mapToDouble(pedestrian -> .mapToDouble(pedestrian ->
//pedestrian.getVelocity().getLength() //pedestrian.getVelocity().getLength()
pedestrianVelocityProcessor.getValue(new TimestepPedestrianIdKey(state.getStep(), pedestrian.getId())) pedestrianVelocityProcessor.getValue(new TimestepPedestrianIdKey(state.getStep(), pedestrian.getId()))
...@@ -85,7 +88,7 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double, ...@@ -85,7 +88,7 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
velocity /= N; velocity /= N;
} }
double density = N / measurementArea.asVRectangle().getArea(); double density = N / measurementAreaVRec.getArea();
putValue(new TimestepKey(state.getStep()), Pair.of(velocity, density)); putValue(new TimestepKey(state.getStep()), Pair.of(velocity, density));
} }
......
...@@ -13,6 +13,7 @@ import org.vadere.state.scenario.MeasurementArea; ...@@ -13,6 +13,7 @@ import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.simulation.FootStep; import org.vadere.state.simulation.FootStep;
import org.vadere.util.factory.processors.Flag; import org.vadere.util.factory.processors.Flag;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.logging.Logger; import org.vadere.util.logging.Logger;
import java.util.Collection; import java.util.Collection;
...@@ -23,6 +24,8 @@ import java.util.List; ...@@ -23,6 +24,8 @@ import java.util.List;
public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdKey, Pair<Double, Double>> implements UsesMeasurementArea { public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdKey, Pair<Double, Double>> implements UsesMeasurementArea {
private MeasurementArea measurementArea; private MeasurementArea measurementArea;
private VRectangle measurementAreaVRec;
private static Logger logger = Logger.getLogger(PedestrianCrossingTimeProcessor.class); private static Logger logger = Logger.getLogger(PedestrianCrossingTimeProcessor.class);
public PedestrianCrossingTimeProcessor() { public PedestrianCrossingTimeProcessor() {
...@@ -38,9 +41,9 @@ public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdK ...@@ -38,9 +41,9 @@ public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdK
PedestrianIdKey key = new PedestrianIdKey(ped.getId()); PedestrianIdKey key = new PedestrianIdKey(ped.getId());
for(FootStep footStep : ped.getFootSteps()) { for(FootStep footStep : ped.getFootSteps()) {
if(footStep.intersects(measurementArea.asVRectangle())) { if(footStep.intersects(measurementAreaVRec)) {
double intersectionTime = footStep.computeIntersectionTime(measurementArea.asVRectangle()); double intersectionTime = footStep.computeIntersectionTime(measurementAreaVRec);
if(!hasCrossStartTime(key)) { if(!hasCrossStartTime(key)) {
setStartTime(key, intersectionTime); setStartTime(key, intersectionTime);
} }
...@@ -83,7 +86,7 @@ public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdK ...@@ -83,7 +86,7 @@ public class PedestrianCrossingTimeProcessor extends DataProcessor<PedestrianIdK
throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getMeasurementAreaId())); throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getMeasurementAreaId()));
if (!measurementArea.isRectangular()) if (!measurementArea.isRectangular())
throw new RuntimeException("DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas."); throw new RuntimeException("DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas.");
measurementAreaVRec = measurementArea.asVRectangle();
} }
......
...@@ -11,6 +11,7 @@ import org.vadere.state.scenario.MeasurementArea; ...@@ -11,6 +11,7 @@ import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.factory.processors.Flag; import org.vadere.util.factory.processors.Flag;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -21,6 +22,7 @@ import java.util.List; ...@@ -21,6 +22,7 @@ import java.util.List;
@DataProcessorClass() @DataProcessorClass()
public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianIdKey, Double> implements UsesMeasurementArea { public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianIdKey, Double> implements UsesMeasurementArea {
private MeasurementArea waitingArea; private MeasurementArea waitingArea;
private VRectangle waitingAreaVRec;
public PedestrianWaitingEndTimeProcessor() { public PedestrianWaitingEndTimeProcessor() {
super("waitingEndTime"); super("waitingEndTime");
...@@ -34,7 +36,7 @@ public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianI ...@@ -34,7 +36,7 @@ public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianI
int pedId = p.getId(); int pedId = p.getId();
VPoint pos = p.getPosition(); VPoint pos = p.getPosition();
if (this.waitingArea.asVRectangle().contains(pos)) { if (this.waitingAreaVRec.contains(pos)) {
PedestrianIdKey key = new PedestrianIdKey(pedId); PedestrianIdKey key = new PedestrianIdKey(pedId);
this.putValue(key, state.getSimTimeInSec()); this.putValue(key, state.getSimTimeInSec());
} }
...@@ -50,7 +52,7 @@ public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianI ...@@ -50,7 +52,7 @@ public class PedestrianWaitingEndTimeProcessor extends DataProcessor<PedestrianI
throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getWaitingAreaId())); throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getWaitingAreaId()));
if (!waitingArea.isRectangular()) if (!waitingArea.isRectangular())
throw new RuntimeException("DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas."); throw new RuntimeException("DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas.");
waitingAreaVRec = waitingArea.asVRectangle();
} }
@Override @Override
......
...@@ -11,6 +11,7 @@ import org.vadere.state.scenario.MeasurementArea; ...@@ -11,6 +11,7 @@ import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.factory.processors.Flag; import org.vadere.util.factory.processors.Flag;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -22,6 +23,7 @@ import java.util.List; ...@@ -22,6 +23,7 @@ import java.util.List;
public class PedestrianWaitingTimeProcessor extends DataProcessor<PedestrianIdKey, Double> implements UsesMeasurementArea { public class PedestrianWaitingTimeProcessor extends DataProcessor<PedestrianIdKey, Double> implements UsesMeasurementArea {
private double lastSimTime; private double lastSimTime;
private MeasurementArea waitingArea; private MeasurementArea waitingArea;
private VRectangle waitingAreaRec;
public PedestrianWaitingTimeProcessor() { public PedestrianWaitingTimeProcessor() {
super("waitingTimeStart"); super("waitingTimeStart");
...@@ -39,7 +41,7 @@ public class PedestrianWaitingTimeProcessor extends DataProcessor<PedestrianIdKe ...@@ -39,7 +41,7 @@ public class PedestrianWaitingTimeProcessor extends DataProcessor<PedestrianIdKe
int pedId = p.getId(); int pedId = p.getId();
VPoint pos = p.getPosition(); VPoint pos = p.getPosition();
if (this.waitingArea.asVRectangle().contains(pos)) { if (this.waitingAreaRec.contains(pos)) {
PedestrianIdKey key = new PedestrianIdKey(pedId); PedestrianIdKey key = new PedestrianIdKey(pedId);
this.putValue(key, (this.hasValue(key) ? this.getValue(key) : 0.0) + dt); this.putValue(key, (this.hasValue(key) ? this.getValue(key) : 0.0) + dt);
} }
...@@ -57,7 +59,7 @@ public class PedestrianWaitingTimeProcessor extends DataProcessor<PedestrianIdKe ...@@ -57,7 +59,7 @@ public class PedestrianWaitingTimeProcessor extends DataProcessor<PedestrianIdKe
throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getWaitingAreaId())); throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", att.getWaitingAreaId()));
if (!waitingArea.isRectangular()) if (!waitingArea.isRectangular())
throw new RuntimeException("DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas."); throw new RuntimeException("DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas.");
waitingAreaRec = waitingArea.asVRectangle();
this.lastSimTime = 0.0; this.lastSimTime = 0.0;
} }
......
{ {
"name" : "TopographyCheckerTest", "name" : "TopographyCheckerTest",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "warning: no commit hash", "commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "Test1", "name" : "Test1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f", "commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "Test1", "name" : "Test1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f", "commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "Test2", "name" : "Test2",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f", "commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "Test1", "name" : "Test1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f", "commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "Test1", "name" : "Test1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f", "commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "Test2", "name" : "Test2",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f", "commithash" : "c45f1d26328baaec22418c15e6351a059e910f5f",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "basic_1_chicken_osm1", "name" : "basic_1_chicken_osm1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "warning: no commit hash", "commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
...@@ -172,4 +172,4 @@ ...@@ -172,4 +172,4 @@
"attributesCar" : null "attributesCar" : null
} }
} }
} }
\ No newline at end of file
{ {
"name" : "test_postvis", "name" : "test_postvis",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "warning: no commit hash", "commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "test_postvis", "name" : "test_postvis",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "warning: no commit hash", "commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
......
{ {
"name" : "test_postvis", "name" : "test_postvis",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "warning: no commit hash", "commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ {