0

Im using the pm4py packege in order to simulate a Petri net model using a log. I do this by chosing random traces from the log file and than use induactive_miner to create Petri net for those traces. My goal is to save the Petri net and load it again so the model will stay the same (since any time i get diffrent model). Is there a way to do this?

I have tried to find such an option in the pm4py pakcge but i didn't saw this kind of option.

1 Answers1

0

You can use the pm4py.read_pnml() and pm4py.write_pnml() functions.

Example:

import pm4py

# Create your Petri net (pn), initial marking (im) and final marking (fm)
# ...


path = "my/path/petri_net.pnml"
pm4py.write_pnml(pn, im, fm, path)

# Read the file in later

pn2, im2, fm2 = pm4py.read_pnml(path)

Official docs:
https://pm4py.fit.fraunhofer.de/static/assets/api/2.5.0/generated/pm4py.read.read_pnml.html
https://pm4py.fit.fraunhofer.de/static/assets/api/2.5.0/generated/pm4py.write.write_pnml.html

Kristo_R
  • 167
  • 1
  • 13