Package de.hpi.eworld.simulationstatistic.model

Examples of de.hpi.eworld.simulationstatistic.model.StatLane


    for (EdgeModel edge : edges) {
      StatEdge statEdge = interval.getStatEdge(edge.getInternalID());
      if (statEdge != null) {
        for (int i = 0; i < edge.getNoOfLanes(); i++) {
          StatLane lane = statEdge.getStatLane(i);
          if (lane != null)
            meanList.add(i, lane.getValue(value) / edges.size());
        }
      }
    }

    return meanList;
View Full Code Here


    StatInterval interval0 = model.getInterval(0);
    Assert.assertEquals(3, model.numIntervals());
    Assert.assertEquals(12, interval0.numEdges());
   
    //TODO: test single lane
    StatLane lane1 = interval0.getStatLane("1si_0");
    Assert.assertEquals(51.64, lane1.getValue(Value.TRAVELTIME), 0);
    Assert.assertEquals(2177.05, lane1.getValue(Value.SAMPLEDSECONDS), 0);
    Assert.assertEquals(10.2, lane1.getValue(Value.DENSITY), 0);
    Assert.assertEquals(5.1, lane1.getValue(Value.OCCUPANCY), 0);
    Assert.assertEquals(963, lane1.getValue(Value.NRSTOPS),0);
    Assert.assertEquals(4.59, lane1.getValue(Value.SPEED), 0);
    Assert.assertEquals(44, lane1.getValue(Value.VEHICLESENTERED),0);
    Assert.assertEquals(0, lane1.getValue(Value.VEHICLESEMITTED),0);
    Assert.assertEquals(42, lane1.getValue(Value.VEHICLESLEFT),0);
    /*
     <edge id="1si">
         <lane id="1si_0" traveltime="51.64" sampledSeconds="2177.05"
          density="10.20" occupancy="5.10" noStops="963"
          speed="4.59" entered="44" emitted="0" left="42"/>
View Full Code Here

   *            {@link StatLane#getExternalId()}.
   * @return a new StatLane object
   * @throws Exception if invalid id was used
   */
  public static StatLane createTestStatLane(String id) throws Exception {
    StatLane lane = new StatLane(id, 100 * Math.random(), 1000 * Math.random(), 100 * Math.random(), 100 * Math.random(),
        100 * Math.random(), (int) (100 * Math.random()), (int) (100 * Math.random()), (int) (100 * Math.random()),
        (int) (100 * Math.random()));
    lane.setMaxSpeed(100 * Math.random());
    lane.setMinSpeed(10 * Math.random());
    lane.setStreetName("street" + (int) (Math.random() * 100));
    return lane;
  }
View Full Code Here

    }

    // create 1..10 child lanes if requested
    if (withChildLanes) {
      try {
        StatLane lane;
        // number of lanes == numLanes, unless numLanes==0
        int num = (numLanes == RANDOM_NUMBER_LANES) ? (int) ((Math.random() * 9) + 1) : numLanes;
        for (int i = 0; i < num; i++) {
          lane = createTestStatLane(edgeId + "_" + i);
          edge.addStatLane(lane);
View Full Code Here

    if (!checkBelongToMap(edges, dataset, true))
      return;

    EdgeModel edge;
    StatLane statLane;

    for (StatInterval interval : dataset.getIntervals()) {
      for (StatEdge statEdge : interval.getStatEdges()) {

        if ((edge = edges.get(statEdge.getId())) == null) {
          continue;
        } else {
          // retrieve lane info
          List<LaneModel> lanes = edge.getLanes();
          List<StatLane> statLanes = statEdge.getStatLanes();
          if (((lanes.size() == 1) && (statEdge.numLanes() == 0))
              || (lanes.size() == statEdge.numLanes())) {
            for (int i = 0; i < statLanes.size(); i++) {
              statLane = statLanes.get(i);
              statLane.setStreetName(edge.getParentWay()
                  .getDescription());
              statLane.setMaxSpeed(lanes.get(i).getMaxSpeed() / 3.6);
              statLane.setMinSpeed(lanes.get(i).getMinSpeed() / 3.6);
            }
          } else {
            continue;
          }
          // retrieve edge info
View Full Code Here

  }

  @Test
  public void testChildLanes() {
    StatEdge edge1 = new StatEdge("dummy1");
    StatLane lane1;
    try {
      lane1 = TestCaseUtil.createTestStatLane("dummy1_0");
    StatLane lane2 = TestCaseUtil.createTestStatLane("dummy1_1");
    Assert.assertEquals(0, edge1.numLanes());
    Assert.assertEquals(0, edge1.getStatLanes().size());
    edge1.addStatLane(lane1);
    Assert.assertEquals(1, edge1.numLanes());
    Assert.assertEquals(1, edge1.getStatLanes().size());
    edge1.addStatLane(lane2);
    Assert.assertEquals(2, edge1.numLanes());
    Assert.assertEquals(2, edge1.getStatLanes().size());

    Assert.assertSame(lane1, edge1.getStatLane(lane1.getId()));
    Assert.assertSame(lane2, edge1.getStatLane(lane2.getId()));
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail();
    }
  }
View Full Code Here

    Assert.assertFalse(edge1.hasValues());
    Assert.assertEquals(0, edge1.numLanes());

    try {
      StatLane lane1 = new StatLane("dummy1_0", 6.0, 100.0, 9.0, 14.4,
          22.7, 4, 6, 3, 9);
      lane1.setMaxSpeed(30.0);
      lane1.setMinSpeed(5.0);
      StatLane lane2 = new StatLane("dummy1_1", 10.0, 200.0, 2.0, 7.2,
          20.1, 0, 8, 0, 8);
      lane2.setMaxSpeed(60.0);
      lane2.setMinSpeed(0.0);
      edge1.addStatLane(lane1);
      edge1.addStatLane(lane2);
      Assert.assertEquals(2, edge1.numLanes());
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail();
    }

    // edge should have mean data of his child lanes, as soon as first
    // value is accessed
    Assert.assertEquals(8.0, edge1.getValue(Value.TRAVELTIME));

    Assert.assertTrue(edge1.hasValues());

    Assert.assertEquals(150.0, edge1.getValue(Value.SAMPLEDSECONDS));
    Assert.assertEquals(5.5, edge1.getValue(Value.DENSITY));
    Assert.assertEquals(10.8, edge1.getValue(Value.OCCUPANCY));
    Assert.assertEquals(21.4, edge1.getValue(Value.SPEED));
    Assert.assertEquals(2, edge1.getValue(Value.NRSTOPS),0);
    Assert.assertEquals(7, edge1.getValue(Value.VEHICLESENTERED),0);
    Assert.assertEquals(1, edge1.getValue(Value.VEHICLESEMITTED),0);
    Assert.assertEquals(8, edge1.getValue(Value.VEHICLESLEFT),0);
    Assert.assertEquals(45.0, edge1.getValue(Value.MAXSPEED),0);
    Assert.assertEquals(2.5, edge1.getValue(Value.MINSPEED),0);

    // test edge without child lanes
    StatEdge edge2 = new StatEdge("dummy1");
    Assert.assertEquals(0.0, edge2.getValue(Value.TRAVELTIME));
    Assert.assertEquals(0.0, edge2.getValue(Value.SAMPLEDSECONDS));
    Assert.assertEquals(0.0, edge2.getValue(Value.DENSITY));
    Assert.assertEquals(0.0, edge2.getValue(Value.OCCUPANCY));
    Assert.assertEquals(0.0, edge2.getValue(Value.SPEED));
    Assert.assertEquals(0, edge2.getValue(Value.NRSTOPS),0);
    Assert.assertEquals(0, edge2.getValue(Value.VEHICLESENTERED),0);
    Assert.assertEquals(0, edge2.getValue(Value.VEHICLESEMITTED),0);
    Assert.assertEquals(0, edge2.getValue(Value.VEHICLESLEFT),0);

    Assert.assertFalse(edge2.hasValues());
    Assert.assertEquals(0, edge2.numLanes());

    // test edge with values AND childs
    // should return values of edge only, no mean values
    StatEdge edge3 = new StatEdge("dummy3", 10.0, 200.0, 8.9, 14.4, 22.7,
        4, 6, 3, 9);
    Assert.assertEquals("dummy3", edge3.getId());
    Assert.assertEquals(10.0, edge3.getValue(Value.TRAVELTIME));
    Assert.assertEquals(200.0, edge3.getValue(Value.SAMPLEDSECONDS));
    Assert.assertEquals(8.9, edge3.getValue(Value.DENSITY));
    Assert.assertEquals(14.4, edge3.getValue(Value.OCCUPANCY));
    Assert.assertEquals(22.7, edge3.getValue(Value.SPEED));
    Assert.assertEquals(4, edge3.getValue(Value.NRSTOPS),0);
    Assert.assertEquals(6, edge3.getValue(Value.VEHICLESENTERED),0);
    Assert.assertEquals(3, edge3.getValue(Value.VEHICLESEMITTED),0);
    Assert.assertEquals(9, edge3.getValue(Value.VEHICLESLEFT),0);

    Assert.assertTrue(edge3.hasValues());
    Assert.assertEquals(0, edge3.numLanes());

    // add two lanes
    try {
      StatLane lane3 = new StatLane("dummy1_0", 6.0, 100.0, 9.0, 14.4,
          22.7, 4, 6, 3, 9);
      lane3.setMaxSpeed(30.0);
      lane3.setMinSpeed(5.0);
      StatLane lane4 = new StatLane("dummy1_1", 10.0, 200.0, 2.0, 7.2,
          20.1, 0, 8, 0, 8);
      lane4.setMaxSpeed(60.0);
      lane4.setMinSpeed(0.0);
      edge3.addStatLane(lane3);
      edge3.addStatLane(lane4);
      Assert.assertEquals(2, edge1.numLanes());
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  @Test
  public void testLaneCreation() {
    // lane with values and valid id

    try {
      StatLane lane1 = new StatLane("dummy1_0", 10.0, 200.0, 8.9, 14.4,
          22.7, 4, 6, 3, 9);
      Assert.assertEquals("dummy1_0", lane1.getExternalId());
      Assert.assertEquals(10.0, lane1.getValue(Value.TRAVELTIME));
      Assert.assertEquals(200.0, lane1.getValue(Value.SAMPLEDSECONDS));
      Assert.assertEquals(8.9, lane1.getValue(Value.DENSITY));
      Assert.assertEquals(14.4, lane1.getValue(Value.OCCUPANCY));
      Assert.assertEquals(22.7, lane1.getValue(Value.SPEED));
      Assert.assertEquals(4, lane1.getValue(Value.NRSTOPS),0);
      Assert.assertEquals(6, lane1.getValue(Value.VEHICLESENTERED),0);
      Assert.assertEquals(3, lane1.getValue(Value.VEHICLESEMITTED),0);
      Assert.assertEquals(9, lane1.getValue(Value.VEHICLESLEFT),0);
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail();
    }

   
    // test for exceptions when invalid ids are used
    try {
      new StatLane("dummy10", 10.0, 200.0, 8.9, 14.4,
          22.7, 4, 6, 3, 9);
      Assert.fail("An error should have occured, because of " +
          "invalid StatLane id");
    } catch (Exception e) {
      //do nothing
    }
   
    try {
      new StatLane("dummy1_", 10.0, 200.0, 8.9, 14.4,
          22.7, 4, 6, 3, 9);
      Assert.fail("An error should have occured, because of " +
          "invalid StatLane id");
    } catch (Exception e) {
      //do nothing
    }
   
    try {
      new StatLane("_0", 10.0, 200.0, 8.9, 14.4,
          22.7, 4, 6, 3, 9);
      Assert.fail("An error should have occured, because of " +
          "invalid StatLane id");
    } catch (Exception e) {
      //do nothing
    }
   
    try {
      new StatLane("dummy1_bla", 10.0, 200.0, 8.9, 14.4,
          22.7, 4, 6, 3, 9);
      Assert.fail("An error should have occured, because of " +
          "invalid StatLane id");
    } catch (Exception e) {
      //do nothing
View Full Code Here

  }

  @Test
  public void testIds() {
    try {
      StatLane lane1 = new StatLane("dummy1_0", 10.0, 200.0, 8.9, 14.4,
          22.7, 4, 6, 3, 9);
      Assert.assertEquals("dummy1_0", lane1.getExternalId());
      Assert.assertEquals(0, lane1.getId());
      Assert.assertEquals("dummy1", lane1.getParentEdgeId());
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail();
    }
  }
View Full Code Here

  public void edgeLaneGetterTest() {
    StatInterval interval1 = new StatInterval("dummy1", 0, 200);

    // setup test case
    StatEdge edge1 = TestCaseUtil.createTestStatEdge(false, false, 0, null);
    StatLane lane10, lane11, lane12;
    try {
      lane10 = TestCaseUtil.createTestStatLane(edge1.getId() + "_0");
      lane11 = TestCaseUtil.createTestStatLane(edge1.getId() + "_1");
      lane12 = TestCaseUtil.createTestStatLane(edge1.getId() + "_2");
      edge1.addStatLane(lane10);
      edge1.addStatLane(lane11);
      edge1.addStatLane(lane12);
      interval1.addStatEdge(edge1);

      StatEdge edge2 = TestCaseUtil.createTestStatEdge(false, false, 0, null);
      StatLane lane20, lane21;
      lane20 = TestCaseUtil.createTestStatLane(edge2.getId() + "_0");
      lane21 = TestCaseUtil.createTestStatLane(edge2.getId() + "_1");
      edge2.addStatLane(lane20);
      edge2.addStatLane(lane21);
      interval1.addStatEdge(edge2);

      // start testing
      Assert.assertEquals(2, interval1.numEdges());
      Assert.assertEquals(5, interval1.numLanes());
      Assert.assertSame(edge1, interval1.getStatEdge(edge1.getId()));
      Assert.assertSame(edge2, interval1.getStatEdge(edge2.getId()));
      Assert.assertSame(lane10, interval1.getStatLane(lane10
          .getExternalId()));
      Assert.assertSame(lane11, interval1.getStatLane(lane11
          .getExternalId()));
      Assert.assertSame(lane12, interval1.getStatLane(lane12
          .getExternalId()));
      Assert.assertSame(lane20, interval1.getStatLane(lane20
          .getExternalId()));
      Assert.assertSame(lane21, interval1.getStatLane(lane21
          .getExternalId()));
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of de.hpi.eworld.simulationstatistic.model.StatLane

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.