/** * 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); }
public void testGetAverageTravelTime(){ LinkedList<Event> events=new LinkedList<Event>(); events.add(new PersonDepartureEvent(20, Id.create("2", Person.class), Id.create("0", Link.class), TransportMode.car)); events.add(new PersonArrivalEvent(30, Id.create("2", Person.class), Id.create("0", Link.class), TransportMode.car)); events.add(new PersonDepartureEvent(90, Id.create("1", Person.class), Id.create("0", Link.class), TransportMode.car)); events.add(new PersonArrivalEvent(110, Id.create("1", Person.class), Id.create("0", Link.class), TransportMode.car)); assertEquals(30.0, EventLibrary.getSumTravelTime(events), EPSILON); }