Skip to content

Model plugin ​

Instantiates a metamodel: named objects with property values, linked together. A model is the starting point of an optimisation and the form every solution comes back in.

At a glance ​

Plugin idmodel-service
Display nameModel
DescriptionLanguage support for model definitions (.m and .m_gen files)
Default URL/plugin/model
Sourceapp/packages/service-model, app/packages/language-model, app/packages/editor-model
Depends onThe Metamodel plugin, since every model imports a metamodel

Languages contributed ​

Language idNameExtensionTextual editorGraphical editorGenerated
modelModel.m✅✅❌
model_genGenerated Model.m_gen❌✅✅

The model language ​

A .m file starts by naming its metamodel, then declares objects and the links between them.

mdeo-model
using "./shapes.mm"

board : Canvas {
    title = "Poster"
    revision = 3
}

background : Layer {
    index = 0
}

foreground : Layer {
    index = 1
}

frame : Rectangle {
    name = "Frame"
    visible = true
    colour = Colour.BLUE
    tags = ["decoration", "border"]
    width = 210.0
    height = 297.0
}

dot : Circle {
    name = "Dot"
    visible = false
    colour = Colour.RED
    tags = []
    radius = 2.5
}

note : Annotation {
    text = "Keep the frame aligned with the page."
}

board.layers -- background
board.layers -- foreground
background.shapes -- frame
foreground.shapes -- dot
frame.annotations -- note

Creating a .m file in the workbench opens a dialog first, because the file cannot be written until its metamodel is known.

Objects ​

mdeo-model
frame : Rectangle {
    name = "Frame"
    visible = true
    colour = Colour.BLUE
    tags = ["decoration", "border"]
    width = 210.0
}

An object is name : Class { ... }. The name is unique within the file and is what links refer to. Inside the braces, each line assigns a property declared by the class or one of its supertypes, and each property may be assigned at most once.

Values may be:

KindExample
String"Frame"
Number3, 210.0
Booleantrue, false
Enum entryColour.BLUE
List["a", "b"], []
mdeo-model
board.layers -- background
frame.annotations -- note

A link connects two objects. Naming the property on an end says which association is meant; for an association that is navigable from only one side, that is the side you name. Both ends may be named when the association is bidirectional and the file benefits from being explicit.

The generated model language ​

.m_gen files are produced by the platform, not written by hand — an optimisation run emits one per solution on its Pareto front. They carry a serialised model rather than the textual syntax above, which is why the language has no textual editor.

They do open in the same diagram editor as hand-written models, so a solution can be inspected exactly like the model it came from.

Contribution plugins contributed ​

None. The model plugin does not extend any other language.

Contributions the model language accepts ​

The model language takes import contributions: a plugin can register a grammar for the content of an import <Name> { … } block, and answer a request for the objects and links that block stands for. The Model CSV plugin is the one bundled example, adding

mdeo-model
import CSV {
    Task from "./tasks.csv"
}

so that the rows of a CSV file become objects of the named metamodel class. Imported objects are merged with the hand-written ones before the model is handed to the execution services, and are drawn in the diagram next to them.

Nothing in this plugin knows what CSV is. An import contribution supplies its own grammar for the block's contents, its own answer to "what objects does this stand for", and — optionally — its own diagram nodes; the model language matches the block to whichever plugin registered its keyword and asks that plugin. A second import format would need no change here.

Server-side capabilities ​

File data keyContents
astThe serialised AST, for both model and model_gen
model-dataThe model in the form the execution services consume

The plugin has no execution handler of its own: models are executed by transformations and optimisations, not on their own.

Graphical editor ​

The model diagram editor shows objects as nodes and links as edges, with the palette populated from the metamodel the file imports — only classes that are not abstract can be created, and only associations declared between the relevant classes can be drawn. Copy and paste work within and between model diagrams.

Released under the terms of the repository licence.