EZ Petri

Posted on December 28, 2019

I am happy to announce the release of EZ Petri, a web-based tool for editing and analyzing Petri nets. I really want to put this out in the wild, so this is just going to be a short run-down of how to use it.

First of all, you should read my earlier blog posts to understand how Petri nets work, particularly Petri Nets for Computer Scientists to understand the data model and Petri Nets in Action to get an idea of how the analysis works, and to get ideas for how to model real-world problems with Petri nets.

Hopefully, EZ Petri should be pretty intuitive. The sliders on the left and the graph are exactly the same as in Petri Nets in Action. In the matrix, you can add new species and new transitions with the “+” buttons and remove them with the “-” buttons. To name your species and transitions, you can simply type in the boxes at the top of each column and at the side of each row. Then, to configure the inputs and outputs of each transition, you can change the numbers within the matrix.

The plot has two modes: “Live Updating” and “Manual Updating”. You can switch between these two modes by clicking the button below the plot; this also displays the current mode. In “Live Updating”, every change you make refreshes the plot automatically. This is very useful, but can sometimes overload your computer because it has to numerically solve a differential equation every time it draws the plot. In “Manual Updating”, it only draws the plot when you click “Refresh”, so you can make changes to the Petri net and then hit “Refresh” to plot it.

In the menu bar you can use “Toggle Source” to get access to the data underlying the current Petri net. If you want to save and share your Petri net, you can copy this code. Pasting the code back into the window and clicking “Toggle Source” again will load the editor with your Petri net. Here are some example Petri nets to get you started; copy and paste these into the source area to play with them!

Exponential Growth:

{"petri_net":{"name":"Exponential Growth","transitions":[{"name":"Growth","input":[1],"output":[2]}],"species":["Amoeba"]},"controls":{"init_vals":[0.21],"rates":[0.29],"xmax":10.0,"ymax":5.0,"scale":5.0}}

Constrained Food

{"petri_net":{"name":"Constrained Food","transitions":[{"name":"Food Grow","input":[0,0],"output":[1,0]},{"name":"Splitting","input":[1,1],"output":[0,2]},{"name":"Death","input":[0,1],"output":[0,0]}],"species":["Food","Amoeba"]},"controls":{"init_vals":[2.52,2.26],"rates":[1.53,1.79,2.52],"xmax":10.0,"ymax":5.0,"scale":5.0}}

Predator Prey

{"petri_net":{"name":"Predator Prey","transitions":[{"name":"Birth","input":[1,0],"output":[2,0]},{"name":"Death","input":[0,1],"output":[0,0]},{"name":"Predation","input":[1,1],"output":[0,2]}],"species":["Rabbit","Wolf"]},"controls":{"init_vals":[2.52,1.58],"rates":[3.97,4.35,3.63],"xmax":10.0,"ymax":5.0,"scale":5.0}}

If you are interested, the source is on github, and if you find any bugs, please report them there!

The eventual goal for this is to replace the transition matrix with an editor for the graphical version of Petri nets, however I wanted to have a complete bit of software done before I started mucking around with graph editing.


Site proudly generated by Hakyll with stylistic inspiration from Tufte CSS