Ejemplo n.º 1
0
  private HNSubSet getTasksWithEmptyOutputPlaces(int task) {

    HNSubSet tasksEmptyOutPlaces;
    HNSubSet inputTasks;

    int inputTask;
    HNSet outputSubsets;

    inputTasks = hNet.getAllElementsInputSet(task);

    tasksEmptyOutPlaces = new HNSubSet();

    for (int iInputTasks = 0; iInputTasks < inputTasks.size(); iInputTasks++) {
      inputTask = inputTasks.get(iInputTasks);
      outputSubsets = auxMapping.getRelatedSubsets(task, inputTask);
      if (outputSubsets != null) {
        if (!allSubsetsAreMarked(inputTask, outputSubsets)) {
          tasksEmptyOutPlaces.add(inputTask);
        }
      } else {
        tasksEmptyOutPlaces.add(inputTask);
      }
    }

    return tasksEmptyOutPlaces;
  }
Ejemplo n.º 2
0
  /**
   * Removes one token from the marked output places (subsets) of the tasks in <i>tasks</i> that
   * contain <i>element</i>.
   *
   * @param element element to fire
   * @param tasks whose output places point to element
   */
  private void removeTokensOutputPlaces(int element, HNSubSet tasks) {

    HNSubSet subset = null;
    HNSet subsets = null;

    Integer tokens = null;
    int taskToFire;
    int task;

    // Checking if element is a start element
    if (hNet.getInputSet(element).size() == 0) {
      if (startPlace > 0) {
        startPlace--;
        numberTokens--;
      }
    } else {
      taskToFire = element;
      for (int iTasks = 0; iTasks < tasks.size(); iTasks++) {
        task = tasks.get(iTasks);
        subsets = auxMapping.getRelatedSubsets(taskToFire, task);
        if (subsets != null) {
          for (int iSubsets = 0; iSubsets < subsets.size(); iSubsets++) {
            subset = subsets.get(iSubsets);
            tokens = getNumberTokens(task, subset);
            if (tokens.intValue() > 0) {
              decreaseNumberTokens(task, subset);
              numberTokens--;
            }
          }
        }
      }
    }
  }