Spaces:
Sleeping
Sleeping
File size: 2,020 Bytes
8097001 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import os
import time
from pm4py.algo.conformance.alignments.petri_net import algorithm as ali
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.objects.petri_net.importer import importer as petri_importer
def testSynchronousDiscountedAlignment():
'''
This function runs an alignment based on the discounted edit distance
By using the synchronous product
:return:
'''
log_path = os.path.join("..", "tests", "input_data", "running-example.xes")
pnml_path = os.path.join("..", "tests", "input_data", "running-example.pnml")
log = xes_importer.apply(log_path)
net, marking, fmarking = petri_importer.apply(pnml_path)
# to see the net :
#vizu(net,marking,fmarking).view()
start=time.time()
alignments1 = ali.apply(log._list[0], net, marking, fmarking,
variant=ali.VERSION_DISCOUNTED_A_STAR,
parameters={ali.Parameters.SYNCHRONOUS:True,ali.Parameters.EXPONENT:1.1})
print(alignments1)
print("Time:",(time.time()-start))
def testNoSynchronousDiscountedAlignment():
'''
This function runs an alignment based on the discounted edit distance
By using the Petri net and petri_net.utils.align_utils.discountedEditDistance function
'''
log_path = os.path.join("..", "tests", "input_data", "running-example.xes")
pnml_path = os.path.join("..", "tests", "input_data", "running-example.pnml")
log = xes_importer.apply(log_path)
net, marking, fmarking = petri_importer.apply(pnml_path)
start=time.time()
alignments1 = ali.apply(log._list[0], net, marking, fmarking,
variant=ali.VERSION_DISCOUNTED_A_STAR,
parameters={ali.Parameters.SYNCHRONOUS:False,ali.Parameters.EXPONENT:1.1})
print(alignments1)
print("Time:",(time.time()-start))
if __name__ == '__main__':
# example on the first trace
testSynchronousDiscountedAlignment()
testNoSynchronousDiscountedAlignment() |