public static double absAverageLinkDiff(ArrayList<EventLog> eventLog1,ArrayList<EventLog> eventLog2){
  HashMap<Integer,Double[]> hm=new HashMap<Integer,Double[]>();
  assert eventLog1.size() == eventLog2.size() : "The size of both eventLogs must be the same!" + eventLog1.size() + " - "+ eventLog2.size();
  for (int i=0; i < eventLog1.size(); i++) {
    int link1=eventLog1.get(i).getLinkId();
    if (!hm.containsKey(link1)) {
      Double[] d=new Double[4];
      d[0]=0d;
      d[1]=0d;
      d[2]=0d;
      d[3]=0d;
      hm.put(link1,d);
    }
    hm.get(link1)[1]=eventLog1.get(i).time - hm.get(link1)[0];
    int link2=eventLog2.get(i).getLinkId();
    if (!hm.containsKey(link2)) {
      Double[] d=new Double[4];
      d[0]=0d;
      d[1]=0d;
      d[2]=0d;
      d[3]=0d;
      hm.put(link2,d);
    }
    hm.get(link2)[3]=eventLog2.get(i).time - hm.get(link2)[2];
  }
  double absSum=0;
  double absAverage=0;
  for (  Double[] d : hm.values()) {
    absSum+=Math.abs(d[1] - d[3]);
  }
  absAverage=absSum / hm.size();
  System.out.println("absSumLink:" + absSum);
  System.out.println("absAverageLinkDiff:" + absAverage);
  return absAverage;
}

public static double absAverageLinkDiff ( ArrayList < EventLog > eventLog1 , ArrayList < EventLog > eventLog2 ) { HashMap < Integer , Double [ ] > hm = new HashMap < Integer , Double [ ] > ( ) ; assert eventLog1 . size ( ) == eventLog2 . size ( ) : "The size of both eventLogs must be the same!" + eventLog1 . size ( ) + " - " + eventLog2 . size ( ) ; for ( int i = 0 ; i < eventLog1 . size ( ) ; i ++ ) { int link1 = eventLog1 . get ( i ) . getLinkId ( ) ; if ( ! hm . containsKey ( link1 ) ) { Double [ ] d = new Double [ 4 ] ; d [ 0 ] = 0d ; d [ 1 ] = 0d ; d [ 2 ] = 0d ; d [ 3 ] = 0d ; hm . put ( link1 , d ) ; } hm . get ( link1 ) [ 1 ] = eventLog1 . get ( i ) . time - hm . get ( link1 ) [ 0 ] ; int link2 = eventLog2 . get ( i ) . getLinkId ( ) ; if ( ! hm . containsKey ( link2 ) ) { Double [ ] d = new Double [ 4 ] ; d [ 0 ] = 0d ; d [ 1 ] = 0d ; d [ 2 ] = 0d ; d [ 3 ] = 0d ; hm . put ( link2 , d ) ; } hm . get ( link2 ) [ 3 ] = eventLog2 . get ( i ) . time - hm . get ( link2 ) [ 2 ] ; } double absSum = 0 ; double absAverage = 0 ; for ( Double [ ] d : hm . values ( ) ) { absSum += Math . abs ( d [ 1 ] - d [ 3 ] ) ; } absAverage = absSum / hm . size ( ) ; System . out . println ( "absSumLink:" + absSum ) ; System . out . println ( "absAverageLinkDiff:" + absAverage ) ; return absAverage ; }
for each link in the event list , find out how long a car has been on that link . then compare the usage time of each link for the two different event logs . print the average ( absolute difference ) : abssumlink and the sum ( absolute difference ) in seconds : absaveragelinkdiff
