Exemplo n.º 1
0
  /**
   * Calculates the "Behavioral Recall" metric for a given mined model with respect to a log and a
   * reference model.
   *
   * @param model The resulting Petri net generated by a mining algorithm.
   * @param referenceLog The log to be used during the calculation of the behavioral recall value of
   *     the mined model.
   * @param referenceModel The Petri net used to measure behavioral recall of the mined model.
   * @param progress Progress
   * @return The behavioral recall value (<code>[0, 1]</code>) of the mined model. If the behavioral
   *     recall value cannot be calculated, the value <code>BenchmarkMetric.INVALID_MEASURE_VALUE
   *     </code> is returned.
   */
  public double measure(
      PetriNet model, LogReader referenceLog, PetriNet referenceModel, Progress progress) {

    // check precondition: no shared inputs for duplicate tasks
    if (model.hasDuplicatesWithSharedInputPlaces() == true
        || referenceModel.hasDuplicatesWithSharedInputPlaces() == true) {
      return BenchmarkMetric.INVALID_MEASURE_VALUE;
    }

    try {
      HeuristicsNet HNmodel =
          new PetriNetToHeuristicNetConverter()
              .toHeuristicsNet(
                  PetriNetToHeuristicNetConverter.removeUnnecessaryInvisibleTasksFromPetriNet(
                      (PetriNet) model.clone()));
      HeuristicsNet HNreferenceModel =
          new PetriNetToHeuristicNetConverter()
              .toHeuristicsNet(
                  PetriNetToHeuristicNetConverter.removeUnnecessaryInvisibleTasksFromPetriNet(
                      (PetriNet) referenceModel.clone()));
      TraceParsing behavioralMetrics = new TraceParsing(referenceLog, HNreferenceModel, HNmodel);
      return behavioralMetrics.getRecall();
    } catch (Exception e) {
      System.err.println(
          "BehavioralRecallMetric >>> Could not calculate the behavioral recall value!");
      e.printStackTrace();
    }
    return BenchmarkMetric.INVALID_MEASURE_VALUE;
  }