private double getUtility(List<Event> input, List<Event> output) {

    int totalInterval = 0;
    int sameReleasedInterval = 0;
    int sensitiveInterval = 0;

    for (int i = 1; i < input.size(); i += 2) {

      int st1 = input.get(i - 1).timestamp;
      int et1 = input.get(i).timestamp;
      if (et1 < st1) System.out.println(">>>>BRETTER");
      if (dictionary.isSensitive(input.get(i).state.place, input.get(i).timestamp)) {
        sensitiveInterval += (et1 - st1 + 1);
        continue;
      }
      totalInterval += (et1 - st1 + 1);
      for (int j = 1; j < output.size(); j += 2) {

        int st2 = output.get(j - 1).timestamp;
        int et2 = output.get(j).timestamp;

        if (input.get(i).state.place.id == output.get(j).state.place.id
            && Math.max(st1, st2) < Math.min(et1, et2)) {
          sameReleasedInterval += (Math.min(et1, et2) - Math.max(st1, st2) + 1);
        }
      }
      //            System.out.println(sameReleasedInterval+"="+totalInterval);

    }
    System.out.println(sameReleasedInterval + " : " + totalInterval + " : " + sensitiveInterval);
    if (totalInterval == 0 || totalInterval < sameReleasedInterval) return 1;

    return (double) sameReleasedInterval
        * 1.0
        / totalInterval; // To change body of created methods use File | Settings | File Templates.
  }
  private boolean isSensitive(State x) {

    return dictionary.isSensitive(x.place, x.timeIndex * 30);
  }
  List<Event> doObfuscation(List<Event> input, boolean isPerfect) {
    List<Event> output = new ArrayList<Event>();

    Queue<StateNode> Q = new PriorityQueue<StateNode>();
    List<Event> altEventList = new ArrayList<Event>();
    //        System.out.println(input.size());

    for (int i = 0; i < input.size(); i++) {
      Event event = input.get(i);
      for (int j = 0; j < altEventList.size(); j++) {
        if (altEventList.get(j).timestamp < output.get(output.size() - 1).timestamp
            || altEventList.get(j).timestamp >= input.get(i).timestamp) continue;
        output.add(altEventList.get(j));
      }
      if (event.type.equals("entry")) {
        if (dictionary.isSensitive(event.state.place, event.timestamp)
            || ((i > 0)
                && input.get((i - 1)).state.place.id
                    != output.get(output.size() - 1).state.place.id)) {
          //                    System.out.println(":" + event.state.place.id);
          if (i == 0)
            altEventList =
                getAlternativeEventPath(
                    new State(new Place(1, "1", 0, 0, 100), 0),
                    0,
                    R,
                    M,
                    DT_MAX,
                    input,
                    i,
                    isPerfect);
          else
            altEventList =
                getAlternativeEventPath(
                    output.get(output.size() - 1).state,
                    output.get(output.size() - 1).timestamp,
                    R,
                    M,
                    DT_MAX,
                    input,
                    i,
                    isPerfect);
        } else {
          output.add(event);
          altEventList.clear();
        }

      } else if (event.type.equals("exit")) {
        if (((i > 0) && output.size() > 0 && input.get((i - 1)) != output.get(output.size() - 1))) {
          altEventList =
              getAlternativeEventPath(
                  output.get(output.size() - 1).state,
                  output.get(output.size() - 1).timestamp,
                  R,
                  M,
                  DT_MAX,
                  input,
                  i,
                  isPerfect);
        } else {
          output.add(event);
        }
      }
    }

    return output;
  }