Commit eaadd70c authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

merge master.

parent ef37653a
Pipeline #186831 passed with stages
in 175 minutes and 31 seconds
......@@ -28,7 +28,7 @@ import org.vadere.util.logging.Logger;
* will be performed in parallel on the bases of the situation (i.e. agents position) at <tt>currentTimeInSec</tt> - <tt>timeStepInSec</tt>.
*/
public class UpdateSchemeParallel implements UpdateSchemeOSM {
private static final int NUMBER_OF_THREADS = 8;
private static Logger logger = Logger.getLogger(UpdateSchemeParallel.class);
protected final ExecutorService executorService;
protected final Topography topography;
......@@ -38,7 +38,11 @@ public class UpdateSchemeParallel implements UpdateSchemeOSM {
*/
protected final Set<Pedestrian> movePedestrians;
/**
* marks an agent which shall move back because of conflicts.
*/
protected final Set<Pedestrian> undoPedestrians;
private final OSMBehaviorController osmBehaviorController;
static {
......@@ -47,7 +51,7 @@ public class UpdateSchemeParallel implements UpdateSchemeOSM {
public UpdateSchemeParallel(@NotNull final Topography topography) {
this.topography = topography;
this.executorService = Executors.newFixedThreadPool(1);
this.executorService = Executors.newFixedThreadPool(NUMBER_OF_THREADS);
this.movePedestrians = new HashSet<>();
this.undoPedestrians = new HashSet<>();
this.osmBehaviorController = new OSMBehaviorController();
......
......@@ -427,37 +427,6 @@ public class OSMBehaviorControllerTest {
assertEquals(expectedTimeOfNextStep, pedestrian2.getTimeOfNextStep(), ALLOWED_DOUBLE_TOLERANCE);
}
@Test
public void swapPedestriansHandlesOSMTimeCreditParametersProperly() {
createSameDirectionTopography();
double timeOfNextStepPed1 = 1;
double timeOfNextStepPed2 = 1.5;
pedestrian1.setTimeOfNextStep(timeOfNextStepPed1);
pedestrian2.setTimeOfNextStep(timeOfNextStepPed2);
double timeCreditInSecPed1 = 1;
double timeCreditInSecPed2 = 1.5;
pedestrian1.setTimeCredit(timeCreditInSecPed1);
pedestrian2.setTimeCredit(timeCreditInSecPed2);
double maxStepDuration = Math.max(pedestrian1.getDurationNextStep(), pedestrian2.getDurationNextStep());
double stepDurationPed1 = pedestrian1.getDurationNextStep();
OSMBehaviorController controllerUnderTest = new OSMBehaviorController();
controllerUnderTest.swapPedestrians(pedestrian1, pedestrian2, topography);
// For event-driven update scheme "timeOfNextStep" must be set properly.
double expectedTimeOfNextStep = timeOfNextStepPed1 + maxStepDuration;
assertEquals(expectedTimeOfNextStep, pedestrian1.getTimeOfNextStep(), ALLOWED_DOUBLE_TOLERANCE);
assertEquals(expectedTimeOfNextStep, pedestrian2.getTimeOfNextStep(), ALLOWED_DOUBLE_TOLERANCE);
// For sequential update scheme "timeCredit" must be set properly.
double expectedTimeCredit = timeCreditInSecPed1 - (stepDurationPed1 + maxStepDuration);
assertEquals(expectedTimeCredit, pedestrian1.getTimeCredit(), ALLOWED_DOUBLE_TOLERANCE);
assertEquals(expectedTimeCredit, pedestrian2.getTimeCredit(), ALLOWED_DOUBLE_TOLERANCE);
}
@Test
public void findSwapCandidateReturnsNullIfGivenPedestrianHasNotTarget() {
createOppositeDirectionVariation2Topography();
......@@ -652,21 +621,4 @@ public class OSMBehaviorControllerTest {
double expectedTimeOfNextStep = currentSimTimeInSec + timeOfNextStep;
assertEquals(expectedTimeOfNextStep, pedestrian1.getTimeOfNextStep(), ALLOWED_DOUBLE_TOLERANCE);
}
@Test
public void waitSetsTimeCreditToZeroForSequentialUpdateScheme() {
createSameDirectionTopography();
double timeCredit = 1.0;
pedestrian1.setTimeCredit(timeCredit);
assertEquals(timeCredit, pedestrian1.getTimeCredit(), ALLOWED_DOUBLE_TOLERANCE);
double currentSimTimeInSec = 1.0;
OSMBehaviorController controllerUnderTest = new OSMBehaviorController();
controllerUnderTest.wait(pedestrian1, currentSimTimeInSec);
double expectedTimeCredit = 0;
assertEquals(expectedTimeCredit, pedestrian1.getTimeCredit(), ALLOWED_DOUBLE_TOLERANCE);
}
}
\ No newline at end of file
Supports Markdown
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