Welcome to Clafer 0.5.0 Model Wiki!


This is a public instance of the ClaferWiki to serve as a model repository. We are publishing example models that showcase Clafer as a lightweight structural modeling language. For installation, visit Software.

Each wiki page contains a single Clafer model. The model can be split into model fragments and interwoven with rich-text contents (literate modeling). The model is compiled using the Clafer compiler and rendered as HTML, which provides syntax and error highlighting and hyperlinking, and as a Graph, which provides a different view on the model that emphasizes inheritance and references. Double click on the graph shows/hides references.

Release announcements and changes

| 0.5.0 (current development version: behavioral clafer). See Behavioral Modeling for examples.

| 0.4.5 | 0.4.4 | 0.4.3 | 0.4.2 | 0.4.1 (compiler) 0.4.1 (web tools) | 0.4.0

| 0.3.10 | 0.3.9 | 0.3.8 | 0.3.7 | | 0.3.5 | 0.3.4 | 0.3.3 | 0.3.2 | 0.3.1 | 0.3.0 |

Learning Clafer

Clafer Cheat Sheet

Domain concept modeling using Clafer

This tutorial presents basics of Clafer using few examples, introduces Clafer a bit more precisely (but not formally), and finishes with a modeling exercise with two alternative reference solutions.


  1. Introduction
  2. Clafer a bit more precisely
  3. Exercise - Modeling a Concept
  4. Exercise - Example Reference Solution
  5. Exercise - Alternative Ways of Modeling

Guidelines for feature modeling using Clafer

Feature Modeling using Clafer

Inheritance of Group Cardinality

“Train Station Layout” domain modeling tutorial

See announcement on clafer.org.

Go to Interactive Tutorial

“Traffic Lights” domain modeling tutorial

See announcement on clafer.org.

Interactive Tutorial

Modeling directed graph reachability

See announcement on clafer.org.

Micro-level and macro-level modeling patterns

Some methodological advice on modeling in Clafer from Alexandr Murashkin’s MMath Thesis (University of Waterloo, 2014) “Automotive Electronic/Electric Architecture Modeling, Design Exploration and Optimization using Clafer”.

Selected posts and presentations from clafer.org

Clafer usage scenarios

Clafer can be used in a number of scenarios:

Product-line architecture modeling

Modeling features of products in a product line and their realization as components.

Multi-objective optimization of product lines

Modeling features of products in a product line with their quality attributes. Multi-objective optimization discovers which products are optimal given the optimization goals such as “minimize total mass” and “maximize total performance”.

Data center resource allocation problems

Modeling and multi-objectively optimizing resource allocations. Models created by Alexandr Murashkin.

  • Allocate services with the given requirements on machines. Maximize the number of free machines.

ISAP Optimization

  • Like ISAP but customized to handle time-varied requirements

TSAP Optimization

Variability modeling

Domain modeling

Feature-based modeling of domain concepts and business rules.

Model transformation

An example FamiliesToPersons inspired by ATL/Tutorials - Create a simple ATL transformation. We let the reader appreciate the simplicity, conciseness, and declarative nature of this transformation in Clafer.


Ecore metamodels from Juan

OCL benchmark

Other cool examples

Clafer is a general-purpose structural modeling language but it’s strengths make it particularly useful in modeling scenarios whereby containment hierarchies and model evolution are very important.

Below are some other examples:

Behavioral modeling

As of version 0.5.0, Clafer can be used for specifying how the structures evolve over time. In this setting, a static Clafer model describes the possible states of the system, whereas, the temporal aspects specify how the states can change.

Demo spaces

Here are pages for the different tool demos:

ClaferWiki-specific help

Below is the Clafer-specific markup that can be used in the wiki pages. On the right is the screenshot of the ClaferWiki-Specific Help page which demonstrates the usage of the markup shown on the left.

Add a Clafer code fragment as follows:

abstract A
  c -> C *
A1 : A
  [ #c = 2 ]
abstract B : A
abstract C

Top-level clafers can be placed into separate code fragments but they cannot be split in the middle. That is all children of a top-level clafer must belong to the same code fragment.

or in the full code block notation

C1 : C
C2 : C

Add the Analyze with ClaferMooViz button

```{.clafer .mooviz}
<anything here is ignored>

Add a graph in the simplified notation:

```{.clafer .graph}
<anything here is ignored>

Double click on the graph in the simplified notation to show/hide references. By default, the graph only shows inheritance relationships allowing for quick inspection of the inheritance hierarchy which is not directly visible in Clafer’s textual notation.

Add a graph in the CVL notation:

```{.clafer .cvlGraph}
<anything here is ignored>

Add statistics:

```{.clafer .stats}
<anything here is ignored>

Add download links for a complete model file (.cfr) and a self-contained HTML rendering of the model file (.html):

```{.clafer .links}
<anything here is ignored>

Add summary, which includes 1) a graph in the simplified notation, 2) module statistics, and 3) the download links:

```{.clafer .summary}
<anything here is ignored>
Screenshot of the ClaferWiki-Specific Help Demonstration page

Use the Preview button to compile the model and see parsing and compilation errors, if any. At most one error is reported for each code block. If a parsing error is reported, compilation is not executed and therefore no compilation errors are reported.

Use the Save button to commit your edits to the Git repository.

Gitit Wiki general help

For instructions on how to make a link to another wiki page, see the Help page. To create a new wiki page, just create a link to it and follow the link.

Help is always available through the “Help” link in the sidebar. More details on installing and configurating gitit are available in the Gitit User’s Guide.