Return to Materials

Cellular automata example

Procedure to install and run the celullar automata illustrative example.

Installation of the environment

Note: it is possible to install all the required tools in your own Eclipse. However, due to possible version incompatibilities of the tools, we recommand to use the ready to use Eclipse package.

  • Get the Eclipse package containing all required tools for your system : https://gemoc.org/download.html
  • Unzip it somewhere on your disk,
  • Lauch the Eclipse executable.

Get the projects

All the sources of the cellular automata illustrative example are available on the following Github repository: https://github.com/mde-book/cellularautomata

  • In Eclipse, go to Window>Open perspective>Git,  clone the following repository https://github.com/mde-book/cellularautomata.git (If you prefer, you are free to fork the repository first). importCellularAutomataProjects
  • In the Git repositories view, right click on the Working directory > import Projects… > Import existing projects (makes sure to check “Search for nested projects”). This will install all the project sources in the Eclipse workspace.Do not worry about the number of projects, there are several variants of the same things that have been developped for the illustrating alternative approaches in the book.
  • Switch to the xDSML or Plug-in Development perspective.
  • Makes sure everything compiles without errors. Click on Project > Clean… in order to help Eclipse rebuild all projects.

If you have a red exclamation point icon on a project, this is typically because, a source folder is missing (usually xtend-gen). In that case, simply create a folder with the expected name.

 

List of the projects

Naming convention of the projects

*.model : contains domain metamodel and diagram (ecore) (for convenience .png file of the diagrams are put there too)

*.cs : contains the grammar for xText textual editors

*.ui :launchers for xText editors (fully generated by xText)

*.edit : contains the EMF support for building editors

*.editor: contains the EMF tree editors

*.design: contains the Sirius diagram specification for diagram editors

other projects : semantic specification, transformation, etc. (may be coded using Kermeta, Java or ATL depending on the section they illustrate in the book)

Project content overview.

A more detailled description of the project content may be available as a readme directly in the source.

For sake of conciseness, o.k.l.s stands for org.kermeta.language.sample, and f.i.d.k.e stands for fr.inria.diverse.k3.example. A refactoring in the future may simplify this by shortening all these names.

  • cellularautomat_sample_models : a set of models in various format (textual, XMI) used to test the Cellular automata language.
  • cellularautomata.acceleo.compiler4mason: acceleo project that compiles evolution rules (CAER) into Java code. The target code use Mason libraries.
  • cellularautomata.acceleo.generateLatex: acceleo project that generates a document in Latex from evolution rules (CAER).
  • f.i.d.k.e.cellularautomata.compiler4mason : Kermate 3 project that compiles evolution rules (CAER) into Java code. The target code use Mason libraries.
  • f.i.d.k.e.cellularautomata.evol.refactoring : Kermate 3 project that refactors evolution rules (CAER) models.
  • f.i.d.k.e.cellularautomata.init.refactoring : Kermate 3 project that refactors evolution rules (CAIR) models.
  • f.i.d.k.e.cellularautomata.simulator : kermeta 3 project that contains the evolution behavior applied on a vm model and implements a simple simulator. Uses  a simple 2D ascii art based visualization of vm models.
  • f.i.d.k.e.cellularautomata.visitorbasedcompiler4mason : Plain Java project that compiles evolution rules (CAER) into Java code. The target code use Mason libraries.
  • f.i.d.k.e.cellularautomata.visitorbasedsimulator : Plain Java project that contains the evolution behavior applied on a vm model and implements a simple simulator. Uses  a simple 2D ascii art based visualization of vm models.
  • f.i.d.k.e.cellularautomata.vm.generator : kermeta 3 project that implements a convenient vm model generator from initialization rules (CAIR) and optional geometry model.
  • f.i.d.k.e.cellularautomata.vm.simple_atl_transfos : ATL project that implements several transformations in ATL on VM models.
  • f.i.d.k.e.cellularautomata.vm.simple_transfos : Kermeta 3 project that implements several transformations on VM models.
  • f.i.d.k.e.cellularautomata.mason.libs : library used by the target code of the compilers (acceleo, Kermeta and plain Java versions).
  • o.k.l.s.cellularautomata.geometry.model : metamodel that defines a universe geometry. (used to build such universe) (+ model.edit project for editor support).
  • o.k.l.s.cellularautomata.rules.core.cs : common reusable grammar (+ cs.ui project for textual editor support).
  • o.k.l.s.cellularautomata.rules.core.model : Metamodel part of the rules which are reusable between initialization and evolution.
  • o.k.l.s.cellularautomata.rules.evolution.cs : text editor and grammar for evolution rules. (deals with *.erule files) (+ cs.ui project for textual editor support).
  • o.k.l.s.cellularautomata.rules.evolution.model : Metamodel for evolution rules.
  • o.k.l.s.cellularautomata.rules.initialization.cs : text editor and grammar for initialization rules. (deals with *.irule files)(+ cs.ui project for textual editor support).
  • o.k.l.s.cellularautomata.rules.initialization.model : Metamodel for initialization rules.
  • o.k.l.s.cellularautomata.vm.design : Sirius project defining a graphical editor for the VM.
  • o.k.l.s.cellularautomata.vm.model : metamodel of the vm, defines a “Universe”, used by the simulator.

 

Run the projects

Depending on the activity you can run and test the project directly in the first Eclipse (I.e. the language workbench). For some other activities, you need to deploy the projects in a second Eclipse (I.e. modeling workbench)

Projects with tests directly in the language workbench

All Kermeta 3  “compiler4mason”, “simulator”, and “refactoring” projects offer a TestXXX class that can be used directly from the language workbench.

All plain Java  “compiler4mason”, “simulator”, and “refactoring” projects offer a TestXXX class that can be used directly from the language workbench.

Projects needing a modeling workbench for testing

  • Texteditors are run by deploying them in a new eclipse (typically in a runtime workbench). right click on the texteditor project, then “run as” > eclipse application.

to test the grammar, the easiest is to copy/paste the samples files present in the *.cs projects or in cellularautomat_sample_models somewhere into the new eclipse workspace. or you can create empty .irule (for initialisation rule) or .erule (for evolution rule) files

  • Graphical editor (sirus) can be tested in both language and modeling workbench. As for textual editor, grabs the examples models from the project cellularautomat_sample_models.

Direct link to the full version of the files presented in the listings of the book

For convenience, we provide the link to the source files for listing related to cellular automata that have been stripped in the book.

5.1 Customized editor code for CAIR.
5.2 Evolution language textual grammar (excerpt).
6.1 Declarative way to create a new model element.
6.2 Imperative way to create a model element.
6.3 Aspect weaving in metamclasses and use of _self.
6.4 In-place transformation example: hard coded Game of Life.
6.5 Insert node transformation example.
6.6 In-place transformation example: von Neumann to Moore.
7.1 Cellular automata visitor context.
7.2 CAER visitor interface.
7.3 Cellular automata operational semantics as visitor (excerpt).
7.4 Cellular automata interpreter main.
7.5 Cellular automata operational semantics using AOP (excerpt).
8.2 Refactoring that extends a dimension of a CAIR model by an increment.
8.5 Starting part of the refactoring transformation of conditions in evolution rules (excerpt).
8.6 Aspect part of the refactoring transformation of conditions in evolution rules (excerpt).
9.0 Listings of section 9.2 .
9.1 Main template of the Acceleo code generator.
9.2 Subtemplates of the Acceleo code generator.
9.4 Templates producing documentation in LaTex.
9.5 Main operations of the VM generator.
9.6 Aspect part of the VM generator (excerpt).