Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 2c720570 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

udpate VTrajectory and the processor using it.

parent 7cf7f9c2
......@@ -226,6 +226,9 @@
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"type" : "PEDESTRIAN",
"groupSizes" : [ ]
} ],
......
......@@ -353,6 +353,9 @@
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"type" : "PEDESTRIAN",
"groupSizes" : [ ]
}, {
......@@ -383,6 +386,9 @@
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"type" : "PEDESTRIAN",
"groupSizes" : [ ]
} ],
......
......@@ -297,6 +297,9 @@
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"type" : "PEDESTRIAN",
"groupSizes" : [ ]
}, {
......@@ -327,6 +330,9 @@
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"type" : "PEDESTRIAN",
"groupSizes" : [ ]
} ],
......
......@@ -585,6 +585,9 @@
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"type" : "PEDESTRIAN",
"groupSizes" : [ ]
}, {
......@@ -615,6 +618,9 @@
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"type" : "PEDESTRIAN",
"groupSizes" : [ ]
} ],
......
......@@ -8,7 +8,6 @@ import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramBProcessor;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramAProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.simulation.VTrajectory;
import org.vadere.util.geometry.shapes.VRectangle;
......@@ -55,7 +54,7 @@ public class PedestrianFundamentalDiagramBProcessor extends DataProcessor<Pedest
@Override
public AttributesProcessor getAttributes() {
if (super.getAttributes() == null) {
setAttributes(new AttributesFundamentalDiagramAProcessor());
setAttributes(new AttributesFundamentalDiagramBProcessor());
}
return super.getAttributes();
}
......@@ -83,8 +82,7 @@ public class PedestrianFundamentalDiagramBProcessor extends DataProcessor<Pedest
for(Map.Entry<PedestrianIdKey, VTrajectory> trajectoryEntry : trajectoryMap.entrySet()) {
PedestrianIdKey key = trajectoryEntry.getKey();
VTrajectory trajectory = trajectoryEntry.getValue();
VTrajectory clone = trajectory.clone();
clone.cut(measurementArea);
VTrajectory clone = trajectory.cut(measurementArea);
cutTrajectoryMap.put(key, clone);
}
......@@ -94,22 +92,31 @@ public class PedestrianFundamentalDiagramBProcessor extends DataProcessor<Pedest
for(Map.Entry<PedestrianIdKey, VTrajectory> trajectoryEntry : cutTrajectoryMap.entrySet()) {
PedestrianIdKey key = trajectoryEntry.getKey();
VTrajectory trajectory = trajectoryEntry.getValue();
double density = density(key, cutTrajectoryMap);
double velocity = trajectory.speed().orElse(0.0);
putValue(key, Pair.of(velocity, density));
if(!trajectory.isEmpty()) {
double density = density(key, cutTrajectoryMap);
double velocity = trajectory.speed().orElse(0.0);
putValue(key, Pair.of(velocity, density));
}
}
}
private double density(@NotNull final PedestrianIdKey key, @NotNull final Map<PedestrianIdKey, VTrajectory> cutTrajectoryMap) {
VTrajectory pedTrajectory = cutTrajectoryMap.get(key);
double duration = pedTrajectory.duration();
List<VTrajectory> sortedTrajectories = cutTrajectoryMap.values()
double densityIntegral = cutTrajectoryMap.values()
.stream()
.filter(trajectory -> trajectory.isInBetween(pedTrajectory))
.sorted(Comparator.comparingDouble(t -> t.getStartTime().get()))
.collect(Collectors.toList());
.map(trajectory -> trajectory.cut(pedTrajectory.getStartTime().get(), pedTrajectory.getEndTime().get()))
.filter(trajectory -> !trajectory.isEmpty())
//.filter(trajectory -> trajectory.isInBetween(pedTrajectory))
//.sorted(Comparator.comparingDouble(t -> t.getStartTime().get()))
.mapToDouble(trajectory -> (trajectory.getEndTime().get() - trajectory.getStartTime().get()))
.sum();
densityIntegral /= duration;
densityIntegral /= measurementArea.getArea();
return densityIntegral;
List<Triple<Double, Double, Integer>> integralValues = new LinkedList<>();
/*List<Triple<Double, Double, Integer>> integralValues = new LinkedList<>();
double start;
double end;
......@@ -124,7 +131,7 @@ public class PedestrianFundamentalDiagramBProcessor extends DataProcessor<Pedest
VTrajectory next = hasNext ? sortedTrajectories.get(i+1) : null;
double nextStartTime = hasNext ? next.getStartTime().get() : -1.0;
while(hasNext && integralElements.peek().getEndTime().get() <= nextStartTime) {
while(!integralElements.isEmpty() && (!hasNext || integralElements.peek().getEndTime().get() <= nextStartTime)) {
double endTime = integralElements.peek().getEndTime().get();
end = endTime;
integralValues.add(Triple.of(start, end, integralElements.size()));
......@@ -136,8 +143,8 @@ public class PedestrianFundamentalDiagramBProcessor extends DataProcessor<Pedest
end = nextStartTime;
integralValues.add(Triple.of(start, end, integralElements.size()));
integralElements.add(next);
i++;
}
i++;
}
double densityIntegral = 0.0;
......@@ -145,11 +152,11 @@ public class PedestrianFundamentalDiagramBProcessor extends DataProcessor<Pedest
double tStart = entry.getLeft();
double tEnd = entry.getMiddle();
int N = entry.getRight();
densityIntegral = N * (tEnd - tStart);
densityIntegral += (N * (tEnd - tStart));
}
densityIntegral /= duration;
densityIntegral /= measurementArea.getArea();
return densityIntegral;
return densityIntegral;*/
}
@Override
......
......@@ -7,7 +7,6 @@ import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramCProcessor;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramAProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.util.geometry.shapes.VRectangle;
......@@ -41,7 +40,7 @@ public class PedestrianFundamentalDiagramCProcessor extends AreaDataProcessor<Pa
@Override
public AttributesProcessor getAttributes() {
if (super.getAttributes() == null) {
setAttributes(new AttributesFundamentalDiagramAProcessor());
setAttributes(new AttributesFundamentalDiagramCProcessor());
}
return super.getAttributes();
}
......
......@@ -7,7 +7,6 @@ import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramDProcessor;
import org.vadere.state.attributes.processor.AttributesFundamentalDiagramAProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.util.geometry.shapes.VRectangle;
......@@ -44,7 +43,7 @@ public class PedestrianFundamentalDiagramDProcessor extends AreaDataProcessor<Pa
@Override
public AttributesProcessor getAttributes() {
if (super.getAttributes() == null) {
setAttributes(new AttributesFundamentalDiagramAProcessor());
setAttributes(new AttributesFundamentalDiagramDProcessor());
}
return super.getAttributes();
}
......
......@@ -3,7 +3,6 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.state.attributes.processor.AttributesPedestrianLineCrossProcessor;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.simulation.VTrajectory;
import org.vadere.state.util.StateJsonConverter;
......@@ -25,7 +24,6 @@ public class PedestrianTrajectoryProcessor extends DataProcessor<PedestrianIdKey
public PedestrianTrajectoryProcessor() {
super("trajectory");
setAttributes(new AttributesPedestrianLineCrossProcessor());
}
@Override
......@@ -34,7 +32,7 @@ public class PedestrianTrajectoryProcessor extends DataProcessor<PedestrianIdKey
for(Pedestrian ped : peds) {
PedestrianIdKey key = new PedestrianIdKey(ped.getId());
ped.getFootSteps().concat(getValue(key));
getValue(key).concat(ped.getFootSteps());
}
}
......
......@@ -73,7 +73,7 @@ public final class FootStep {
}
public boolean intersects(@NotNull final VRectangle rectangle) {
return rectangle.intersects(new VLine(getStart(), getEnd()));
return GeometryUtils.intersectsRectangleBoundary(rectangle, getStart().x, getStart().y, getEnd().x, getEnd().y);
}
public boolean intersects(@NotNull final VLine line) {
......@@ -91,7 +91,7 @@ public final class FootStep {
VPoint vector = end.subtract(start);
double duration = duration();
double portion = simTimeInSec - startTime;
VPoint portionStep = vector.norm(portion / duration);
VPoint portionStep = vector.scalarMultiply(portion / duration);
VPoint middle = start.add(portionStep);
......
......@@ -84,13 +84,17 @@ public class VTrajectory implements Iterable<FootStep> {
footSteps.add(footStep);
}
public void cut(@NotNull final VRectangle rectangle) {
public VTrajectory cut(@NotNull final VRectangle rectangle) {
List<FootStep> intersectionSteps = footSteps.stream().filter(footStep -> footStep.intersects(rectangle)).collect(Collectors.toList());
if(intersectionSteps.size() == 2) {
double startSimTime = intersectionSteps.get(0).computeIntersectionTime(rectangle);
double endSimTime = intersectionSteps.get(1).computeIntersectionTime(rectangle);
cut(startSimTime, endSimTime);
return cut(startSimTime, endSimTime);
}
else if(intersectionSteps.size() > 0) {
throw new IllegalArgumentException("the number of intersection points is not zero or 2.");
}
return this;
}
public void cutHead(final double simTimeInSec) {
......@@ -98,7 +102,7 @@ public class VTrajectory implements Iterable<FootStep> {
footSteps.removeFirst();
}
if(footSteps.peekFirst().getStartTime() < simTimeInSec) {
if(!footSteps.isEmpty() && footSteps.peekFirst().getStartTime() < simTimeInSec) {
FootStep footStep = footSteps.removeFirst();
footSteps.addFirst(footStep.cut(simTimeInSec).getRight());
}
......@@ -106,11 +110,11 @@ public class VTrajectory implements Iterable<FootStep> {
}
public void cutTail(final double simTimeInSec) {
while (!footSteps.isEmpty() && footSteps.peekLast().getStartTime() > simTimeInSec) {
while (!footSteps.isEmpty() && footSteps.peekLast().getStartTime() >= simTimeInSec) {
footSteps.removeLast();
}
if(footSteps.peekLast().getEndTime() > simTimeInSec) {
if(!footSteps.isEmpty() && footSteps.peekLast().getEndTime() > simTimeInSec) {
FootStep footStep = footSteps.removeLast();
footSteps.addLast(footStep.cut(simTimeInSec).getLeft());
}
......@@ -118,7 +122,7 @@ public class VTrajectory implements Iterable<FootStep> {
public void concat(@NotNull final VTrajectory trajectory) {
for (FootStep footStep : trajectory) {
if(footStep.getStartTime() >= footSteps.peekLast().getEndTime()) {
if(isEmpty() || (footStep.getStartTime() >= footSteps.peekLast().getEndTime())) {
footSteps.addLast(footStep);
}
}
......
......@@ -87,6 +87,13 @@ public class GeometryUtils {
return Optional.empty();
}
public static boolean intersectsRectangleBoundary(@NotNull final VRectangle rectangle, double x1, double y1, double x2, double y2) {
return intersectLineSegment(rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y, x1, y1, x2, y2) ||
intersectLineSegment(rectangle.x, rectangle.y, rectangle.x, rectangle.y + rectangle.height, x1, y1, x2, y2) ||
intersectLineSegment(rectangle.x + rectangle.width, rectangle.y, rectangle.x + rectangle.width, rectangle.y + rectangle.height, x1, y1, x2, y2) ||
intersectLineSegment(rectangle.x, rectangle.y + rectangle.height, rectangle.x + rectangle.width, rectangle.y + rectangle.height, x1, y1, x2, y2);
}
//http://mathworld.wolfram.com/Line-LineIntersection.html
public static VPoint intersectionPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
double a = derterminant2D(x1, x2, y1, y2);
......
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