-1

I am face a problem that took me a lot of time and I do not resolve it yet, the problem is how does modelisation look like with Petri nets for an application writen in python? and if there are any exemple of couple of code and Petri nets representation(modelisation) please show me, so thank's for all of you.

I know that Petri nets compose of arrows, states(places) and transitions(events)

Hachour Fouad
  • 52
  • 1
  • 6
  • Too broad of a question. You should try to narrow the question to something more specific. Not "show me how to do this" but "why is this particular code not working?" – MadPhysicist Nov 11 '19 at 19:54
  • Hi! I have python code, I would to reprensente his behaviour in Petri nets, so how can I do this, please? thank's – Hachour Fouad Nov 11 '19 at 21:15

2 Answers2

1

You cannot just translate any random program - no matter what language - into a Petri net model. Models are abstractions, so you have to decide which states of your program are important enough to become part of the model. Then you have to figure out how to represent these states with tokens in places. Then you have to figure out how to describe the state changes with transitions.

Does this sound all too vague to you? That's because your question is too broad. Your Python application could be a text editor, an HTTP server, a particle simulator, a chess game. We cannot help you to create a model without knowing what you're trying to model.

Roland Weber
  • 3,395
  • 12
  • 26
1

It is possible to model the logic of an application as a Petri Net even if you already encoded the application logic in a programming language. It is also possible to create a computer program (e.g. JavaScript) based on a Petri Net model of the application logic.

One way to model an application program as a Petri Net would be to consider the variables of the program as marks of places, weights of inputs or weights of outputs; and computations as logic annotations of inputs, outputs and transitions.

Roland Weber asked a very good question "which states of your program are important enough to become part of the model?" If you consider every variable and every computation as important then you might end up with a model that is too large for this exercise. Thus consider a part of the application program that is small enough for this exercise.

"A Petri Net Model for the Euclidean Algorithm" explains the relations between the variables of a function for the greatest commond divisor with the elements of a Petri Net using a dynamic and interactive diagram and discusses the various annotations associated with the Petri Net model.