Commit b33810e8 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

fix issue #242.

parent 4575db5e
Pipeline #114918 failed with stages
in 70 minutes and 6 seconds
......@@ -46,11 +46,13 @@ public class OSMBehaviorController {
VPoint currentPosition = pedestrian.getPosition();
VPoint nextPosition = pedestrian.getNextPosition();
// start time
double timeOfNextStep = pedestrian.getTimeOfNextStep();
// end time
double entTimeOfStep = pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep();
double endTimeOfStep = pedestrian.getTimeOfNextStep();
// start time
double timeOfNextStep = pedestrian.getTimeOfNextStep() - pedestrian.getDurationNextStep();
assert endTimeOfStep > timeOfNextStep && endTimeOfStep >= 0.0;
if (nextPosition.equals(currentPosition)) {
pedestrian.setTimeCredit(0);
......@@ -73,7 +75,7 @@ public class OSMBehaviorController {
* strides and foot steps have no influence on the simulation itself, i.e. they are saved to analyse trajectories
*/
pedestrian.getStrides().add(Pair.of(currentPosition.distance(nextPosition), timeOfNextStep));
pedestrian.getFootSteps().add(new FootStep(currentPosition, nextPosition, timeOfNextStep, entTimeOfStep));
pedestrian.getFootSteps().add(new FootStep(currentPosition, nextPosition, timeOfNextStep, endTimeOfStep));
}
public void wait(PedestrianOSM pedestrian) {
......
......@@ -40,27 +40,28 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
// event driven update ignores time credits!
while (pedestrianEventsQueue.peek().getTimeOfNextStep() < currentTimeInSec) {
PedestrianOSM ped = pedestrianEventsQueue.poll();
update(ped, currentTimeInSec);
update(ped, timeStepInSec, currentTimeInSec);
//System.out.println(ped.getId());
pedestrianEventsQueue.add(ped);
}
}
}
protected void update(@NotNull final PedestrianOSM pedestrian, final double currentTimeInSec) {
protected void update(@NotNull final PedestrianOSM pedestrian, final double timeStepInSec, final double currentTimeInSec) {
Event mostImportantEvent = pedestrian.getMostImportantEvent();
if (mostImportantEvent instanceof ElapsedTimeEvent) {
VPoint oldPosition = pedestrian.getPosition();
double stepDuration = pedestrian.getDurationNextStep();
// for the first step after creation, timeOfNextStep has to be initialized
/*if (pedestrian.getTimeOfNextStep() == 0) {
pedestrian.setTimeOfNextStep(currentTimeInSec);
}*/
if (pedestrian.getTimeOfNextStep() == 0) {
pedestrian.setTimeOfNextStep(currentTimeInSec - timeStepInSec);
}
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
pedestrian.updateNextPosition();
double stepDuration = pedestrian.getDurationNextStep();
osmBehaviorController.makeStep(pedestrian, topography, stepDuration);
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + stepDuration);
} else if (mostImportantEvent instanceof WaitEvent || mostImportantEvent instanceof WaitInAreaEvent) {
......
......@@ -141,7 +141,7 @@ public class UpdateSchemeEventDrivenParallel extends UpdateSchemeEventDriven {
parallelUpdatablePeds.stream().forEach(ped -> {
//logger.info(ped.getTimeOfNextStep());
//System.out.println(ped.getId());
update(ped, currentTimeInSec);
update(ped, timeStepInSec, currentTimeInSec);
});
......
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