Code Generation (Petri nets + Python)
|
The goal of this assignment is to generate code for two different platforms. The first is CPNTools, to do analysis on the Petrinet models resulting from the denotational mapping of the previous exercise. The second is Python, by generating code that will actually create your modelled railway network and all its elements. For this, a Python framework is provided.
Write a report that includes a clear explanation of your complete solution, as well as an explanation of your testing process. Please also mention possible difficulties you encountered during the assignment, and how you solved them. You will have to complete this assignment in groups of 2. Submit your assignment (report in pdf, abstract and concrete syntax denition, example models, all rule-based model transformations, and code generators) on Blackboard before November 27, 13:00h.
Contact Simon Van Mierlo (simon.vanmierlo@uantwerpen.be) if you have a question.
is section lists the requirements for the code generation assignment. They are split into two sections: one for CPNTools, and one for Python. Make sure to provide test models for each part, demonstrating the functionality you implemented!
Installation: Download exported_to_md.zip. Unzip this file in your root AToMPM directory. This will create a folder called "exported_to_md" containing a railway folder, files needed for code generation, and metaDepth.jar. Careful: this is another version of metaDepth.
CPNTools allows you to generate the reachability graph for a given Petrinet. First of all, open the State space tool, which will show the following palette:
Click the top-left button, and then click on your Petrinet. This will calculate the reachability graph of the Petrinet, and allow you to perform analysis.
CPNTools allows to query the reachability graph, and you will have to create an appropriate query to decide whether the two trains in your model can be scheduled independently. You can write the query as a string (text) in CPNTools, and evaluate it as an ML expression. Documentation on the functions you can use can be found in the following [PDF]. The easiest way to go about this is to try and find a node in the reachability graph for which the condition is not satised: if such a node can be found, your query will return it, and the trains cannot be scheduled independently. If no such node is found, the trains can be scheduled independently. Use the SearchNodes function, and use the Mark facility to check the markings of specic places in the nodes of the reachability graph in the condition passed to your call to SearchNodes. Please note that Mark has its limitations: it is not possible to check the markings of all places without knowing their name. You have to hard-code the name of the place as in Mark.exported'myPlace 1 n ('myPlace' cannot be a variable). This will probably force you to manually adapt your query whenever another exported model is being checked. Please explain the workflow for checking the condition on any railway model in your report.