private HNSubSet getAllOutputElementsOfDuplicates(HNSubSet duplicates) {
    // Returns the union set of the output tasks of the tasks in
    // "duplicates".
    // The returned union set has already the codes mapped to the ATEs in
    // the log!
    HNSubSet union = new HNSubSet();
    HNSubSet allElements;

    for (int i = 0; i < duplicates.size(); i++) {
      allElements = hNet.getAllElementsOutputSet(duplicates.get(i));
      for (int j = 0; j < allElements.size(); j++) {
        union.add(hNet.getDuplicatesMapping()[allElements.get(j)]);
      }
    }

    return union;
  }
  private int identifyDuplicateToFire(HNSubSet duplicates, int elementInATE) {

    HNSubSet candidateDuplicates = new HNSubSet();
    HNSubSet allElements;

    for (int i = 0; i < duplicates.size(); i++) {
      allElements = hNet.getAllElementsOutputSet(duplicates.get(i));
      for (int j = 0; j < allElements.size(); j++) {
        if (elementInATE == hNet.getDuplicatesMapping()[allElements.get(j)]) {
          candidateDuplicates.add(duplicates.get(i));
          break;
        }
      }
    }

    if (candidateDuplicates.size() <= 0) {
      candidateDuplicates = duplicates; // we can choose any of the tasks
      // because none has
      // followers in the process instance...
    }

    return candidateDuplicates.get(generator.nextInt(candidateDuplicates.size()));
  }
 private void addToPossiblyEnabledElements(int element) {
   HNSubSet subset = hNet.getAllElementsOutputSet(element);
   for (int i = 0; i < subset.size(); i++) {
     possiblyEnabledElements.add(subset.get(i));
   }
 }