Is there any software for drawing a Petri net and generating any source code from there? The source code could be in any already known programming language...
Slightly less desirable option would be outputting a file with only the description of the Petri net graphs in a text-based file in some open format, like XML or any other data language. I could then write the code generator myself, but at least I would like to avoid gui/graph development part ;))
Thanks
A Petri net is a directed bipartite graph that has two types of elements, places and transitions. Place elements are depicted as white circles and transition elements are depicted as rectangles. A place can contain any number of tokens, depicted as black circles.
Definition. A Petri Net is a graph model for the control behavior of systems exhibiting concurrency in their operation. The graph is bipartite, the two node types being places drawn as circles, and transitions drawn as bars. The arcs of the graph are directed and run from places to transitions or vice versa.
Petri net is a graphical programming language for modeling concurrent systems. It has been mainly used to model artificial systems such as manufacturing systems and communication protocols.
A Petri net consists of four elements: places, transitions, edges, and tokens. Graphically, places are represented by circles, transitions by rectangles, edges by directed arrows, and tokens by small solid (filled) circles. There are a wide variety of extensions to Petri nets.
I am developing y_petri
in Ruby. At the moment being, YPetri can handle visualization (YPetri::Net
class has #visualize
method using Graphviz to draw the net), but not the GUI editing you seem to have in mind. FYI, firstly, GUI editing in Petri nets is less important than it seems.
The data language in use is Ruby itself (more precisely, and internal DSL written in Ruby).
A major issue with Petri nets is, that there is entirely too many kinds of them in existence. YPetri
attempts to be a universal Petri net framework, with 1 kind of places (of arbitrary marking type) and 4 basic types of transitions (timed / timeless x stoichiometric / non-stoichiometric). In addition, there is a fifth kind of transition, assignment transition, that replaces the target places' marking with the return value of its function. I believe that this can be used to describe any dynamic system whatsoever, while being as parsimonious as I was able to make it.
Petri net arcs are understood as relations between transitions and places (they belong to transitions in y_petri
. I found that it is useful to have a way to express also relations between Petri net nodes (places / transitions) than just arcs. For this purpose, I use Ted Nelson's ZZ structure (ZigZag) basically as a replacement for a relational database.
As for the simulation (Petri net execution), general hybrid Petri nets have no faster simulation method available than implicit Euler method (which I call pseudo Euler). This is because a Petri net can be used to implement a Turing machine, for which no general speedup is possible.
If you are willing to operate in Ruby, you can thus describe a Petri net in y_petri
or y_nelson
DSL code. I do not provide conversion to XML, as I do not consider it superior to the source DSL. It would be possible to write such export routine, but I encourage you to use the DSL instead.
I'd look at the CPN Tools. They provide all kinds of construction, analysis, simulation of Colored Petri nets, and claim code generation capabilities.
Check PetriNetSim it is developed in Java, you can draw and simulate simple/colored/timed petrinets. It comes with few examples. You can extend arc and nodes constraints in Java. And finally you can see java classes of the generated petri net
You can grab the source code from github https://github.com/guillem-catala/PetriNetSim
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With