Exemplo n.º 1
0
  /**
   * Compares the sum of all travel times with the sum of all travel times generated by the
   * C++DEQSim. As {@link #compareToDEQSimEvents(String)} does not function for most comparisons of
   * the JavaDEQSim and C++DEQSim model, we need to compare the time each car was on the road and
   * take its average. This figure should with in a small interval for both simulations. Attention:
   * Still when vehicles are stuck, this comparison can be off by larger number, because unstucking
   * the vehicles is done in different ways by the two simulations
   */
  protected void compareToDEQSimTravelTimes(
      final String deqsimEventsFile, final double tolerancePercentValue) {
    ArrayList<EventLog> deqSimLog = CppEventFileParser.parseFile(deqsimEventsFile);

    double deqSimTravelSum = EventLog.getSumTravelTime(deqSimLog);
    double javaSimTravelSum = EventLibrary.getSumTravelTime(allEvents);
    assertTrue(
        (Math.abs(deqSimTravelSum - javaSimTravelSum) / deqSimTravelSum) < tolerancePercentValue);
  }
Exemplo n.º 2
0
  /**
   * Compare events to deq event file. The order of events must also be the same. (this test will
   * only succeed for simple tests with one car often!!!) => reason: at junctions the order of cars
   * can change + stuck vehicles are dealt with in different ways
   */
  protected void compareToDEQSimEvents(final String deqsimEventsFile) {
    LinkedList<Event> copyEventList = new LinkedList<Event>();

    // remove ActStartEvent and ActEndEvent, because this does not exist in
    // c++ DEQSim
    for (int i = 0; i < allEvents.size(); i++) {
      if (!(allEvents.get(i) instanceof ActivityStartEvent
          || allEvents.get(i) instanceof ActivityEndEvent)) {
        copyEventList.add(allEvents.get(i));
      }
    }

    ArrayList<EventLog> deqSimLog = CppEventFileParser.parseFile(deqsimEventsFile);
    for (int i = 0; i < copyEventList.size(); i++) {
      assertTrue(
          "events not equal.", CppEventFileParser.equals(copyEventList.get(i), deqSimLog.get(i)));
    }
  }