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 @@ ...@@ -77,7 +77,7 @@
}, },
"org.vadere.state.attributes.models.AttributesOSM" : { "org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18, "stepCircleResolution" : 18,
"numberOfCircles" : 1, "numberOfCircles" : 3,
"varyStepDirection" : false, "varyStepDirection" : false,
"stepLengthIntercept" : 0.4625, "stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345, "stepLengthSlopeSpeed" : 0.2345,
...@@ -137,294 +137,6 @@ ...@@ -137,294 +137,6 @@
"type" : "RECTANGLE" "type" : "RECTANGLE"
}, },
"id" : -1 "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" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
} }
}, },
"org.vadere.state.attributes.models.AttributesOSM" : { "org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18, "stepCircleResolution" : 10,
"numberOfCircles" : 3, "numberOfCircles" : 3,
"varyStepDirection" : false, "varyStepDirection" : false,
"stepLengthIntercept" : 0.4625, "stepLengthIntercept" : 0.4625,
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
} }
}, },
"org.vadere.state.attributes.models.AttributesOSM" : { "org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18, "stepCircleResolution" : 10,
"numberOfCircles" : 3, "numberOfCircles" : 3,
"varyStepDirection" : false, "varyStepDirection" : false,
"stepLengthIntercept" : 0.4625, "stepLengthIntercept" : 0.4625,
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
} }
}, },
"org.vadere.state.attributes.models.AttributesOSM" : { "org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18, "stepCircleResolution" : 10,
"numberOfCircles" : 1, "numberOfCircles" : 3,
"varyStepDirection" : false, "varyStepDirection" : false,
"stepLengthIntercept" : 0.4625, "stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345, "stepLengthSlopeSpeed" : 0.2345,
......
...@@ -45,14 +45,14 @@ ...@@ -45,14 +45,14 @@
} }
}, },
"org.vadere.state.attributes.models.AttributesOSM" : { "org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18, "stepCircleResolution" : 10,
"numberOfCircles" : 1, "numberOfCircles" : 3,
"varyStepDirection" : true, "varyStepDirection" : true,
"stepLengthIntercept" : 0.4625, "stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345, "stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036, "stepLengthSD" : 0.036,
"movementThreshold" : 0.0, "movementThreshold" : 0.0,
"optimizationType" : "NELDER_MEAD", "optimizationType" : "PSO",
"movementType" : "ARBITRARY", "movementType" : "ARBITRARY",
"dynamicStepLength" : false, "dynamicStepLength" : false,
"updateType" : "EVENT_DRIVEN", "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 { ...@@ -201,10 +201,18 @@ public class CentroidGroup implements Group {
double result; double result;
VPoint pedLocation = ped.getPosition(); 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 pedDistance = potentialFieldTarget.getPotential(pedLocation, ped);
double centroidDistance = potentialFieldTarget.getPotential(getCentroidOthers(ped), ped);
result = centroidDistance - pedDistance; result = (potentialSum / size) - pedDistance;
if (result > POTENTIAL_DISTANCE_THRESHOLD) { if (result > POTENTIAL_DISTANCE_THRESHOLD) {
result = 0; result = 0;
......
...@@ -3,7 +3,9 @@ package org.vadere.simulator.models.groups; ...@@ -3,7 +3,9 @@ package org.vadere.simulator.models.groups;
import org.apache.log4j.LogManager; import org.apache.log4j.LogManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.vadere.annotation.factories.models.ModelClass; 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.PotentialFieldAgent;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.state.attributes.Attributes; import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesCGM; import org.vadere.state.attributes.models.AttributesCGM;
import org.vadere.state.attributes.scenario.AttributesAgent; import org.vadere.state.attributes.scenario.AttributesAgent;
...@@ -27,14 +29,17 @@ public class CentroidGroupPotential implements PotentialFieldAgent { ...@@ -27,14 +29,17 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
private final AttributesCGM attributesCGM; private final AttributesCGM attributesCGM;
private final CentroidGroupModel groupCollection; private final CentroidGroupModel groupCollection;
private final PotentialFieldAgent potentialFieldPedestrian; private final PotentialFieldAgent potentialFieldPedestrian;
private final IPotentialFieldTarget potentialFieldTarget;
public CentroidGroupPotential(CentroidGroupModel groupCollection, public CentroidGroupPotential(CentroidGroupModel groupCollection,
PotentialFieldAgent pedestrianRepulsionPotential, PotentialFieldAgent pedestrianRepulsionPotential,
IPotentialFieldTarget potentialFieldTarget,
AttributesCGM attributesCGM) { AttributesCGM attributesCGM) {
this.attributesCGM = attributesCGM; this.attributesCGM = attributesCGM;
this.groupCollection = groupCollection; this.groupCollection = groupCollection;
this.potentialFieldPedestrian = pedestrianRepulsionPotential; this.potentialFieldPedestrian = pedestrianRepulsionPotential;
this.potentialFieldTarget = potentialFieldTarget;
} }
@Override @Override
...@@ -65,6 +70,8 @@ public class CentroidGroupPotential implements PotentialFieldAgent { ...@@ -65,6 +70,8 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
if (leader != null) { if (leader != null) {
VPoint leaderPoint = leader.getPosition(); VPoint leaderPoint = leader.getPosition();
double leaderPotential = potentialFieldTarget.getPotential(leaderPoint, leader);
double pedPotential = potentialFieldTarget.getPotential(ped.getPosition(), ped);
final double[] distanceToCentroid = { final double[] distanceToCentroid = {
pos.getX() - leaderPoint.getX(), pos.getX() - leaderPoint.getX(),
...@@ -72,9 +79,8 @@ public class CentroidGroupPotential implements PotentialFieldAgent { ...@@ -72,9 +79,8 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
result = attributesCGM.getLeaderAttractionFactor() result = attributesCGM.getLeaderAttractionFactor()
* Math.pow( * Math.pow(
Math.pow(distanceToCentroid[0], 2) leaderPotential - pedPotential,
+ Math.pow(distanceToCentroid[1], 2), 4);
2);
} }
return result; return result;
...@@ -111,7 +117,7 @@ public class CentroidGroupPotential implements PotentialFieldAgent { ...@@ -111,7 +117,7 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
double potential = potentialFieldPedestrian.getAgentPotential(pos, double potential = potentialFieldPedestrian.getAgentPotential(pos,
pedestrian, otherPedestrian); pedestrian, otherPedestrian);
if (group.equals(groupOther)) { if (group != null && group.equals(groupOther)) {
potential *= attributesCGM.getGroupMemberRepulsionFactor(); 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; ...@@ -8,10 +8,12 @@ import org.vadere.simulator.control.factory.SourceControllerFactory;
import org.vadere.simulator.models.MainModel; import org.vadere.simulator.models.MainModel;
import org.vadere.simulator.models.Model; import org.vadere.simulator.models.Model;
import org.vadere.simulator.models.SpeedAdjuster; import org.vadere.simulator.models.SpeedAdjuster;
import org.vadere.simulator.models.StepSizeAdjuster;
import org.vadere.simulator.models.SubModelBuilder; import org.vadere.simulator.models.SubModelBuilder;
import org.vadere.simulator.models.groups.CentroidGroupModel; import org.vadere.simulator.models.groups.CentroidGroupModel;
import org.vadere.simulator.models.groups.CentroidGroupPotential; import org.vadere.simulator.models.groups.CentroidGroupPotential;
import org.vadere.simulator.models.groups.CentroidGroupSpeedAdjuster; 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.ParticleSwarmOptimizer;
import org.vadere.simulator.models.osm.optimization.StepCircleOptimizer; import org.vadere.simulator.models.osm.optimization.StepCircleOptimizer;
import org.vadere.simulator.models.osm.optimization.StepCircleOptimizerBrent; import org.vadere.simulator.models.osm.optimization.StepCircleOptimizerBrent;
...@@ -58,14 +60,17 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel, Dynami ...@@ -58,14 +60,17 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel, Dynami
private PotentialFieldObstacle potentialFieldObstacle; private PotentialFieldObstacle potentialFieldObstacle;
private PotentialFieldAgent potentialFieldPedestrian; private PotentialFieldAgent potentialFieldPedestrian;
private List<SpeedAdjuster> speedAdjusters; private List<SpeedAdjuster> speedAdjusters;
private List<StepSizeAdjuster> stepSizeAdjusters;
private Topography topography; private Topography topography;
private double lastSimTimeInSec; private double lastSimTimeInSec;
private int pedestrianIdCounter; private int pedestrianIdCounter;
private ExecutorService executorService; private ExecutorService executorService;
private List<Model> models = new LinkedList<>(); private List<Model> models = new LinkedList<>();
public OptimalStepsModel() { public OptimalStepsModel() {
this.pedestrianIdCounter = 0; this.pedestrianIdCounter = 0;
this.speedAdjusters = new LinkedList<>(); this.speedAdjusters = new LinkedList<>();
this.stepSizeAdjusters = new LinkedList<>();