Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 1cb60daf authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

quick fix to avoid significant overlaps.

parent 294bec0b
......@@ -26,6 +26,7 @@ import java.util.Random;
public abstract class SourceController {
protected final double NO_EVENT = Double.MAX_VALUE;
private final double SPAWN_BUFFER_SIZE = 0.001;
protected final Source source;
private final DynamicElementFactory dynamicElementFactory;
......@@ -52,7 +53,7 @@ public abstract class SourceController {
this.topography = scenario;
this.random = random;
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();
try {
......
......@@ -67,11 +67,12 @@ public class PotentialFieldPedestrianCompact implements PotentialFieldAgent {
Agent pedestrian, Topography scenario) {
List<Pedestrian> result = new LinkedList<>();
final double maxWalkedDistanceInSimTime = 0.4 * 3; // quick fix 0.4 = simtime, 3 = max velocity.
// select pedestrians within recognition distance
List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class)
.getObjects(relevantArea.getCenter(), this.width + pedestrian.getRadius() +
attributes.getVisionFieldRadius());
attributes.getVisionFieldRadius() + maxWalkedDistanceInSimTime);
result = closePedestrians;
......
......@@ -3,6 +3,7 @@ package org.vadere.simulator.models.potential;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import org.vadere.simulator.models.Model;
import org.vadere.annotation.factories.models.ModelClass;
......@@ -40,16 +41,18 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA
}
@Override
public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea,
public Collection<Pedestrian> getRelevantAgents(VCircle maxStepCircle,
Agent pedestrian, Topography scenario) {
List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class)
.getObjects(relevantArea.getCenter(), this.personalWidth + 0.5);
final double maxWalkedDistanceInSimTime = 0.4 * 3; // quick fix 0.4 = simtime, 3 = max velocity.
List<Pedestrian> closePedestrians = scenario.getElements(Pedestrian.class)
.stream().filter(p -> p.getPosition().distance(maxStepCircle.getCenter()) <= this.personalWidth + maxStepCircle.getRadius() + maxWalkedDistanceInSimTime + pedestrian.getRadius()).collect(Collectors.toList());
return closePedestrians;
}
@Override
public double getAgentPotential(VPoint pos, Agent pedestrian,
Agent otherPedestrian) {
Agent otherPedestrian) {
double radii = pedestrian.getRadius() + otherPedestrian.getRadius(); // 2* r_p (sivers-2016b)
double potential = 0;
......@@ -81,6 +84,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
public double getAgentPotential(VPoint pos, Agent pedestrian,
Collection<? extends Agent> otherPedestrians) {
......
......@@ -66,9 +66,10 @@ public class PotentialFieldPedestrianOSM implements PotentialFieldAgent {
@Override
public Collection<Pedestrian> getRelevantAgents(VCircle relevantArea,
Agent pedestrian, Topography scenario) {
final double maxWalkedDistanceInSimTime = 0.4 * 3; // quick fix 0.4 = simtime, 3 = max velocity.
List<Pedestrian> closePedestrians = scenario.getSpatialMap(Pedestrian.class)
.getObjects(relevantArea.getCenter(),
attributes.getPedestrianRecognitionDistance());
attributes.getPedestrianRecognitionDistance() + maxWalkedDistanceInSimTime);
return closePedestrians;
}
......
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.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
......@@ -16,6 +18,7 @@ import java.util.Collection;
*/
@DataProcessorClass()
public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdKey, Integer> {
private static Logger logger = LogManager.getLogger(PedestrianOverlapProcessor.class);
private double pedRadius;
......@@ -42,7 +45,8 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
}
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
......
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