Process Tree – Generation and Usage

In PM4Py we offer support for process trees (visualization, conversion to Petri net and generation of a log) and a functionality to generate them. In this page, the functionalities are examined.

Generation of process trees

The approach “PTAndLogGenerator”, described by the scientific paper “PTandLogGenerator: A Generator for Artificial Event Data”, has been implemented in the PM4Py library.

The following code can be used to generate a process tree:

from pm4py.algo.simulation.tree_generator import factory as tree_gen_factory
parameters = {}
tree = tree_gen_factory.apply(parameters=parameters)

The supported parameters are the ones supported by the approach:

mode: most frequent number of visible activities (default 20)
min: minimum number of visible activities (default 10)
max: maximum number of visible activities (default 30)
sequence: probability to add a sequence operator to tree (default 0.25)
choice: probability to add a choice operator to tree (default 0.25)
parallel: probability to add a parallel operator to tree (default 0.25)
loop: probability to add a loop operator to tree (default 0.25)
or: probability to add an or operator to tree (default 0)
silent: probability to add silent activity to a choice or loop operator (default 0.25)
duplicate: probability to duplicate an activity label (default 0)
lt_dependency: probability to add a random dependency to the tree (default 0)
infrequent: probability to make a choice have infrequent paths (default 0.25)
no_models: number of trees to generate from model population (default 10)
unfold: whether or not to unfold loops in order to include choices underneath in dependencies: 0=False, 1=True
if lt_dependency <= 0: this should always be 0 (False)
if lt_dependency > 0: this can be 1 or 0 (True or False) (default 10)
max_repeat: maximum number of repetitions of a loop (only used when unfolding is True) (default 10)

Generation of a log out of a process tree

The following code can be used to generate a log, with 100 cases, out of the process tree:

from pm4py.objects.process_tree import semantics
log = semantics.generate_log(tree, no_traces=100)

Conversion into Petri net

The following code can be used to convert the process tree into a Petri net

from pm4py.objects.conversion.process_tree import factory as pt_conv_factory
net, im, fm = pt_conv_factory.apply(tree)

Printing a Process Tree

The following code can be used to print a process tree:


Obtaining as example:

->( *( ->( +( a, X( h, X( j, k ) ) ), f ), b ), ->( *( ->( c, +( i, l ) ), d ), ->( e, g ) ) )

Obtaining a visualization of the Process Tree

The following code can be used to visualize the process tree:

from pm4py.visualization.process_tree import factory as pt_vis_factory
gviz = pt_vis_factory.apply(tree, parameters={"format": "png"})