示例#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
 /**
  * Ensures that the capacities of the lanes are correctly calculated by the fixture, i.e. the
  * lanes1.1 to lanes2.0 conversion works as expected.
  *
  * @author dgrether
  */
 @Test
 public void testFixture() {
   LaneDefinitions20 lanes = this.fixture.sc.getLanes();
   Assert.assertNotNull(lanes);
   Assert.assertNotNull(lanes.getLanesToLinkAssignments());
   LanesToLinkAssignment20 lanesLink1 = lanes.getLanesToLinkAssignments().get(fixture.id1);
   Assert.assertNotNull(lanesLink1);
   Assert.assertEquals(2, lanesLink1.getLanes().size());
   Lane lane1ol = lanesLink1.getLanes().get(fixture.link1FirstLaneId);
   Assert.assertNotNull(lane1ol);
   Assert.assertEquals(100.1, lane1ol.getStartsAtMeterFromLinkEnd(), testUtils.EPSILON);
   Assert.assertEquals(7200.0, lane1ol.getCapacityVehiclesPerHour(), testUtils.EPSILON);
   Assert.assertEquals(2.0, lane1ol.getNumberOfRepresentedLanes(), testUtils.EPSILON);
   Assert.assertEquals(fixture.laneId1, lane1ol.getToLaneIds().get(0));
   Assert.assertNull(lane1ol.getToLinkIds());
   Lane lane1 = lanesLink1.getLanes().get(fixture.laneId1);
   Assert.assertNotNull(lane1);
   Assert.assertEquals(50.0, lane1.getStartsAtMeterFromLinkEnd(), testUtils.EPSILON);
   Assert.assertEquals(7200.0, lane1.getCapacityVehiclesPerHour(), testUtils.EPSILON);
   Assert.assertEquals(2.0, lane1.getNumberOfRepresentedLanes(), testUtils.EPSILON);
   Assert.assertEquals(2, lane1.getToLinkIds().size());
   Assert.assertNull(lane1.getToLaneIds());
 }
示例#3
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);
  }