def test_playout(self): log = xes_importer.apply( os.path.join("input_data", "running-example.xes")) from pm4py.algo.discovery.alpha import algorithm as alpha_miner net, im, fm = alpha_miner.apply(log) from pm4py.algo.simulation.playout import simulator log2 = simulator.apply(net, im, fm)
def play_out(*args: Union[Tuple[PetriNet, Marking, Marking], dict, Counter, ProcessTree], **kwargs) -> EventLog: """ Performs the playout of the provided model, i.e., gets a set of traces from the model. The function either takes a petri net, initial and final marking, or, a process tree as an input. Parameters --------------- args Model (Petri net, initial, final marking) or ProcessTree kwargs Parameters of the playout Returns -------------- log Simulated event log """ if len(args) == 3: from pm4py.objects.petri.petrinet import PetriNet if type(args[0]) is PetriNet: from pm4py.algo.simulation.playout import simulator return simulator.apply(args[0], args[1], final_marking=args[2], **kwargs) elif type(args[0]) is dict or type(args[0]) is Counter: from pm4py.objects.dfg.utils import dfg_playout return dfg_playout.apply(args[0], args[1], args[2], **kwargs) elif len(args) == 1: from pm4py.objects.process_tree.process_tree import ProcessTree if type(args[0]) is ProcessTree: from pm4py.algo.simulation.tree_playout import algorithm return algorithm.apply(args[0], **kwargs) raise Exception("unsupported model for playout")
def generate_process_tree(**kwargs) -> ProcessTree: """ Generates a process tree Parameters ------------- kwargs Parameters of the process tree generator algorithm Returns ------------- model process tree """ from pm4py.algo.simulation.tree_generator import simulator return simulator.apply(**kwargs)
def test_emd_2(self): from pm4py.algo.evaluation.earth_mover_distance import evaluator as earth_mover_distance log = xes_importer.apply( os.path.join("input_data", "running-example.xes")) lang_log = variants_get.get_language(log) net1, im1, fm1 = inductive_miner.apply(log) lang_model1 = variants_get.get_language( simulator.apply( net1, im1, fm1, variant=simulator.Variants.STOCHASTIC_PLAYOUT, parameters={ simulator.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: log })) emd = earth_mover_distance.apply(lang_model1, lang_log)
def execute_script(): M = { ("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01 } L1 = { ("a", "b", "d", "e"): 0.49, ("a", "d", "b", "e"): 0.49, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01 } # the distance between M and L1, that we expect to be zero, is zero according to the EMD emd = earth_mover_distance.apply(M, L1) print("M L1 emd distance:", emd) L2 = { ("a", "b", "e"): 0.5, ("a", "b", "d", "e"): 0.245, ("a", "d", "b", "e"): 0.245, ("a", "c", "d", "e"): 0.005, ("a", "d", "c", "e"): 0.005 } # the distance between M and L2 according to the EMD is 0.1275 (paper value 0.125) emd = earth_mover_distance.apply(M, L2) print("M L2 emd distance:", emd) L3 = { ("a", "b", "d", "e"): 0.489, ("a", "d", "b", "e"): 0.489, ("a", "c", "d", "e"): 0.01, ("a", "d", "c", "e"): 0.01, ("a", "b", "e"): 0.002 } # the distance between M and L3 according to the EMD is 0.0005 (paper value 0.0005), perfect! emd = earth_mover_distance.apply(M, L3) print("M L3 emd distance:", emd) L4 = {("a", "b", "d", "e"): 0.5, ("a", "d", "b", "e"): 0.5} # the distance between M and L4 according to the EMD is 0.005 (paper value 0.005), perfect! emd = earth_mover_distance.apply(M, L4) print("M L4 emd distance:", emd) L5 = {("a", "c", "d", "e"): 0.5, ("a", "d", "c", "e"): 0.5} # the distance between M and L5 according to the EMD is 0.245 (paper value 0.245), perfect! emd = earth_mover_distance.apply(M, L5) print("M L5 emd distance:", emd) log = xes_importer.apply( os.path.join("..", "tests", "input_data", "running-example.xes")) lang_log = variants_get.get_language(log) net0, im0, fm0 = alpha_miner.apply(log) net1, im1, fm1 = inductive_miner.apply(log) lang_model0 = variants_get.get_language( simulator.apply( net0, im0, fm0, variant=simulator.Variants.STOCHASTIC_PLAYOUT, parameters={ simulator.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: log })) lang_model1 = variants_get.get_language( simulator.apply( net1, im1, fm1, variant=simulator.Variants.STOCHASTIC_PLAYOUT, parameters={ simulator.Variants.STOCHASTIC_PLAYOUT.value.Parameters.LOG: log })) emd = earth_mover_distance.apply(lang_model0, lang_log) print("running-example alpha emd distance: ", emd) emd = earth_mover_distance.apply(lang_model1, lang_log) print("running-example inductive emd distance: ", emd)