Code Generation (Petri nets + Python) 

  Assignment Goal

The goal of this assignment is to do generate code for two different platforms. The first is PNML, to do analysis on the Petrinet models resulting from the denotational mapping of the previous exercise. There are three steps involved:
  1. Export the Petrinet model to metaDepth (using the provided exporter).
  2. Write an exporter using the Epsilon Generation Language (EGL) that exports the Petrinet model from metaDepth to PIPE.
  3. Perform analysis on the PIPE model.
The second is Python, by generating code that will actually create your modelled RPG world map and all its elements. For this, a Python framework is provided. This task also consists of three steps:
  1. Export the RPGGame metamodel and your example model(s) to metaDepth (using the provided exporter).
  2. Write an exporter using the Epsilon Generation Language (EGL) that exports the RPGGame model from metaDepth to Python.
  3. Run the game!
The task is split up in the following parts:
  • Create a realistic example of a RPGame. Additionally, think of at least three invariants for this model. The goal is to check these invariants on your model. You will do this by transforming your model to a Petrinet (using your rule-based transformation from exercise 4), export this to metaDepth and generate the PIPE model, open this model in PIPE and do your checks using that tool.
  • On top of this example, create test models that test all requirements of this assignment (for both the PNML and Python generation). Make sure that your test cases maximise your confidence in the correctness of the implementation of these requirements, so keep your test coverage in mind.
  • Write a report that:
    • explains the particularities of your solution and the difficulties you encountered;
    • sums up the desirable results for all your test cases (in the form of text/image).

The deadline for this assignment is November 29, 2013, 23:59. You will have to submit your solution (metaDepth exporters, examples, tests, and report) to Blackboard.

  Manual

Installation:

  1. Under "Useful Links", you will find a download link for a file called "exported_to_md.zip". Unzip this file in your root AToMPM directory. This will create a folder called "exported_to_md" containing an RPGGame folder, files needed for code generation, and metaDepth.jar. Careful: this is another version of metaDepth.
  2. Also under "Useful Links", download the "metadepth_exporter.zip" file. Extract its contents in your AToMPM/plugins directory. This will create two files: "exportmtomd.js" and "exportmmtomd.js"
  3. Lastly, download "metadepth_exporter_toolbar.zip" and unzip it in the Toolbars folder under your user directory. This will create a folder called "MetaDepth" in your Toolbars folder.

Usage (PNML Generation):

  1. Generate your Petrinet model using your rule-based model transformation for denotational semantics.
  2. Remove all traceability links and RPG game elements by closing the respective toolbars.
  3. Load the MetaDepth toolbar (inside of the MetaDepth folder, it is called Export.buttons.model). This toolbar has two buttons: one for exporting models, and one for exporting metamodels. Normally, you will only need the first one, as the exported PN metamodel is already present in the "exported_to_md" folder.
  4. Click on the button for exporting models, and leave the name alone (the exported model should be called "exported.mdepth"). Click OK. This will generate a file with name "exported.mdepth" in the "exported_to_md" folder.
  5. Write your EGL code in the file "generate_pnml.egl" (initially empty). This file should generate a valid PNML model. For more information on PNML, see the "Useful Links" section.
  6. To actually generate the PNML file, execute the command "java -jar metaDepth.jar < commandlist_pnml" inside of the "exported_to_md" folder. This will generate a "exported.xml" file.
  7. Load the "exported.xml" file in PIPE, and perform your analysis.

Usage (Python Generation):

  1. Using the MetaDepth toolbar, export your RPG game metamodel. You do this by loading your metamodel (as a model), loading the toolbar and clicking on the "Export MetaModel" button. In the input dialog, write the name of your compiled metamodel (for example, "RPGGame").
  2. Export the model you want to generate code for using the "Export Model" button. Leave the name alone (the exported model should be called "exported.mdepth").
  3. Write your EGL code in the file "generate_python.egl" (initially empty). This file should generate a valid Python file, which creates your world map. For more information on PNML, see the "Useful Links" section. For an example of a valid game file, look at game.py in the RPGGame folder. Feel free to make modifications to the RPGGame framework to suit your needs!
  4. To actually generate the Python file, execute the command "java -jar metaDepth.jar < commandlist_python" inside of the "exported_to_md" folder. This will generate a "game.py" file. To run your game, run "python game.py" in your console.

  Useful Links