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 87eaa64e authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

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

parents 730beb92 ed672836
......@@ -6,7 +6,7 @@
### Added
- * Added script "osm2vadere.py" to "Tools" folder, to convert OpenStreetMap maps to a Vadere topography. (929d4775: Tools).
- Added script "osm2vadere.py" to "Tools" folder, to convert OpenStreetMap maps to a Vadere topography. (929d4775: Tools).
- `VadereConsole`: Add option `--logname <filename>` to specify the name for the log file.
Please note that the log file `log.out` is always written (because this file is configured
in the `log4j.properties` of each Vadere module (i.e., "gui", "meshing", ...). (c61a3946: Simulator)
......
package org.vadere.simulator.models;
import org.vadere.state.scenario.Pedestrian;
public interface StepSizeAdjuster {
double getAdjustedStepSize(Pedestrian ped, double originalStepSize);
}
......@@ -201,10 +201,18 @@ public class CentroidGroup implements Group {
double result;
VPoint pedLocation = ped.getPosition();
double potentialSum = 0.0;
int size = 0;
for (Pedestrian p : members) {
if (!ped.equals(p) && !isLostMember(p)) {
potentialSum += potentialFieldTarget.getPotential(p.getPosition(), p);
size++;
}
}
double pedDistance = potentialFieldTarget.getPotential(pedLocation, ped);
double centroidDistance = potentialFieldTarget.getPotential(getCentroidOthers(ped), ped);
result = centroidDistance - pedDistance;
result = (potentialSum / size) - pedDistance;
if (result > POTENTIAL_DISTANCE_THRESHOLD) {
result = 0;
......
......@@ -3,7 +3,9 @@ package org.vadere.simulator.models.groups;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.annotation.factories.models.ModelClass;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesCGM;
import org.vadere.state.attributes.scenario.AttributesAgent;
......@@ -27,14 +29,17 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
private final AttributesCGM attributesCGM;
private final CentroidGroupModel groupCollection;
private final PotentialFieldAgent potentialFieldPedestrian;
private final IPotentialFieldTarget potentialFieldTarget;
public CentroidGroupPotential(CentroidGroupModel groupCollection,
PotentialFieldAgent pedestrianRepulsionPotential,
IPotentialFieldTarget potentialFieldTarget,
AttributesCGM attributesCGM) {
this.attributesCGM = attributesCGM;
this.groupCollection = groupCollection;
this.potentialFieldPedestrian = pedestrianRepulsionPotential;
this.potentialFieldTarget = potentialFieldTarget;
}
@Override
......@@ -65,6 +70,8 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
if (leader != null) {
VPoint leaderPoint = leader.getPosition();
double leaderPotential = potentialFieldTarget.getPotential(leaderPoint, leader);
double pedPotential = potentialFieldTarget.getPotential(ped.getPosition(), ped);
final double[] distanceToCentroid = {
pos.getX() - leaderPoint.getX(),
......@@ -72,9 +79,8 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
result = attributesCGM.getLeaderAttractionFactor()
* Math.pow(
Math.pow(distanceToCentroid[0], 2)
+ Math.pow(distanceToCentroid[1], 2),
2);
leaderPotential - pedPotential,
4);
}
return result;
......@@ -111,7 +117,7 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
double potential = potentialFieldPedestrian.getAgentPotential(pos,
pedestrian, otherPedestrian);
if (group.equals(groupOther)) {
if (group != null && group.equals(groupOther)) {
potential *= attributesCGM.getGroupMemberRepulsionFactor();
}
......
package org.vadere.simulator.models.groups;
import org.vadere.simulator.models.StepSizeAdjuster;
import org.vadere.state.scenario.Pedestrian;
public class CentroidGroupStepSizeAdjuster implements StepSizeAdjuster {
private final CentroidGroupModel groupCollection;
public CentroidGroupStepSizeAdjuster(CentroidGroupModel groupCollection) {
this.groupCollection = groupCollection;
}
@Override
public double getAdjustedStepSize(Pedestrian ped, double originalStepSize) {
double result = 1.0;
double aheadDistance = 0;
CentroidGroup group = groupCollection.getGroup(ped);
if (group != null) {
aheadDistance = group.getRelativeDistanceCentroid(ped);
// TODO [priority=low] [task=refactoring] move Parameters to AttributesCGM
if (!group.isLostMember(ped)) {
if (aheadDistance > 8) {
result = Double.MIN_VALUE;
} else if (aheadDistance >= 1) {
result /= 1.0 + aheadDistance / 8 - 1 / 8 + 1;
} else if (aheadDistance >= 0) {
result /= 1.0 + Math.pow(aheadDistance, 2);
} else if (aheadDistance >= -1) {
result /= 0.75;
} else {
result /= 0.65;
}
}
}
return originalStepSize * result;
}
}
......@@ -8,10 +8,12 @@ import org.vadere.simulator.control.factory.SourceControllerFactory;
import org.vadere.simulator.models.MainModel;
import org.vadere.simulator.models.Model;
import org.vadere.simulator.models.SpeedAdjuster;
import org.vadere.simulator.models.StepSizeAdjuster;
import org.vadere.simulator.models.SubModelBuilder;
import org.vadere.simulator.models.groups.CentroidGroupModel;
import org.vadere.simulator.models.groups.CentroidGroupPotential;
import org.vadere.simulator.models.groups.CentroidGroupSpeedAdjuster;
import org.vadere.simulator.models.groups.CentroidGroupStepSizeAdjuster;
import org.vadere.simulator.models.osm.optimization.ParticleSwarmOptimizer;
import org.vadere.simulator.models.osm.optimization.StepCircleOptimizer;
import org.vadere.simulator.models.osm.optimization.StepCircleOptimizerBrent;
......@@ -58,14 +60,17 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel, Dynami
private PotentialFieldObstacle potentialFieldObstacle;
private PotentialFieldAgent potentialFieldPedestrian;
private List<SpeedAdjuster> speedAdjusters;
private List<StepSizeAdjuster> stepSizeAdjusters;
private Topography topography;
private double lastSimTimeInSec;
private int pedestrianIdCounter;
private ExecutorService executorService;
private List<Model> models = new LinkedList<>();
public OptimalStepsModel() {
this.pedestrianIdCounter = 0;
this.speedAdjusters = new LinkedList<>();
this.stepSizeAdjusters = new LinkedList<>();
}
@Override
......@@ -103,10 +108,11 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel, Dynami
this.potentialFieldPedestrian =
new CentroidGroupPotential(centroidGroupModel,
potentialFieldPedestrian, centroidGroupModel.getAttributesCGM());
potentialFieldPedestrian, potentialFieldTarget, centroidGroupModel.getAttributesCGM());
SpeedAdjuster speedAdjusterCGM = new CentroidGroupSpeedAdjuster(centroidGroupModel);
this.speedAdjusters.add(speedAdjusterCGM);
this.stepSizeAdjusters.add(new CentroidGroupStepSizeAdjuster(centroidGroupModel));
}
this.stepCircleOptimizer = createStepCircleOptimizer(
......@@ -264,7 +270,7 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel, Dynami
PedestrianOSM pedestrian = new PedestrianOSM(attributesOSM,
attributesAgent, topography, random, potentialFieldTarget,
potentialFieldObstacle.copy(), potentialFieldPedestrian,
speedAdjusters, stepCircleOptimizer.clone());
stepSizeAdjusters, stepCircleOptimizer.clone());
pedestrian.setPosition(position);
return pedestrian;
}
......
......@@ -2,6 +2,7 @@ package org.vadere.simulator.models.osm;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.StepSizeAdjuster;
import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.simulator.models.SpeedAdjuster;
import org.vadere.simulator.models.osm.optimization.StepCircleOptimizer;
......@@ -39,6 +40,7 @@ public class PedestrianOSM extends Pedestrian {
private transient PotentialFieldObstacle potentialFieldObstacle;
private transient PotentialFieldAgent potentialFieldPedestrian;
private transient List<SpeedAdjuster> speedAdjusters;
private transient List<StepSizeAdjuster> stepSizeAdjusters;
private double durationNextStep;
private VPoint nextPosition;
private VPoint lastPosition;
......@@ -62,7 +64,7 @@ public class PedestrianOSM extends Pedestrian {
Random random, IPotentialFieldTarget potentialFieldTarget,
PotentialFieldObstacle potentialFieldObstacle,
PotentialFieldAgent potentialFieldPedestrian,
List<SpeedAdjuster> speedAdjusters,
List<StepSizeAdjuster> stepSizeAdjusters,
StepCircleOptimizer stepCircleOptimizer) {
super(attributesPedestrian, random);
......@@ -74,7 +76,8 @@ public class PedestrianOSM extends Pedestrian {
this.potentialFieldPedestrian = potentialFieldPedestrian;
this.stepCircleOptimizer = stepCircleOptimizer;
this.speedAdjusters = speedAdjusters;
this.speedAdjusters = new LinkedList<>();
this.stepSizeAdjusters = stepSizeAdjusters;
this.relevantPedestrians = new HashSet<>();
this.timeCredit = 0;
......@@ -125,7 +128,7 @@ public class PedestrianOSM extends Pedestrian {
} else if (topography.getTarget(getNextTargetId()).getShape().contains(getPosition())) {
this.nextPosition = getPosition();
} else {
VCircle reachableArea = new VCircle(getPosition(), getStepSize());
VCircle reachableArea = new VCircle(getPosition(), getDesiredStepSize());
// get stairs pedestrian is on - remains null if on area
Stairs stairs = null;
......@@ -166,6 +169,16 @@ public class PedestrianOSM extends Pedestrian {
}
}
public double getDesiredStepSize() {
double desiredStepSize = getStepSize();
for (StepSizeAdjuster adjuster : stepSizeAdjusters) {
desiredStepSize = adjuster.getAdjustedStepSize(this, desiredStepSize);
}
return desiredStepSize;
}
public double getDesiredSpeed() {
double desiredSpeed = getFreeFlowSpeed();
......
......@@ -34,7 +34,7 @@ public class ParticleSwarmOptimizer implements StepCircleOptimizer {
VCircle circle = ((VCircle) reachableArea);
double stepSize = circle.getRadius();
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(pedestrian, random);
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(pedestrian, (VCircle) reachableArea, random);
// maximum possible angle of movement relative to ankerAngle
double angle;
......
......@@ -36,7 +36,7 @@ public class StepCircleOptimizerDiscrete implements StepCircleOptimizer {
assert reachableArea instanceof VCircle;
double stepSize = ((VCircle) reachableArea).getRadius();
List<VPoint> positions = getReachablePositions(pedestrian, random);
List<VPoint> positions = getReachablePositions(pedestrian, (VCircle) reachableArea, random);
PotentialEvaluationFunction potentialEvaluationFunction = new PotentialEvaluationFunction(pedestrian);
potentialEvaluationFunction.setStepSize(stepSize);
......@@ -75,7 +75,7 @@ public class StepCircleOptimizerDiscrete implements StepCircleOptimizer {
return new StepCircleOptimizerDiscrete(movementThreshold, random);
}
public static List<VPoint> getReachablePositions(@NotNull final PedestrianOSM pedestrian, @NotNull final Random random) {
public static List<VPoint> getReachablePositions(@NotNull final PedestrianOSM pedestrian, @NotNull VCircle reachableArea, @NotNull final Random random) {
final AttributesOSM attributesOSM = pedestrian.getAttributesOSM();
int numberOfCircles = attributesOSM.getNumberOfCircles();
......@@ -116,8 +116,7 @@ public class StepCircleOptimizerDiscrete implements StepCircleOptimizer {
return GeometryUtils.getDiscDiscretizationPoints(
random,
attributesOSM.isVaryStepDirection(),
new VCircle(pedestrian.getPosition(),
pedestrian.getStepSize()),
reachableArea,
numberOfCircles,
attributesOSM.getStepCircleResolution(),
anchorAngle,
......
......@@ -37,7 +37,7 @@ public class StepCircleOptimizerEvolStrat implements StepCircleOptimizer {
public VPoint getNextPosition(PedestrianOSM ped, Shape reachableArea) {
double stepSize = ((VCircle) reachableArea).getRadius();
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(ped, random);
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(ped, (VCircle)reachableArea, random);
int numberOfParents = positions.size();
int numberOfChildren = numberOfParents * 7;
......
......@@ -35,7 +35,7 @@ public class StepCircleOptimizerNelderMead implements StepCircleOptimizer {
public VPoint getNextPosition(PedestrianOSM pedestrian, Shape reachableArea) {
double stepSize = ((VCircle) reachableArea).getRadius();
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(pedestrian, random);
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(pedestrian, (VCircle)reachableArea, random);
PotentialEvaluationFunction potentialEvaluationFunction = new PotentialEvaluationFunction(pedestrian);
potentialEvaluationFunction.setStepSize(stepSize);
......
......@@ -38,7 +38,7 @@ public class StepCircleOptimizerPowell implements StepCircleOptimizer {
PointValuePair newMinimum = new PointValuePair(position, potentialEvaluationFunction.value(position));
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(pedestrian, random);
List<VPoint> positions = StepCircleOptimizerDiscrete.getReachablePositions(pedestrian, (VCircle)reachableArea, random);
try {
newMinimum = optimizer.optimize(1000, (MultivariateFunction) potentialEvaluationFunction, GoalType.MINIMIZE,
......
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