File size: 3,114 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
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import unittest

from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.algo.evaluation import algorithm as evaluation_alg
from pm4py.algo.evaluation.generalization import algorithm as generalization_alg
from pm4py.algo.evaluation.precision import algorithm as precision_alg
from pm4py.algo.evaluation.replay_fitness import algorithm as fitness_alg
from pm4py.algo.evaluation.simplicity import algorithm as simplicity_alg
from pm4py.objects.log.importer.xes import importer as xes_importer
from tests.constants import INPUT_DATA_DIR
from pm4py.objects.conversion.process_tree import converter as process_tree_converter


class ProcessModelEvaluationTests(unittest.TestCase):
    def test_evaluation_pm1(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.apply(os.path.join(INPUT_DATA_DIR, "running-example.xes"))
        process_tree = inductive_miner.apply(log)
        net, marking, final_marking = process_tree_converter.apply(process_tree)
        fitness = fitness_alg.apply(log, net, marking, final_marking)
        precision = precision_alg.apply(log, net, marking, final_marking)
        generalization = generalization_alg.apply(log, net, marking, final_marking)
        simplicity = simplicity_alg.apply(net)
        del fitness
        del precision
        del generalization
        del simplicity

    def test_evaluation_pm2(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.apply(os.path.join(INPUT_DATA_DIR, "running-example.xes"))
        process_tree = inductive_miner.apply(log)
        net, initial_marking, final_marking = process_tree_converter.apply(process_tree)
        metrics = evaluation_alg.apply(log, net, initial_marking, final_marking)
        del metrics

    def test_simplicity_arc_degree(self):
        import pm4py
        net, im, fm = pm4py.read_pnml("input_data/running-example.pnml")
        from pm4py.algo.evaluation.simplicity import algorithm as simplicity_evaluator
        val = simplicity_evaluator.apply(net, variant=simplicity_evaluator.Variants.SIMPLICITY_ARC_DEGREE)


    def test_simplicity_extended_cardoso(self):
        import pm4py
        net, im, fm = pm4py.read_pnml("input_data/running-example.pnml")
        from pm4py.algo.evaluation.simplicity import algorithm as simplicity_evaluator
        val = simplicity_evaluator.apply(net, variant=simplicity_evaluator.Variants.EXTENDED_CARDOSO)


    def test_simplicity_extended_cyclomatic(self):
        import pm4py
        net, im, fm = pm4py.read_pnml("input_data/running-example.pnml")
        from pm4py.algo.evaluation.simplicity import algorithm as simplicity_evaluator
        val = simplicity_evaluator.apply(net, variant=simplicity_evaluator.Variants.EXTENDED_CYCLOMATIC)


if __name__ == "__main__":
    unittest.main()