transformations.rst 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Model transformations
  2. =====================
  3. A next step in the Modelverse is the use of model transformations.
  4. Model transformations are implemented using RAMification, and are therefore also modelled explicitly.
  5. As such, all previous modelling concepts are again useful.
  6. Specification
  7. -------------
  8. To create a model transformation, users must specify a set of source metamodels and target metamodels.
  9. The model transformation will afterwards get a signature of these models.
  10. To create a simple Petri Net simulation transformation, we use the operation *transformation_add_MT* as follows::
  11. >>> transformation_add_MT({"PN": "PetriNets"}, {"PN": "PetriNets"}, "pn_simulate", open("pn_simulate.mvc", "r").read())
  12. The first dictionary we pass, is the input dictionary: it specifies the name the model elements will get in the LHS, and the expected type of them.
  13. Similarly, the output dictionary specifies the name of output elements and their types.
  14. The actual metamodel in which the model transformation executes is defined as the merger of the keys in both the input and output dictionary.
  15. Note that in the transformation, all types are renamed by prepending the tag of their signature.
  16. For example, all types in the previous model transformation will be renamed by prepending *"PN/"* (e.g., *PN/Place*, *PN/P2T*).
  17. All types are renamed, in order to make multiple inputs with the same type possible.
  18. For example, when combining two models, both of the same type, but one of them being the *master*, it is possible to do the following::
  19. >>> transformation_add_MT({"master": "PetriNets", "slave": "PetriNets"}, {"result": "PetriNets"}, "pn_merge", open("pn_merge.mvc", "r").read())
  20. In this case, the LHS can match specifically for elements of the master (e.g., *master/Place*).
  21. The output dictionary is interesting as well: multiple output models are possible, and these are based on the tags as well.
  22. When model elements do not match any tags, they are ignored.
  23. When a model element matches a tag, it is put into that specific output model.
  24. More information on tags can be found in the *invocation* subsection.
  25. We will now continue on how to specify a model transformation through modelling.
  26. RAMification
  27. ^^^^^^^^^^^^
  28. Explain how RAMification works and what it does.
  29. Specifically, which attributes does it add etc.
  30. Rule specification
  31. ^^^^^^^^^^^^^^^^^^
  32. How to specify a rule
  33. Schedule
  34. ^^^^^^^^
  35. Scheduling constructs
  36. Invocation
  37. ----------
  38. The actual binding is only done later on, upon invocation, and goes as follows::
  39. >>> transformation_execute_MT("pn_simulate", {"PN": "my_pn"}, {"PN": "my_pn"})
  40. In this case, the model transformation takes the model *my_pn* as input for the *pn_simulate* model transformation, and writes out the result in *my_pn*.
  41. As the output model matches the input model, the model transformation is effectively in-place.
  42. For out-place transformations, it is possible to specify a different output model, in which case the model is implicitly copied as well::
  43. >>> transformation_execute_MT("pn_simulate", {"PN": "my_pn"}, {"PN": "my_simulated_pn"})
  44. Model transformation invocation has no effect on the original model in this case.
  45. Also, model transformations always happen on a copy of the original model.
  46. As such, it is also possible to restore the model to before the transformation.
  47. When a model transformation fails (i.e., the schedule ends in a *Failure*), no output models are written and the models are left untouched.
  48. Tracability links
  49. -----------------
  50. How do tracability links work?