Esempio n. 1
0
 def test_importingPetriLogAlignment(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     imported_petri1, marking1, fmarking1 = petri_importer.import_net(
         os.path.join(INPUT_DATA_DIR, "running-example.pnml"))
     soundness = check_soundness.check_petri_wfnet_and_soundness(
         imported_petri1)
     del soundness
     log = xes_importer.import_log(
         os.path.join(INPUT_DATA_DIR, "running-example.xes"))
     final_marking = petri.petrinet.Marking()
     for p in imported_petri1.places:
         if not p.out_arcs:
             final_marking[p] = 1
     for trace in log:
         cf_result = state_equation_a_star.apply(trace, imported_petri1,
                                                 marking1,
                                                 final_marking)['alignment']
         is_fit = True
         for couple in cf_result:
             if not (couple[0] == couple[1]
                     or couple[0] == ">>" and couple[1] is None):
                 is_fit = False
         if not is_fit:
             raise Exception("should be fit")
Esempio n. 2
0
 def test_alignment_pnml(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     trace_log = xes_importer.import_log(
         os.path.join(INPUT_DATA_DIR, "running-example.xes"))
     net, marking, final_marking = dfg_only.apply(trace_log, None)
     for trace in trace_log:
         cf_result = state_equation_a_star.apply(trace, net, marking,
                                                 final_marking)['alignment']
         is_fit = True
         for couple in cf_result:
             if not (couple[0] == couple[1]
                     or couple[0] == ">>" and couple[1] is None):
                 is_fit = False
         if not is_fit:
             raise Exception("should be fit")
def alignment_upper_bound_su_trace_bruteforce(behavior_net, bn_i, bn_f, petri_net, initial_marking, final_marking, parameters=None):
    """
    Returns the upper bound for conformance of a strongly uncertain trace against a reference Petri net by aligning all possible realizations.

    :param behavior_net: the behavior net of a strongly uncertain trace
    :param bn_i: the initial marking of the behavior net
    :param bn_f: the final marking of the behavior net
    :param petri_net: the reference Petri net
    :param initial_marking: the initial marking of the reference Petri net
    :param final_marking: the final marking of the reference Petri net
    :param parameters: the optional parameters for alignments
    :return: the alignment results for the upper bound for conformance of the trace
    """

    # Obtains all the realizations of the trace by executing all possible variants from the behavior net
    realization_set = acyclic_net_variants(behavior_net, bn_i, bn_f)

    # Computes the upper bound for conformance via bruteforce on the realization set
    alignments = [apply(trace, petri_net, initial_marking, final_marking, parameters) for trace in realization_set]

    return min(alignments, key=lambda x: x['cost'])
Esempio n. 4
0
 def test_alignment_alpha(self):
     # to avoid static method warnings in tests,
     # that by construction of the unittest package have to be expressed in such way
     self.dummy_variable = "dummy_value"
     log = xes_importer.import_log(
         os.path.join(INPUT_DATA_DIR, "running-example.xes"))
     net, marking, fmarking = alpha_factory.apply(log)
     final_marking = petri.petrinet.Marking()
     for p in net.places:
         if not p.out_arcs:
             final_marking[p] = 1
     for trace in log:
         cf_result = state_equation_a_star.apply(trace, net, marking,
                                                 final_marking)['alignment']
         is_fit = True
         for couple in cf_result:
             if not (couple[0] == couple[1]
                     or couple[0] == ">>" and couple[1] is None):
                 is_fit = False
         if not is_fit:
             raise Exception("should be fit")