fpom / snakes

SNAKES is the Net Algebra Kit for Editors and Simulators
https://snakes.ibisc.univ-evry.fr
Other
88 stars 29 forks source link

Petrinet.draw error #13

Closed amcomb closed 7 years ago

amcomb commented 7 years ago

Hello

I'm trying to draw a simple petri net example extract from SNAKES; a flexible high-level petri nets library (tool paper) We use anaconda package with Spyder 3.1.2 and python 3.6. We've installed graphviz 2.38 and test it, it works.

import snakes.plugins
snakes.plugins.load("gv", "snakes.nets", "nets")
from nets import *

pn=PetriNet("hello world in SNAKES")
pn.add_place(Place("hello",["hello", "salut"]))
pn.add_place(Place("world",["world", "le monde"]))
pn.add_place(Place("sentence"))
pn.add_transition(Transition("concat"))
pn.add_input("hello","concat",Variable("h"))
pn.add_input("world","concat",Variable("w"))
pn.add_output("sentence","concat",Expression("h + ' ' + w"))
pn.draw("hello.png")

error : runfile('C:/Users/ameli/Desktop/sanstitre0.py', wdir='C:/Users/ameli/Desktop') Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/ameli/Desktop/sanstitre0.py', wdir='C:/Users/ameli/Desktop')

File "C:\Users\ameli\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile execfile(filename, namespace)

File "C:\Users\ameli\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/ameli/Desktop/sanstitre0.py", line 19, in pn.draw("hello.png")

File "C:\Users\ameli\Anaconda3\lib\site-packages\snakes\plugins\gv.py", line 239, in draw g.render(filename, engine, debug)

File "C:\Users\ameli\Anaconda3\lib\site-packages\snakes\plugins\gv.py", line 129, in render outfile.write(self.dot())

File "C:\Users\ameli\Anaconda3\lib\site-packages\snakes\plugins\gv.py", line 116, in dot self._dot(),

File "C:\Users\ameli\Anaconda3\lib\site-packages\snakes\plugins\gv.py", line 86, in _dot lines = ["subgraph %s {" % self, self._dot_attr(self.attr, "graph"),

File "C:\Users\ameli\Anaconda3\lib\site-packages\snakes\plugins\gv.py", line 82, in _dot_attr for key, val in attr.items()],

File "C:\Users\ameli\Anaconda3\lib\site-packages\snakes\plugins\gv.py", line 82, in for key, val in attr.items()],

NameError: name 'unicode' is not defined

Any ideas to solve this error ?

himito commented 7 years ago

Hi @amcomb,

Have you tried with Python 2 ? the function unicode() is only for Python 2, it was replaced by str() in Python 3.

Cheers, Jaime

fpom commented 7 years ago

Oops, I did not run the Py3 tests for a long time, and now I did, I discovered several incompatibilities. But this one should be fixed in commit 193114bd86c1da9545ec5ab390858038278cffcf I pushed a minute ago. Tell me if its OK.

But I agree with @himito that using Py2 would be safer if you can. I still must rework the Py3 compatibility.

Cheers, Franck

amcomb commented 7 years ago

I installed Py2.7 and it works now.

Thank you @himito and @fpom Amélie

amcomb commented 7 years ago

Just one more question, have you a simple example of stochastic petri nets ?

Amélie

fpom commented 7 years ago

If you mean model stochastic nets, you can use plugin label to record stochastic information. But there is no plugin to execute such nets, you'll have to do it yourself or export to another tool.

amcomb commented 7 years ago

Thank you Do you know a tool to execute and solve stochastic petri nets ?

fpom commented 7 years ago

I'm not very well informed about stochastic nets tools, maybe you should start with https://www.informatik.uni-hamburg.de/TGI/PetriNets/tools/db.html

fkgl commented 4 years ago

Hi, please, I'm using python 3.8 with Pycharm IDE 2020.1.1 , I'm trying to use snakes but I can't load plugins (snakes.plugins.load("gv", "snakes.nets", "nets") from nets import *) if I pass the mouse on the load the message (You need configured Python 2 SDK to render Epydoc docstrings) is displayed. I don't know if that is the problem or there is another problem I try to install epydoc but the problem is not resolved; please can someone help me?

fpom commented 4 years ago

SNAKES is not completely well ported to Python 3, does it work with Python 2.7?

fkgl commented 4 years ago

@fpom , ok I will try python2.7 thank you