Commit 8042f44a authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Added "BangEvent", process it in "CognitionLayer" and added dummy behavior in...

Added "BangEvent", process it in "CognitionLayer" and added dummy behavior in "UpdateSchemeSequential" and "UpdateSchemeEventDriven".

VadereSimulator/src/org/vadere/simulator/models/potential/combinedPotentials/CombinedPotentialStrategy.java:
- Renamed this interface to "ICombinedPotentialStrategy".
- Added enum "CombinedPotentialStrategy".
parent 8b05aaa8
Pipeline #90653 failed with stages
in 3 minutes and 29 seconds
{
"name" : "bang_event_2_sources_2_targets_osm_sequential",
"description" : "",
"release" : "0.7",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "density.txt",
"processors" : [ 1 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "out.txt",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "out1.txt",
"processors" : [ 4 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "postvis.trajectories",
"processors" : [ 1, 2 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianDensityCountingProcessor",
"id" : 1,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianDensityCountingProcessor",
"attributes" : {
"pedestrianPositionProcessorId" : 2,
"radius" : 1.5
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 4,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.MaxOverlapProcessor",
"id" : 5,
"attributesType" : "org.vadere.state.attributes.processor.AttributesMaxOverlapProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT"
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"numberOfCircles" : 1,
"optimizationType" : "DISCRETE",
"varyStepDirection" : false,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.4625,
"minimumStepLength" : false,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : false,
"updateType" : "SEQUENTIAL",
"seeSmallWalls" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ ]
},
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
}
},
"attributesSimulation" : {
"finishTime" : 150.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 40.0,
"height" : 16.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true
},
"obstacles" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 36.0,
"y" : 10.5,
"width" : 2.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 2,
"absorbing" : true,
"shape" : {
"x" : 36.0,
"y" : 1.0,
"width" : 2.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"sources" : [ {
"id" : 1,
"shape" : {
"x" : 1.0,
"y" : 10.5,
"width" : 2.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 10,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
}, {
"id" : 2,
"shape" : {
"x" : 1.0,
"y" : 1.0,
"width" : 2.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 10,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ {
"eventTimeframe" : {
"startTime" : 18.0,
"endTime" : 18.4,
"repeat" : false,
"waitTimeBetweenRepetition" : 0.0
},
"events" : [ {
"type" : "BangEvent",
"targets" : [ ]
} ]
} ]
}
}
\ No newline at end of file
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
"pedestrianOverlapProcessorId" : 3 "pedestrianOverlapProcessorId" : 3
} }
} ], } ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel", "mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
...@@ -74,19 +75,19 @@ ...@@ -74,19 +75,19 @@
"org.vadere.state.attributes.models.AttributesOSM" : { "org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18, "stepCircleResolution" : 18,
"numberOfCircles" : 1, "numberOfCircles" : 1,
"optimizationType" : "DISCRETE",
"varyStepDirection" : false, "varyStepDirection" : false,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625, "stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345, "stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036, "stepLengthSD" : 0.036,
"movementThreshold" : 0.0, "movementThreshold" : 0.0,
"minStepLength" : 0.4625, "minStepLength" : 0.4625,
"minimumStepLength" : false,
"maxStepDuration" : 1.7976931348623157E308, "maxStepDuration" : 1.7976931348623157E308,
"optimizationType" : "DISCRETE",
"movementType" : "ARBITRARY",
"dynamicStepLength" : false, "dynamicStepLength" : false,
"updateType" : "SEQUENTIAL", "updateType" : "SEQUENTIAL",
"seeSmallWalls" : false, "seeSmallWalls" : false,
"minimumStepLength" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid", "targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell", "pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell", "obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
......
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
"pedestrianOverlapProcessorId" : 3 "pedestrianOverlapProcessorId" : 3
} }
} ], } ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.bhm.BehaviouralHeuristicsModel", "mainModel" : "org.vadere.simulator.models.bhm.BehaviouralHeuristicsModel",
......
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
"pedestrianOverlapProcessorId" : 3 "pedestrianOverlapProcessorId" : 3
} }
} ], } ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel", "mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
...@@ -74,19 +75,19 @@ ...@@ -74,19 +75,19 @@
"org.vadere.state.attributes.models.AttributesOSM" : { "org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18, "stepCircleResolution" : 18,
"numberOfCircles" : 1, "numberOfCircles" : 1,
"optimizationType" : "DISCRETE",
"varyStepDirection" : false, "varyStepDirection" : false,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625, "stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345, "stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036, "stepLengthSD" : 0.036,
"movementThreshold" : 0.0, "movementThreshold" : 0.0,
"minStepLength" : 0.4625, "minStepLength" : 0.4625,
"minimumStepLength" : false,
"maxStepDuration" : 1.7976931348623157E308, "maxStepDuration" : 1.7976931348623157E308,
"optimizationType" : "DISCRETE",
"movementType" : "ARBITRARY",
"dynamicStepLength" : false, "dynamicStepLength" : false,
"updateType" : "SEQUENTIAL", "updateType" : "SEQUENTIAL",
"seeSmallWalls" : false, "seeSmallWalls" : false,
"minimumStepLength" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid", "targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell", "pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell", "obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
......
package org.vadere.simulator.control.cognition; package org.vadere.simulator.control.cognition;
import org.vadere.state.events.types.ElapsedTimeEvent; import org.vadere.state.events.types.*;
import org.vadere.state.events.types.Event;
import org.vadere.state.events.types.WaitEvent;
import org.vadere.state.events.types.WaitInAreaEvent;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import java.util.Collection; import java.util.Collection;
...@@ -34,8 +31,11 @@ public class CognitionLayer { ...@@ -34,8 +31,11 @@ public class CognitionLayer {
List<Event> waitEvents = events.stream().filter(event -> event instanceof WaitEvent).collect(Collectors.toList()); List<Event> waitEvents = events.stream().filter(event -> event instanceof WaitEvent).collect(Collectors.toList());
List<Event> waitInAreaEvents = events.stream().filter(event -> event instanceof WaitInAreaEvent).collect(Collectors.toList()); List<Event> waitInAreaEvents = events.stream().filter(event -> event instanceof WaitInAreaEvent).collect(Collectors.toList());
List<Event> bangEvents = events.stream().filter(event -> event instanceof BangEvent).collect(Collectors.toList());
if (waitEvents.size() >= 1) { if (bangEvents.size() >= 1) {
mostImportantEvent = bangEvents.get(0);
} else if (waitEvents.size() >= 1) {
mostImportantEvent = waitEvents.get(0); mostImportantEvent = waitEvents.get(0);
} else if (waitInAreaEvents.size() >= 1) { } else if (waitInAreaEvents.size() >= 1) {
for (Event event : waitInAreaEvents) { for (Event event : waitInAreaEvents) {
......
...@@ -98,6 +98,8 @@ public class EventController { ...@@ -98,6 +98,8 @@ public class EventController {
/** /**
* Return if "simulationTime" is in interval [startTime, endTime) of given "timeframe". * Return if "simulationTime" is in interval [startTime, endTime) of given "timeframe".
* *
* TODO: Maybe, including boundaries, i.e. [startTime, endTime], is more intuitive. Check if this causes problems.
*
* @throws IllegalArgumentException If given timeframe is a recurring one. * @throws IllegalArgumentException If given timeframe is a recurring one.
*/ */
public static boolean oneTimeTimeframeIsActiveAtSimulationTime(EventTimeframe timeframe, double simulationTime) { public static boolean oneTimeTimeframeIsActiveAtSimulationTime(EventTimeframe timeframe, double simulationTime) {
......
...@@ -4,6 +4,8 @@ import org.apache.commons.lang3.tuple.Pair; ...@@ -4,6 +4,8 @@ import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.StepSizeAdjuster; import org.vadere.simulator.models.StepSizeAdjuster;
import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy; import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy;
import org.vadere.simulator.models.potential.combinedPotentials.ICombinedPotentialStrategy;
import org.vadere.simulator.models.potential.combinedPotentials.TargetAttractionStrategy;
import org.vadere.simulator.models.potential.combinedPotentials.TargetDistractionStrategy; import org.vadere.simulator.models.potential.combinedPotentials.TargetDistractionStrategy;
import org.vadere.util.geometry.shapes.Vector2D; import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.simulator.models.SpeedAdjuster; import org.vadere.simulator.models.SpeedAdjuster;
...@@ -42,7 +44,7 @@ public class PedestrianOSM extends Pedestrian { ...@@ -42,7 +44,7 @@ public class PedestrianOSM extends Pedestrian {
private transient PotentialFieldObstacle potentialFieldObstacle; private transient PotentialFieldObstacle potentialFieldObstacle;
private transient PotentialFieldAgent potentialFieldPedestrian; private transient PotentialFieldAgent potentialFieldPedestrian;
// A setter is provided to be able to change strategy at runtime (e.g. by events). // A setter is provided to be able to change strategy at runtime (e.g. by events).
private transient CombinedPotentialStrategy combinedPotentialStrategy; private transient ICombinedPotentialStrategy combinedPotentialStrategy;
private transient List<SpeedAdjuster> speedAdjusters; private transient List<SpeedAdjuster> speedAdjusters;
private transient List<StepSizeAdjuster> stepSizeAdjusters; private transient List<StepSizeAdjuster> stepSizeAdjusters;
private VPoint nextPosition; private VPoint nextPosition;
...@@ -77,8 +79,7 @@ public class PedestrianOSM extends Pedestrian { ...@@ -77,8 +79,7 @@ public class PedestrianOSM extends Pedestrian {
this.potentialFieldTarget = potentialFieldTarget; this.potentialFieldTarget = potentialFieldTarget;
this.potentialFieldObstacle = potentialFieldObstacle; this.potentialFieldObstacle = potentialFieldObstacle;
this.potentialFieldPedestrian = potentialFieldPedestrian; this.potentialFieldPedestrian = potentialFieldPedestrian;
// TODO: Use "TargetAttractionStrategy" by default. this.combinedPotentialStrategy = new TargetAttractionStrategy(potentialFieldTarget, potentialFieldObstacle, potentialFieldPedestrian);
this.combinedPotentialStrategy = new TargetDistractionStrategy(potentialFieldTarget, potentialFieldObstacle, potentialFieldPedestrian);
this.stepCircleOptimizer = stepCircleOptimizer; this.stepCircleOptimizer = stepCircleOptimizer;
this.speedAdjusters = speedAdjusters; this.speedAdjusters = speedAdjusters;
...@@ -265,7 +266,7 @@ public class PedestrianOSM extends Pedestrian { ...@@ -265,7 +266,7 @@ public class PedestrianOSM extends Pedestrian {
new Vector2D(0, 0), this, relevantPedestrians); new Vector2D(0, 0), this, relevantPedestrians);
} }
public CombinedPotentialStrategy getCombinedPotentialStrategy() { public ICombinedPotentialStrategy getCombinedPotentialStrategy() {
return combinedPotentialStrategy; return combinedPotentialStrategy;
} }
...@@ -313,8 +314,18 @@ public class PedestrianOSM extends Pedestrian { ...@@ -313,8 +314,18 @@ public class PedestrianOSM extends Pedestrian {
this.relevantPedestrians = relevantPedestrians; this.relevantPedestrians = relevantPedestrians;
} }
public void setCombinedPotentialStrategy(CombinedPotentialStrategy combinedPotentialStrategy) { public void setCombinedPotentialStrategy(CombinedPotentialStrategy newStrategy) {
this.combinedPotentialStrategy = combinedPotentialStrategy; if (newStrategy == CombinedPotentialStrategy.TARGET_ATTRACTION_STRATEGY) {
this.combinedPotentialStrategy = new TargetAttractionStrategy(this.potentialFieldTarget,
this.potentialFieldObstacle,
this.potentialFieldPedestrian);
} else if (newStrategy == CombinedPotentialStrategy.TARGET_DISTRACTION_STRATEGY) {
this.combinedPotentialStrategy = new TargetDistractionStrategy(this.potentialFieldTarget,
this.potentialFieldObstacle,
this.potentialFieldPedestrian);
} else {
throw new UnsupportedOperationException();
}
} }
public Collection<? extends Agent> getRelevantPedestrians() { public Collection<? extends Agent> getRelevantPedestrians() {
......
...@@ -2,10 +2,9 @@ package org.vadere.simulator.models.osm.updateScheme; ...@@ -2,10 +2,9 @@ package org.vadere.simulator.models.osm.updateScheme;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.osm.PedestrianOSM; import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.state.events.types.ElapsedTimeEvent; import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy;
import org.vadere.state.events.types.Event; import org.vadere.simulator.models.potential.combinedPotentials.TargetDistractionStrategy;
import org.vadere.state.events.types.WaitEvent; import org.vadere.state.events.types.*;
import org.vadere.state.events.types.WaitInAreaEvent;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
...@@ -46,6 +45,7 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM { ...@@ -46,6 +45,7 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
protected void update(@NotNull final PedestrianOSM pedestrian, final double currentTimeInSec) { protected void update(@NotNull final PedestrianOSM pedestrian, final double currentTimeInSec) {
Event mostImportantEvent = pedestrian.getMostImportantEvent(); Event mostImportantEvent = pedestrian.getMostImportantEvent();
// TODO: Extract behavior to own methods (i.e. step(), wait() and escape()).
if (mostImportantEvent instanceof ElapsedTimeEvent) { if (mostImportantEvent instanceof ElapsedTimeEvent) {
VPoint oldPosition = pedestrian.getPosition(); VPoint oldPosition = pedestrian.getPosition();
...@@ -61,6 +61,11 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM { ...@@ -61,6 +61,11 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + stepDuration); pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + stepDuration);
} else if (mostImportantEvent instanceof WaitEvent || mostImportantEvent instanceof WaitInAreaEvent) { } else if (mostImportantEvent instanceof WaitEvent || mostImportantEvent instanceof WaitInAreaEvent) {
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep()); pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
} else if (mostImportantEvent instanceof BangEvent) {
// Watch out: For testing purposes, a bang event changes only
// the "CombinedPotentialStrategy". The agent does not move here!
// Therefore, trigger only a single bang event and then use "ElapsedTimeEvent"
pedestrian.setCombinedPotentialStrategy(CombinedPotentialStrategy.TARGET_DISTRACTION_STRATEGY);
} }
} }
......
...@@ -2,10 +2,8 @@ package org.vadere.simulator.models.osm.updateScheme; ...@@ -2,10 +2,8 @@ package org.vadere.simulator.models.osm.updateScheme;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.osm.PedestrianOSM; import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.state.events.types.ElapsedTimeEvent; import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy;
import org.vadere.state.events.types.Event; import org.vadere.state.events.types.*;
import org.vadere.state.events.types.WaitEvent;
import org.vadere.state.events.types.WaitInAreaEvent;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
...@@ -48,6 +46,11 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM { ...@@ -48,6 +46,11 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
} else if (mostImportantEvent instanceof WaitEvent || mostImportantEvent instanceof WaitInAreaEvent) { } else if (mostImportantEvent instanceof WaitEvent || mostImportantEvent instanceof WaitInAreaEvent) {
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep()); pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
} else if (mostImportantEvent instanceof BangEvent) {
// Watch out: For testing purposes, a bang event changes only
// the "CombinedPotentialStrategy". The agent does not move here!
// Therefore, trigger only a single bang event and then use "ElapsedTimeEvent"
pedestrian.setCombinedPotentialStrategy(CombinedPotentialStrategy.TARGET_DISTRACTION_STRATEGY);
} }
} }
......
package org.vadere.simulator.models.potential.combinedPotentials; package org.vadere.simulator.models.potential.combinedPotentials;
import org.vadere.state.scenario.Agent;
import org.vadere.util.geometry.shapes.IPoint;
import java.util.Collection;
/** /**
* In "seitz-2012", the total potential for some point x (in R²) * All available potential strategies.
* is the combination of different potentials:
*
* combined(x) = target(x) + obstacles(x) + agents(x)
*
* Use this interface to implement different combinations of these
* potentials. For instance, negate the target potential so that
* agents run away from targets:
*
* combined(x) = -target(x) + obstacles(x) + agents(x)
*
* The implementing classes require objects of following interfaces
* to calculate the combined potential:
* - {@link org.vadere.simulator.models.potential.fields.IPotentialFieldTarget}
* - {@link org.vadere.simulator.models.potential.fields.PotentialFieldObstacle}
* - {@link org.vadere.simulator.models.potential.fields.PotentialFieldAgent}
* *
* At runtime, implementations of this interface can be replaced by using the strategy pattern. * Use these enum values to create objects imlementing {@link org.vadere.simulator.models.potential.combinedPotentials.ICombinedPotentialStrategy}
* by using the factory pattern.
*/ */
public interface CombinedPotentialStrategy { public enum CombinedPotentialStrategy {
/** TARGET_ATTRACTION_STRATEGY,
* Get the combined potential at given position. TARGET_DISTRACTION_STRATEGY
*/
public double getValue(IPoint newPos, Agent thisAgent, Collection<? extends Agent> otherAgents);