Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

15 pnfrag add whitespace support and petri net export is buggy #16

Merged

Conversation

AdamBanham
Copy link
Owner

@AdamBanham AdamBanham commented Jul 6, 2024

This patch adds white space to the label of transitions for pnfrag and a bug fixes for the exporting pnml that can be read by prom.
Additional prom bits can be exported using a flag but is off by default.

The additionals allow for the example @ https://adamburkeware.net/2021/05/20/petri-net-fragments.html to be reproduced with the following code:

from pmkoalas.models.pnfrag import parse_net_fragments
from pmkoalas.models.petrinet import export_net_to_pnml

from os.path import join

def gen():
    net = parse_net_fragments(
        "burke test model",
        "I -> {register request 1.0} -> p1 -> {examine throughly 1.0} -> p2",
        "I -> {register request 1.0} -> p1 -> {examine casually 10.0} -> p2",
        "I -> {register request 1.0} -> p3 -> {check ticket 1.0} -> p4",
        "p2 -> {decide 1.0} -> p5",
        "p4 -> {decide 1.0} -> p5",
        "p5 -> {pay compensation 1.0} -> F",
        "p5 -> {reject request 2.0} -> F",
        "p5 -> {reinitiate request 1.0} -> p3"
    )
    print(net)
    export_net_to_pnml(
        net,
        join(".", net.name.replace(" ","_").lower()+".pnml"),
        True
    )

if __name__ == "__main__":
    gen()

When visualised the net shows the same layout as before (but I am not sure of the export extension for weights Petri nets).
Visualised layout from ProM of the underlying Petri net:
burke_test
Note that this net eventually deadlocks if the transition 'reinitiate request' is fired. Unsure if the model was intended to have this behaviour, but matches the blog post.

@AdamBanham AdamBanham linked an issue Jul 6, 2024 that may be closed by this pull request
@AdamBanham AdamBanham requested a review from adamburkegh July 6, 2024 06:50
@adamburkegh adamburkegh changed the title 15 pnfrag unable to parse example and petri net export is buggy 15 pnfrag add whitespace support and petri net export is buggy Jul 12, 2024
Copy link
Collaborator

@adamburkegh adamburkegh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch. Better Petri net interoperability will be nice. I suspect it worked at the Java program level but not through the ProM GUI, which is how it went undetected. I can see the whitespace labels being handy too.

I had a question about why UUID ids were desirable or needed.

@adamburkegh
Copy link
Collaborator

There is no special extension for PNML files with weights or other stochastic distribution info.

@adamburkegh
Copy link
Collaborator

I can't remember why that Petri net had a deadlock. I should probably fix it in the blog post as it will irritate PN heads.

@AdamBanham
Copy link
Owner Author

I can't remember why that Petri net had a deadlock. I should probably fix it in the blog post as it will irritate PN heads.

Na let them boil over with rage, then feed off their energy!

@AdamBanham AdamBanham merged commit 1c9a03c into main Aug 25, 2024
4 checks passed
@AdamBanham AdamBanham deleted the 15-pnfrag-unable-to-parse-example-and-petri-net-export-is-buggy branch August 25, 2024 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pnfrag unable to parse example + petri net export is buggy
2 participants