コード例 #1
0
 def test_applyAlphaMinerToCSV(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"
     # calculate and compare Petri nets obtained on the same log to verify that instances
     # are working correctly
     log1, net1, marking1, fmarking1 = self.obtainPetriNetThroughAlphaMiner(
         os.path.join(INPUT_DATA_DIR, "running-example.csv"))
     log2, net2, marking2, fmarking2 = self.obtainPetriNetThroughAlphaMiner(
         os.path.join(INPUT_DATA_DIR, "running-example.csv"))
     log1 = sorting.sort_timestamp(log1)
     log1 = sampling.sample(log1)
     log1 = index_attribute.insert_trace_index_as_event_attribute(log1)
     log2 = sorting.sort_timestamp(log2)
     log2 = sampling.sample(log2)
     log2 = index_attribute.insert_trace_index_as_event_attribute(log2)
     petri_exporter.export_net(
         net1, marking1,
         os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     os.remove(os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     self.assertEqual(len(net1.places), len(net2.places))
     self.assertEqual(len(net1.transitions), len(net2.transitions))
     self.assertEqual(len(net1.arcs), len(net2.arcs))
     final_marking = petri.petrinet.Marking()
     for p in net1.places:
         if not p.out_arcs:
             final_marking[p] = 1
     aligned_traces = token_replay.apply_log(log1, net1, marking1,
                                             final_marking)
     self.assertEqual(aligned_traces, aligned_traces)
コード例 #2
0
 def test_applyAlphaMinerToProblematicLogs(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"
     logs = os.listdir(PROBLEMATIC_XES_DIR)
     for log in logs:
         try:
             log_full_path = os.path.join(PROBLEMATIC_XES_DIR, log)
             # calculate and compare Petri nets obtained on the same log to verify that instances
             # are working correctly
             log1, net1, marking1, fmarking1 = self.obtainPetriNetThroughAlphaMiner(
                 log_full_path)
             log2, net2, marking2, fmarking2 = self.obtainPetriNetThroughAlphaMiner(
                 log_full_path)
             self.assertEqual(len(net1.places), len(net2.places))
             self.assertEqual(len(net1.transitions), len(net2.transitions))
             self.assertEqual(len(net1.arcs), len(net2.arcs))
             final_marking = petri.petrinet.Marking()
             for p in net1.places:
                 if not p.out_arcs:
                     final_marking[p] = 1
             aligned_traces = token_replay.apply_log(
                 log1, net1, marking1, final_marking)
             self.assertEqual(aligned_traces, aligned_traces)
         except SyntaxError as e:
             logging.info("SyntaxError on log " + str(log) + ": " + str(e))
         except NoConceptNameException as e:
             logging.info("Concept name error on log " + str(log) + ": " +
                          str(e))
コード例 #3
0
 def test_importingPetriLogTokenReplay(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"))
     trace_log = xes_importer.import_log(os.path.join(INPUT_DATA_DIR, "running-example.xes"))
     aligned_traces = token_replay.apply_log(trace_log, imported_petri1, marking1, fmarking1)
     del aligned_traces
コード例 #4
0
 def test_alphaMinerVisualizationFromXES(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, net, marking, fmarking = self.obtainPetriNetThroughAlphaMiner(
         os.path.join(INPUT_DATA_DIR, "running-example.xes"))
     log = sorting.sort_timestamp(log)
     log = sampling.sample(log)
     log = index_attribute.insert_trace_index_as_event_attribute(log)
     petri_exporter.export_net(net, marking, os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     os.remove(os.path.join(OUTPUT_DATA_DIR, "running-example.pnml"))
     gviz = pn_viz.graphviz_visualization(net)
     self.assertEqual(gviz, gviz)
     final_marking = petri.petrinet.Marking()
     for p in net.places:
         if not p.out_arcs:
             final_marking[p] = 1
     aligned_traces = token_replay.apply_log(log, net, marking, fmarking)
     self.assertEqual(aligned_traces, aligned_traces)