Пример #1
0
  private HNSet getAlreadyMarkedPlaces(HNSet set, int task) {
    HNSet markedPlaces = null;
    HNSubSet subset = null;

    markedPlaces = new HNSet();

    for (int iSet = 0; iSet < set.size(); iSet++) {
      subset = set.get(iSet);
      if (subset.contains(task)) {
        markedPlaces.add(subset);
      }
    }

    return markedPlaces;
  }
Пример #2
0
  /**
   * Fires a element even if it is not enabled. When the element has duplicates, it looks ahead to
   * set which duplicate to fire.
   *
   * <p><b>Note:</b> The element MUST be in the net.
   *
   * @param element element to be fired.
   * @param pi process instance where the element to be fired is.
   * @param elementPositionInPi element position.
   * @return int number of tokens that needed to be added to fire this element.
   */
  public int fire(int element, ProcessInstance pi, int elementPositionInPi) {

    int addedTokens = 0;
    int elementDuplicates;

    if ((hNet.getReverseDuplicatesMapping()[element]).size() == 1) {
      elementDuplicates = hNet.getReverseDuplicatesMapping()[element].get(0);
    } else {
      // identify which duplicate to fire
      HNSubSet duplicates = hNet.getReverseDuplicatesMapping()[element].deepCopy();

      // getting the duplicates that are enabled
      for (int i = 0; i < duplicates.size(); i++) {

        if (!isEnabled(duplicates.get(i))) {
          duplicates.remove(duplicates.get(i));
        }
      }

      if (duplicates.size() > 0) {
        if (duplicates.size() == 1) {
          elementDuplicates = duplicates.get(0);
        } else {
          // getting the output tasks of the duplicates. These output
          // are used to
          // look ahead at the process instance
          HNSubSet unionMappedToATEsCode = getAllOutputElementsOfDuplicates(duplicates);
          AuditTrailEntryList ATEntriesList = pi.getAuditTrailEntryList();
          // advancing the pointer in the ATEntries till the current
          // element + 1

          AuditTrailEntry ATEntry;
          int elementInATE = -1;
          for (int i = elementPositionInPi + 1; i < ATEntriesList.size(); i++) {
            try {
              ATEntry = ATEntriesList.get(i);
              elementInATE =
                  this.hNet
                      .getLogEvents()
                      .findLogEventNumber(ATEntry.getElement(), ATEntry.getType());
              if (unionMappedToATEsCode.contains(elementInATE)) {
                break;
              }

            } catch (IOException ex) {
              break;
            } catch (IndexOutOfBoundsException ex) {
              break;
            }
          }
          elementDuplicates = identifyDuplicateToFire(duplicates, elementInATE);
        }
      } else {
        // because no duplicate is enabled, a random one is chosen to
        // fire...
        elementDuplicates =
            (hNet.getReverseDuplicatesMapping()[element])
                .get(generator.nextInt(hNet.getReverseDuplicatesMapping()[element].size()));
      }
    }

    bestCombination = findBestSetTasks(elementDuplicates);
    addedTokens += bestCombination.getNumberMissingTokens();
    removeTokensOutputPlaces(elementDuplicates, bestCombination.getTasks());
    addTokensOutputPlaces(elementDuplicates);
    addToPossiblyEnabledElements(elementDuplicates);

    // registering the firing of element...
    hNet.increaseElementActualFiring(
        elementDuplicates,
        MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi));
    // updating the arc usage for the individual...
    hNet.increaseArcUsage(
        bestCombination.getElementToFire(),
        bestCombination.getTasks(),
        MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi));

    return addedTokens;
  }