Пример #1
0
  private void test1PersonStartingOnLane(boolean reduceCap) {
    fixture.create1PersonFromLink1Population();

    if (reduceCap) {
      fixture.sc.getConfig().qsim().setStartTime(3500.0);
      fixture.sc.getConfig().qsim().setEndTime(7200.0);
      LaneDefinitions20 lanes = fixture.sc.getLanes();
      Lane lane1 =
          lanes.getLanesToLinkAssignments().get(fixture.id1).getLanes().get(fixture.laneId1);
      lane1.setCapacityVehiclesPerHour(1800.0);
      Lane lane1ol =
          lanes
              .getLanesToLinkAssignments()
              .get(fixture.id1)
              .getLanes()
              .get(fixture.link1FirstLaneId);
      lane1ol.setCapacityVehiclesPerHour(1800.0);
    }

    EventsManager events = EventsUtils.createEventsManager();
    MixedLanesEventsHandler handler = new MixedLanesEventsHandler(this.fixture);
    events.addHandler(handler);
    QSim qsim = QSimUtils.createDefaultQSim(this.fixture.sc, events);
    qsim.run();
    Assert.assertNotNull(handler.lastAgentDepartureEvent);
    Assert.assertEquals(3600.0, handler.lastAgentDepartureEvent.getTime(), testUtils.EPSILON);

    Assert.assertNull(handler.lastLink1EnterEvent);

    Assert.assertNull(handler.lastLane1olEnterEvent);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT, handler.lastLane1olLeaveEvent.getTime(), testUtils.EPSILON);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT, handler.lastLane1EnterEvent.getTime(), testUtils.EPSILON);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1,
        handler.lastLane1LeaveEvent.getTime(),
        testUtils.EPSILON);

    Assert.assertNotNull(handler.lastLink2EnterEvent);
    Assert.assertEquals(
        this.fixture.pid1, handler.vehId2DriverId.get(handler.lastLink2EnterEvent.getVehicleId()));
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1,
        handler.lastLink2EnterEvent.getTime(),
        testUtils.EPSILON);

    Assert.assertNull(handler.lastLink3EnterEvent);
  }
Пример #2
0
  private void testMixedLane2PersonsDriving(boolean reduceCap) {
    fixture.create2PersonPopulation();

    // if no capacity is reduced the delay of both agents should be zero
    double delayOfAgent1 = 0;
    double delayOfAgent2 = 0;

    if (reduceCap) {
      // reduce capacity on lane 1
      LaneDefinitions20 lanes = fixture.sc.getLanes();
      Lane lane1 =
          lanes.getLanesToLinkAssignments().get(fixture.id1).getLanes().get(fixture.laneId1);
      lane1.setCapacityVehiclesPerHour(1800.0);

      // the delay of the second agent on lane 1 should be two seconds if
      // capacity is reduced to 1800 veh/h
      delayOfAgent2 = 2;
    }

    EventsManager events = EventsUtils.createEventsManager();

    MixedLanesEventsHandler handler = new MixedLanesEventsHandler(this.fixture);
    events.addHandler(handler);

    QSim qsim = (QSim) QSimUtils.createDefaultQSim(this.fixture.sc, events);
    qsim.run();

    Assert.assertNotNull(handler.lastAgentDepartureEvent);
    Assert.assertEquals(3600.0, handler.lastAgentDepartureEvent.getTime(), testUtils.EPSILON);

    Assert.assertNotNull(handler.lastLink1EnterEvent);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT, handler.lastLink1EnterEvent.getTime(), testUtils.EPSILON);

    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT, handler.lastLane1olEnterEvent.getTime(), testUtils.EPSILON);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1ol,
        handler.lastLane1olLeaveEvent.getTime(),
        testUtils.EPSILON);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1ol,
        handler.lastLane1EnterEvent.getTime(),
        testUtils.EPSILON);
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1ol + laneTTlane1 + delayOfAgent2,
        handler.lastLane1LeaveEvent.getTime(),
        testUtils.EPSILON);

    Assert.assertNotNull(handler.lastLink2EnterEvent);
    Assert.assertEquals(
        this.fixture.pid1, handler.vehId2DriverId.get(handler.lastLink2EnterEvent.getVehicleId()));
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1ol + laneTTlane1 + delayOfAgent2,
        handler.lastLink2EnterEvent.getTime(),
        testUtils.EPSILON);

    Assert.assertNotNull(handler.lastLink3EnterEvent);
    Assert.assertEquals(
        this.fixture.pid2, handler.vehId2DriverId.get(handler.lastLink3EnterEvent.getVehicleId()));
    Assert.assertEquals(
        3600.0 + firstLinkOrLaneTT + laneTTlane1ol + laneTTlane1 + delayOfAgent1,
        handler.lastLink3EnterEvent.getTime(),
        testUtils.EPSILON);
  }