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

Merge branch 'dev/stepSizeAdjuster' into 'master'

Dev/step size adjuster

See merge request !36
parents 562b25c6 35020ae4
Pipeline #78511 failed with stages
in 57 seconds
......@@ -77,7 +77,7 @@
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"numberOfCircles" : 1,
"numberOfCircles" : 3,
"varyStepDirection" : false,
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
......@@ -137,294 +137,6 @@
"type" : "RECTANGLE"
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 0.5001
}, {
"x" : -1.0E-4,
"y" : 0.5001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : -1.0E-4
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 9.4999
}, {
"x" : 20.0001,
"y" : 9.4999
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : 10.0001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 0.5001
}, {
"x" : -1.0E-4,
"y" : 0.5001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : -1.0E-4
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 9.4999
}, {
"x" : 20.0001,
"y" : 9.4999
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : 10.0001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 0.5001
}, {
"x" : -1.0E-4,
"y" : 0.5001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : -1.0E-4
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 9.4999
}, {
"x" : 20.0001,
"y" : 9.4999
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : 10.0001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 0.5001
}, {
"x" : -1.0E-4,
"y" : 0.5001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : -1.0E-4
}, {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : 10.0001
}, {
"x" : 19.4999,
"y" : -1.0E-4
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 20.0001,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : 9.4999
}, {
"x" : 20.0001,
"y" : 9.4999
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : 10.0001
}, {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : -1.0E-4
}, {
"x" : 0.5001,
"y" : 10.0001
} ]
},
"id" : -1
} ],
"stairs" : [ ],
"targets" : [ {
......
......@@ -87,7 +87,7 @@
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"stepCircleResolution" : 10,
"numberOfCircles" : 3,
"varyStepDirection" : false,
"stepLengthIntercept" : 0.4625,
......
......@@ -87,7 +87,7 @@
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"stepCircleResolution" : 10,
"numberOfCircles" : 3,
"varyStepDirection" : false,
"stepLengthIntercept" : 0.4625,
......
......@@ -45,8 +45,8 @@
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"numberOfCircles" : 1,
"stepCircleResolution" : 10,
"numberOfCircles" : 3,
"varyStepDirection" : false,
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
......
......@@ -45,14 +45,14 @@
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"numberOfCircles" : 1,
"stepCircleResolution" : 10,
"numberOfCircles" : 3,
"varyStepDirection" : true,
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"optimizationType" : "NELDER_MEAD",
"optimizationType" : "PSO",
"movementType" : "ARBITRARY",
"dynamicStepLength" : false,
"updateType" : "EVENT_DRIVEN",
......
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 {