Generate pm4py log using ASP GeneratorΒΆ

ASP log generator uses the decl model which converts the model into abudction logic programming and pass to the clingo. Clingo generates the output which is turned into the pm4py log or can be created a .xes file.

[1]:
!python3 --version
Python 3.11.4
[2]:
import os
import pathlib

from Declare4Py.ProcessMiningTasks.ASPLogGeneration.asp_generator import AspGenerator
from Declare4Py.ProcessModels.DeclareModel import DeclareModel
[3]:
decl_model_1 = "decl_files/Response.decl"
decl_model_2 = "decl_files/MikeModel.decl"
decl_model_3 = "decl_files/reference10.decl"
decl_model_4 = "diagonisis.decl"
decl_folder = "decl_files"

decl_filename = decl_model_4.split(".")[0]
output_file = pathlib.Path(".", f"{decl_filename}.xes")
decl_file = pathlib.Path(".", decl_folder, decl_model_4)
[4]:
# Create Declare model by reading declare model from a file.

model: DeclareModel = DeclareModel().parse_from_file(decl_file)
[5]:
#general Setting

# Number of traces that should be generated
num_of_traces = 20

# Minimum and maximum number of events a trace can contain
(num_min_events, num_max_events) = (2, 5)

[6]:
# Initializing ASP generator with default distributor which is uniform.

asp = AspGenerator(
    model,
    num_of_traces,
    num_min_events,
    num_max_events
)
[7]:
asp.set_number_of_repetition_per_trace(8)  # same trace but with possible different events
[8]:
# Generate the traces and parse the result produced by clingo
asp.run()  # Run accets 1 optional value whether to create file for the ASP generated from given declare model

PM4PY log generated: 160/160 only.
[9]:
# Save file to xes
asp.to_xes(output_file.as_posix())
[ ]:
asp.set_distribution("custom", custom_probabilities=[0.0, 0.9, 0.0, 0.0, 0.1])
[ ]:
asp.run()
[ ]:
asp.to_xes(output_file.as_posix())
[ ]: