Commit b190d3d9 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Fixed bugs in "UpdateSchemeSequential."update()"

Removed unnecessary "pedestrian.clearStrides()" calls and use
"stepForward()" instead of "makeStepToTarget()" which is intended
for "UpdateSchemeEventDriven".

"stepForward()" takes care of proper time credit handling
in sequential update scheme while "makeStepToTarget()" does not!
parent 61ccbd3f
Pipeline #206242 passed with stages
in 121 minutes and 47 seconds
......@@ -123,6 +123,9 @@ public class OSMBehaviorController {
public void maximizeDistanceToThreatAndIncreaseSpeed(PedestrianOSM pedestrian, Topography topography) {
Stimulus perceivedThreat = pedestrian.getPerceivedThreat();
// FIXME: This test (if we have already seen a bang) is wrong!
// Assume, the pedestrian leaves the bang radius and re-enters it.
// Therefore, introduce a flag or another more robust test.
if (perceivedThreat instanceof Threat && pedestrian.getCombinedPotentialStrategy() instanceof TargetAttractionStrategy) {
Threat threat = (Threat) perceivedThreat;
Target threatOrigin = topography.getTarget(threat.getOriginAsTargetId());
......
......@@ -31,20 +31,15 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
}
protected void update(@NotNull final Collection<Pedestrian> pedestrianOSMS, final double currentTimeInSec, final double timeStepInSec) {
// TODO: Clarify with Bene if we can call "clearStrides()" here directly like in "UpdateSchemeEventDriven"
// and omit in in invoked "update()".
for (Pedestrian pedestrian : pedestrianOSMS) {
if(!skipUdate.contains(pedestrian)) {
update((PedestrianOSM) pedestrian, currentTimeInSec, timeStepInSec);
}
//pedestrian.update(timeStepInSec, -1, CallMethod.SEQUENTIAL);
}
skipUdate.clear();
}
protected void update(@NotNull final PedestrianOSM pedestrian, final double currentTimeInSec, final double timeStepInSec) {
Stimulus mostImportantStimulus = pedestrian.getMostImportantStimulus();
// for the first step after creation, timeOfNextStep has to be initialized
if (pedestrian.getTimeOfNextStep() == Pedestrian.INVALID_NEXT_EVENT_TIME) {
pedestrian.setTimeOfNextStep(currentTimeInSec);
......@@ -53,25 +48,23 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
SelfCategory selfCategory = pedestrian.getSelfCategory();
if (selfCategory == SelfCategory.TARGET_ORIENTED) {
pedestrian.clearStrides();
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
} else if (selfCategory == SelfCategory.COOPERATIVE) {
pedestrian.clearStrides();
PedestrianOSM candidate = osmBehaviorController.findSwapCandidate(pedestrian, topography);
if(candidate != null) {
osmBehaviorController.swapPedestrians(pedestrian, candidate, topography);
// here we update not only pedestrian but also candidate, therefore candidate is already treated and will be skipped.
// We update "this" pedestrian and "candidate" here. Therefore, candidate is already treated and will be skipped.
skipUdate.add(candidate);
} else {
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
}
} else if (selfCategory == SelfCategory.INSIDE_THREAT_AREA) {
osmBehaviorController.maximizeDistanceToThreatAndIncreaseSpeed(pedestrian, topography);
osmBehaviorController.makeStepToTarget(pedestrian, topography);
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
} else if (selfCategory == SelfCategory.OUTSIDE_THREAT_AREA) {
osmBehaviorController.changeTargetToSafeZone(pedestrian, topography);
osmBehaviorController.makeStepToTarget(pedestrian, topography);
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
} else if (selfCategory == SelfCategory.WAIT) {
osmBehaviorController.wait(pedestrian, timeStepInSec);
} else if (selfCategory == SelfCategory.CHANGE_TARGET) {
......
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