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 7d4bf084 authored by Marion Goedel's avatar Marion Goedel
Browse files

Merge branch 'develop' of https://gitlab.lrz.de/vadere/vadere into develop

parents edb8ac2e 4e62c7b4
...@@ -65,13 +65,11 @@ public class OfflineTopographyController { ...@@ -65,13 +65,11 @@ public class OfflineTopographyController {
protected void recomputeCells() { protected void recomputeCells() {
this.topography.getSpatialMap(Pedestrian.class).clear(); this.topography.getSpatialMap(Pedestrian.class).clear();
for (Pedestrian pedestrian : this.topography.getElements(Pedestrian.class)) { for (Pedestrian pedestrian : this.topography.getElements(Pedestrian.class)) {
this.topography.getSpatialMap(Pedestrian.class).addObject(pedestrian, this.topography.getSpatialMap(Pedestrian.class).addObject(pedestrian);
pedestrian.getPosition());
} }
this.topography.getSpatialMap(Car.class).clear(); this.topography.getSpatialMap(Car.class).clear();
for (Car car : this.topography.getElements(Car.class)) { for (Car car : this.topography.getElements(Car.class)) {
this.topography.getSpatialMap(Car.class).addObject(car, this.topography.getSpatialMap(Car.class).addObject(car);
car.getPosition());
} }
} }
} }
...@@ -26,6 +26,7 @@ import java.util.Random; ...@@ -26,6 +26,7 @@ import java.util.Random;
public abstract class SourceController { public abstract class SourceController {
protected final double NO_EVENT = Double.MAX_VALUE; protected final double NO_EVENT = Double.MAX_VALUE;
private final double SPAWN_BUFFER_SIZE = 0.001;
protected final Source source; protected final Source source;
private final DynamicElementFactory dynamicElementFactory; private final DynamicElementFactory dynamicElementFactory;
...@@ -52,7 +53,7 @@ public abstract class SourceController { ...@@ -52,7 +53,7 @@ public abstract class SourceController {
this.topography = scenario; this.topography = scenario;
this.random = random; this.random = random;
this.spawnArray = new SpawnArray(new VRectangle(source.getShape().getBounds2D()), this.spawnArray = new SpawnArray(new VRectangle(source.getShape().getBounds2D()),
new VRectangle(0, 0, getDynamicElementShape().getRadius() * 2, getDynamicElementShape().getRadius() * 2)); new VRectangle(0, 0, (getDynamicElementShape().getRadius()) * 2 + SPAWN_BUFFER_SIZE, (getDynamicElementShape().getRadius()) * 2 + SPAWN_BUFFER_SIZE));
timeOfNextEvent = sourceAttributes.getStartTime(); timeOfNextEvent = sourceAttributes.getStartTime();
try { try {
......
...@@ -104,16 +104,16 @@ public class PedestrianOSM extends Pedestrian { ...@@ -104,16 +104,16 @@ public class PedestrianOSM extends Pedestrian {
switch (updateType) { switch (updateType) {
case EVENT_DRIVEN: case EVENT_DRIVEN:
result = new UpdateSchemeEventDriven(pedestrian); result = new UpdateSchemeEventDriven(pedestrian, pedestrian.topography);
break; break;
case PARALLEL: case PARALLEL:
result = new UpdateSchemeParallel(pedestrian); result = new UpdateSchemeParallel(pedestrian);
break; break;
case SEQUENTIAL: case SEQUENTIAL:
result = new UpdateSchemeSequential(pedestrian); result = new UpdateSchemeSequential(pedestrian, pedestrian.topography);
break; break;
default: default:
result = new UpdateSchemeSequential(pedestrian); result = new UpdateSchemeSequential(pedestrian, pedestrian.topography);
} }
return result; return result;
......
package org.vadere.simulator.models.osm.updateScheme; package org.vadere.simulator.models.osm.updateScheme;
import org.vadere.simulator.models.osm.PedestrianOSM; import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
public class UpdateSchemeEventDriven implements UpdateSchemeOSM { public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
private final PedestrianOSM pedestrian; private final PedestrianOSM pedestrian;
private final Topography topography;
public UpdateSchemeEventDriven(PedestrianOSM pedestrian) { public UpdateSchemeEventDriven(PedestrianOSM pedestrian, Topography topography) {
this.pedestrian = pedestrian; this.pedestrian = pedestrian;
this.topography = topography;
} }
@Override @Override
public void update(double timeStepInSec, double currentTimeInSec, CallMethod callMethod) { public void update(double timeStepInSec, double currentTimeInSec, CallMethod callMethod) {
VPoint oldPosition = pedestrian.getPosition();
// for the first step after creation, timeOfNextStep has to be initialized // for the first step after creation, timeOfNextStep has to be initialized
if (pedestrian.getTimeOfNextStep() == 0) { if (pedestrian.getTimeOfNextStep() == 0) {
pedestrian.setTimeOfNextStep(currentTimeInSec); pedestrian.setTimeOfNextStep(currentTimeInSec);
...@@ -22,6 +28,8 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM { ...@@ -22,6 +28,8 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
pedestrian.updateNextPosition(); pedestrian.updateNextPosition();
pedestrian.makeStep(pedestrian.getDurationNextStep()); pedestrian.makeStep(pedestrian.getDurationNextStep());
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep()); pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
topography.moveElement(pedestrian, oldPosition);
} }
} }
package org.vadere.simulator.models.osm.updateScheme; package org.vadere.simulator.models.osm.updateScheme;
import org.vadere.simulator.models.osm.PedestrianOSM; import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
public class UpdateSchemeSequential implements UpdateSchemeOSM { public class UpdateSchemeSequential implements UpdateSchemeOSM {
private final PedestrianOSM pedestrian; private final PedestrianOSM pedestrian;
private final Topography topography;
public UpdateSchemeSequential(PedestrianOSM pedestrian) { public UpdateSchemeSequential(PedestrianOSM pedestrian, Topography topography) {
this.pedestrian = pedestrian; this.pedestrian = pedestrian;
this.topography = topography;
} }
@Override @Override
public void update(double timeStepInSec, double currentTimeInSec, CallMethod callMethod) { public void update(double timeStepInSec, double currentTimeInSec, CallMethod callMethod) {
VPoint oldPosition = pedestrian.getPosition();
pedestrian.setTimeCredit(pedestrian.getTimeCredit() + timeStepInSec); pedestrian.setTimeCredit(pedestrian.getTimeCredit() + timeStepInSec);
pedestrian.setDurationNextStep(pedestrian.getStepSize() / pedestrian.getDesiredSpeed()); pedestrian.setDurationNextStep(pedestrian.getStepSize() / pedestrian.getDesiredSpeed());
...@@ -20,5 +26,7 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM { ...@@ -20,5 +26,7 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
pedestrian.makeStep(timeStepInSec); pedestrian.makeStep(timeStepInSec);
pedestrian.setDurationNextStep(pedestrian.getStepSize() / pedestrian.getDesiredSpeed()); pedestrian.setDurationNextStep(pedestrian.getStepSize() / pedestrian.getDesiredSpeed());
} }
topography.moveElement(pedestrian, oldPosition);
} }
} }
...@@ -66,18 +66,10 @@ public class PotentialFieldPedestrianCompact implements PotentialFieldAgent { ...@@ -66,18 +66,10 @@ public class PotentialFieldPedestrianCompact implements PotentialFieldAgent {
public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea, public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea,
Agent pedestrian, Topography scenario) { Agent pedestrian, Topography scenario) {
List<Pedestrian> result = new LinkedList<>();
// select pedestrians within recognition distance // select pedestrians within recognition distance
List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class) return scenario.getSpatialMap(Pedestrian.class)
.getObjects(relevantArea.getCenter(), this.width + pedestrian.getRadius() + .getObjects(relevantArea.getCenter(), this.width + pedestrian.getRadius() +
attributes.getVisionFieldRadius()); attributes.getVisionFieldRadius());
result = closePedestrians;
return result;
} }
@Override @Override
......
...@@ -3,6 +3,7 @@ package org.vadere.simulator.models.potential; ...@@ -3,6 +3,7 @@ package org.vadere.simulator.models.potential;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors;
import org.vadere.simulator.models.Model; import org.vadere.simulator.models.Model;
import org.vadere.annotation.factories.models.ModelClass; import org.vadere.annotation.factories.models.ModelClass;
...@@ -40,16 +41,16 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA ...@@ -40,16 +41,16 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA
} }
@Override @Override
public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea, public Collection<Pedestrian> getRelevantAgents(VCircle maxStepCircle,
Agent pedestrian, Topography scenario) { Agent pedestrian, Topography scenario) {
List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class) List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class).getObjects(maxStepCircle.getCenter(),
.getObjects(relevantArea.getCenter(), this.personalWidth + 0.5); this.personalWidth + maxStepCircle.getRadius() + pedestrian.getRadius());
return closePedestrians; return closePedestrians;
} }
@Override @Override
public double getAgentPotential(VPoint pos, Agent pedestrian, public double getAgentPotential(VPoint pos, Agent pedestrian,
Agent otherPedestrian) { Agent otherPedestrian) {
double radii = pedestrian.getRadius() + otherPedestrian.getRadius(); // 2* r_p (sivers-2016b) double radii = pedestrian.getRadius() + otherPedestrian.getRadius(); // 2* r_p (sivers-2016b)
double potential = 0; double potential = 0;
...@@ -81,6 +82,39 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA ...@@ -81,6 +82,39 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA
} }
/*
@Override
public double getAgentPotential(VPoint pos, Agent pedestrian,
Agent otherPedestrian) {
double radii = pedestrian.getRadius() + otherPedestrian.getRadius(); // 2* r_p (sivers-2016b)
double potential = 0;
double distanceSq = otherPedestrian.getPosition().distanceSq(pos);
double maxDistanceSq = (Math.max(personalWidth, intimateWidth) + pedestrian.getRadius()) * (Math.max(personalWidth, intimateWidth) + pedestrian.getRadius());
if (distanceSq < maxDistanceSq) {
double distance = otherPedestrian.getPosition().distance(pos); // Euclidean distance d_j(x) between agent j and position x
int intPower = this.attributes.getIntimateSpacePower(); // b_p
int perPower = this.attributes.getPersonalSpacePower(); // not defined in sivers-2016b (perPower = 1)
double factor = this.attributes.getIntimateSpaceFactor(); // a_p
if (distance < personalWidth + otherPedestrian.getRadius()) {
// implementation differs from sivers-2016b here: \delta_{per} + r_p (note: radii = 2*r_p)
potential += this.height * Math.exp(4 / (Math.pow(distance / (personalWidth + radii), (2 * perPower)) - 1));
}
if (distance < this.intimateWidth + otherPedestrian.getRadius()) {
// implementation differs from sivers-2016b here: \delta_{int} + r_p (note: radii = 2*r_p)
potential += this.height / factor
* Math.exp(4 / (Math.pow(distance / (this.intimateWidth + pedestrian.getRadius()), (2 * intPower)) - 1));
}
if (distance < radii) {
// implementations differs from sivers-2016b here : Math.power(distance / (radii),2)
potential += 1000 * Math.exp(1 / (Math.pow(distance / pedestrian.getRadius(), 2) - 1));
}
}
return potential;
}*/
@Override @Override
public double getAgentPotential(VPoint pos, Agent pedestrian, public double getAgentPotential(VPoint pos, Agent pedestrian,
Collection<? extends Agent> otherPedestrians) { Collection<? extends Agent> otherPedestrians) {
......
...@@ -66,11 +66,9 @@ public class PotentialFieldPedestrianOSM implements PotentialFieldAgent { ...@@ -66,11 +66,9 @@ public class PotentialFieldPedestrianOSM implements PotentialFieldAgent {
@Override @Override
public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea, public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea,
Agent pedestrian, Topography scenario) { Agent pedestrian, Topography scenario) {
List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class) return scenario.getSpatialMap(Pedestrian.class)
.getObjects(relevantArea.getCenter(), .getObjects(relevantArea.getCenter(),
attributes.getPedestrianRecognitionDistance()); attributes.getPedestrianRecognitionDistance());
return closePedestrians;
} }
@Override @Override
......
package org.vadere.simulator.projects.dataprocessing.processor; package org.vadere.simulator.projects.dataprocessing.processor;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
...@@ -16,6 +18,7 @@ import java.util.Collection; ...@@ -16,6 +18,7 @@ import java.util.Collection;
*/ */
@DataProcessorClass() @DataProcessorClass()
public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdKey, Integer> { public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdKey, Integer> {
private static Logger logger = LogManager.getLogger(PedestrianOverlapProcessor.class);
private double pedRadius; private double pedRadius;
...@@ -42,7 +45,8 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian ...@@ -42,7 +45,8 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
} }
private int calculateOverlaps(final Collection<Pedestrian> peds, VPoint pos) { private int calculateOverlaps(final Collection<Pedestrian> peds, VPoint pos) {
return (int) peds.stream().filter(p -> p.getPosition().distance(pos) <= 2 * this.pedRadius).count() - 1; long overlap = peds.stream().filter(p -> p.getPosition().distance(pos) <= 2 * this.pedRadius).count() - 1;
return (int)overlap;
} }
@Override @Override
......
...@@ -4,10 +4,12 @@ import java.awt.geom.RectangularShape; ...@@ -4,10 +4,12 @@ import java.awt.geom.RectangularShape;
import java.util.*; import java.util.*;
import org.vadere.util.geometry.LinkedCellsGrid; import org.vadere.util.geometry.LinkedCellsGrid;
import org.vadere.util.geometry.shapes.VPoint;
public class DynamicElementContainer<T extends DynamicElement> { public class DynamicElementContainer<T extends DynamicElement> {
private transient final List<DynamicElementAddListener<T>> addListener; private transient final List<DynamicElementAddListener<T>> addListener;
private transient final List<DynamicElementRemoveListener<T>> removeListener; private transient final List<DynamicElementRemoveListener<T>> removeListener;
private transient final List<DynamicElementMoveListener<T>> moveListener;
private final Map<Integer, T> elementMap; private final Map<Integer, T> elementMap;
...@@ -32,6 +34,7 @@ public class DynamicElementContainer<T extends DynamicElement> { ...@@ -32,6 +34,7 @@ public class DynamicElementContainer<T extends DynamicElement> {
this.addListener = new LinkedList<>(); this.addListener = new LinkedList<>();
this.removeListener = new LinkedList<>(); this.removeListener = new LinkedList<>();
this.moveListener = new LinkedList<>();
} }
public LinkedCellsGrid<T> getCellsElements() { public LinkedCellsGrid<T> getCellsElements() {
...@@ -56,13 +59,21 @@ public class DynamicElementContainer<T extends DynamicElement> { ...@@ -56,13 +59,21 @@ public class DynamicElementContainer<T extends DynamicElement> {
public void addElement(T element) { public void addElement(T element) {
this.elementMap.put(element.getId(), element); this.elementMap.put(element.getId(), element);
this.cellsElements.addObject(element, element.getPosition()); this.cellsElements.addObject(element);
for (DynamicElementAddListener<T> listener : addListener) { for (DynamicElementAddListener<T> listener : addListener) {
listener.elementAdded(element); listener.elementAdded(element);
} }
} }
public void moveElement(T element, VPoint oldPosition) {
this.cellsElements.moveObject(element, oldPosition);
for (DynamicElementMoveListener<T> listener : moveListener) {
listener.elementMove(element);
}
}
public void removeElement(T element) { public void removeElement(T element) {
this.elementMap.remove(element.getId()); this.elementMap.remove(element.getId());
this.cellsElements.removeObject(element); this.cellsElements.removeObject(element);
......
package org.vadere.state.scenario;
/**
* @Benedikt Zoennchen
*/
public interface DynamicElementMoveListener<T extends DynamicElement> {
public void elementMove(T element);
}
...@@ -220,6 +220,10 @@ public class Topography { ...@@ -220,6 +220,10 @@ public class Topography {
((DynamicElementContainer<T>) getContainer(element.getClass())).removeElement(element); ((DynamicElementContainer<T>) getContainer(element.getClass())).removeElement(element);
} }
public <T extends DynamicElement> void moveElement(T element, final VPoint oldPosition) {
((DynamicElementContainer<T>) getContainer(element.getClass())).moveElement(element, oldPosition);
}
public List<Source> getSources() { public List<Source> getSources() {
return sources; return sources;
} }
......
package org.vadere.util.geometry; package org.vadere.util.geometry;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
...@@ -14,75 +15,19 @@ import org.vadere.util.geometry.shapes.VPoint; ...@@ -14,75 +15,19 @@ import org.vadere.util.geometry.shapes.VPoint;
/** /**
* A grid augmenting the position of generic objects, for faster access. O(1) * A grid augmenting the position of generic objects, for faster access. O(1)
* instead of O(n) for one fixed radius check. See * instead of O(n) for one fixed radius check. See
* {@link LinkedCellsGrid#getObjects(java.awt.geometry.shapes.VPoint, double)}. * {@link LinkedCellsGrid#getObjects(VPoint, double)}.
* *
* *
*/ */
public class LinkedCellsGrid<T> implements Iterable<T> { public class LinkedCellsGrid<T extends PointPositioned> implements Iterable<T> {
/**
* Key value pair holding an object with its assigned position.
*
*
*/
private class ObjectWithPosition<U> {
U object;
VPoint position;
public ObjectWithPosition(U object, VPoint pos) {
this.object = object;
this.position = pos;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((object == null) ? 0 : object.hashCode());
result = prime * result
+ ((position == null) ? 0 : position.hashCode());
return result;
}
@SuppressWarnings("unchecked")
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ObjectWithPosition<U> other = (ObjectWithPosition<U>) obj;
if (object == null) {
if (other.object != null) {
return false;
}
} else if (!object.equals(other.object)) {
return false;
}
if (position == null) {
if (other.position != null) {
return false;
}
} else if (!position.equals(other.position)) {
return false;
}
return true;
}
}
final private double left; final private double left;
final private double top; final private double top;
final private double width; final private double width;
final private double height; final private double height;
private GridCell<T>[][] grid; private GridCell<T>[][] grid;
private List<ObjectWithPosition<T>> totalObjects = new LinkedList<ObjectWithPosition<T>>();
private int[] gridSize = new int[2]; private int[] gridSize = new int[2];
private double[] cellSize = new double[2]; private double[] cellSize = new double[2];
private int size;
/** /**
* One cell in the grid. It contains a mapping from points to lists of * One cell in the grid. It contains a mapping from points to lists of
...@@ -92,8 +37,8 @@ public class LinkedCellsGrid<T> implements Iterable<T> { ...@@ -92,8 +37,8 @@ public class LinkedCellsGrid<T> implements Iterable<T> {
* @param <E> * @param <E>
* type of objects stored in this cell. * type of objects stored in this cell.
*/ */
private class GridCell<E> { private class GridCell<E extends PointPositioned> {
public Map<VPoint, List<E>> objects = new HashMap<VPoint, List<E>>(); public List<E> objects = new ArrayList<>();