Rule-Based Operational Semantics 

  Practical Information

The goal of this assignment is to build a rule-based transformation for the operational semantics of the railway modelling language in AToMPM.

Use the MoTiF and TransformationRule formalisms in combination with your RAMi fied domain-speci c language to create the rules and schedule of your transformation. Make your operational semantics such that the model is updated visually while executing the transformation.

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 diculties 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 definition, example models, and the complete rule-based transformation) on Blackboard before November 13, 13:00h.

Contact Simon Van Mierlo ( if you have a question.


Operational Semantics

You will model the semantics of a "control room" that regulates the flow of trains on the railway network. The semantics should produce a trace of consecutive snapshots, which show (visually) the dynamic evolution of the system. The goal is to get each train from its start station to its end station according to its schedule, and this in a safe manner. Safety is defined as "no two trains shall be on a given segment during any step (i.e, at any given time)". This means that the control room needs to make sure two trains can never be on the same track, as well as switching turnouts and junctions to the correct position. More detailed rules are listed below:
  • The simulation is broken up into a number of "steps". In each simulation step, the control room first sets all lights to the correct "mode" and switches the direction of turnouts and junctions. After that, all trains are moved to the next segment, if allowed.
  • In the initial simulation step, all trains are placed in their start station. If this initial step leads to an invalid state, such as having more than one train on a single (station) segment, the simulation shall halt with an appropriate error message.
  • A train is allowed to move to the next segment if the light on its current segment is set to green. If the light is red, the train has to wait.
  • If a train is on a turnout, it moves in the direction the turnout is set to. In other words, a train has no access to its schedule and follows the directions set by the control room.
  • The control room iterates over all segments that contain a train. If no train is present on the segment the train wants to move to, it sets the light of the segment the train is currently on to green.
  • If a train is on a turnout, the control room switches the direction to where the train wants to go, by looking at the next step in the schedule of the train. It is an error if there is no step (the schedule has reached the end) when a train wants to leave a turnout.
  • In case of two trains wanting to enter a junction at the same time, the control room chooses one randomly.
  • A train can only enter a junction if the direction of the junction is set correctly.
  • When a train reaches its end station, it is removed from the model.
  • The simulation ends when all trains have reached their end station, or no more moves are possible (the end station is not reachable). The simulation should end with an appropriate message in both cases.

For a more detailed explanation on railway operation and control, take a look at the book by Joern Pachl:

  Useful Links


  • Modelling rules can only be done when your metamodel is compiled to a pattern metamodel (third button on the CompileMenu toolbar). Click on the button, then select your compiled abstract syntax metamodel and click 'ok'. This will create two new files in the same folder as your metamodel, called 'name'.pattern.metamodel and 'name'.defaultIcons.pattern.metamodel, where 'name' is the name of your metamodel.
  • Model your rules using the '/Formalisms/__Transformation__/TransformationRule/' formalism. The name of rule models must start with 'R_'. Contents of the rule are modelled using the pattern metamodel, generated in the previous step.
  • Model the schedule of your transformation using the '/Formalisms/__Transformation__/Transformation/MoTif' formalism. The name of transformation models must start with 'T_'.
  • Actions and Constraints in rule are written in Python, not Javascript.
  • Make sure to fi ll in every action and constraint on a rule and its contents (even when this rule should not do anything - use 'result = True' for conditions, 'pass' for global actions and 'result = getAttr()' for attribute actions).