如何将活动图转换为petrinet,综合然后分析?
我正在做一个关于 Petri 网的项目。
我使用 UML 工具 Umbrello 生成了一个活动图(.xmi 格式)。我需要将其转换为 Petri 网,然后使用工具 Petrify 对其进行合成。但为了将其转换为 Petri 网,必须将活动图转换为 XML 格式。
为了使用 petrify 进行合成,Petri 网必须转换为 .g 格式,然后才转换为 .xml 格式。简而言之,我需要集成 Umbrello、UML2owfn、Petrify 和 PIPE 工具。如何使用 Python 集成这些工具?
I am doing a project on Petri nets.
I have generated an activity diagram (in the .xmi format) using the UML tool Umbrello. I need to convert it to a Petri net and then synthesize it using the tool Petrify. But in order to convert it to the Petri net, the activity diagram has to be converted into the XML format.
In order to synthesize using petrify, the Petri net has to be converted into .g format, and only afterwards to the .xml format. In short I need to integrate the tools Umbrello, UML2owfn, Petrify and PIPE. How could I integrate these tools using Python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论如何,活动图或多或少具有 Petri 网的语义。事情是这样的:您需要首先读取并解析活动图 XML。 Python 中有几个不错的选择;除非您的活动图非常庞大,否则您可能应该选择一种将整个 XML 元素树保留在内存中的活动图。
然后将活动图转换为二分图。由于活动图可以具有没有转换(线)的相邻活动节点(气泡),因此将所有相邻活动节点折叠到 Petri 网中的一处。
Python 中也有 几个图形库,但这相当简单,可能更容易只需将图表示为位置和转换的列表以及边对的列表。
一旦你得到了patri网图,只需运行它来生成Petrify输入,你就应该设置好了。如果您确实需要这些中间表示,则应该使用 SMOP 将它们生成为出色地。
Conveniently activity diagrams more or less have the semantics of Petri Nets anyway. Here's the deal: you will need to read and parse the activity digram XML first. There are several good options for this in Python; unless your activity diagrams are just massive, you should probably choose one that keeps the whole XML element tree in memory.
Then convert the activity diagram into a bipartite graph. Since an activity diagram can have adjacent activity nodes (bubbles) without transitions (lines), collapse all the adjacent activity nodes into one place in the petri net.
There are several graph libraries in Python as well, but this is fairly simple and it may be easier to just represent the graph as lists of places and transitions, and a list of pairs for the edges.
Once you've got the patri net graph, just walk it to generate the Petrify input and you should be set. If yu really need those intermediate representations, it should be a SMOP to generate them as well.