Revision 9e983db875a7f9a13baff48582659063978d5f1a (click the page title to view the current version)

Feature Modeling using Clafer

Changes from 9e983db875a7f9a13baff48582659063978d5f1a to 42609c9e70bb0edd1651a6dec0d35cbc46c2f0d2
---
title: Guidelines for feature modeling using Clafer
...

# Learning the Clafer language

The subset of Clafer most relevant to feature modeling is presented in these two resources:

* Feature modeling using Clafer tutorial

>The tutorial [Attributed Feature Models in Clafer](https://github.com/gsdlab/clafer/raw/master/doc/tutorial/attributed/doc.pdf) explains how to read and encode attributed feature models in Clafer. It also presents Clafer constructions that go beyond feature modeling but which are useful for encoding variability models.

* Feature modeling with quality and multi-objective optimization using Clafer

> An [interactive assignment](https://wiselab.uwaterloo.ca/railwaywiki/) designed to introduce the concepts of *variability management*, *multi-objective optimization*, and *computational decision-making* in product line engineering. The assignment introduces basic feature modeling, modularizing feature models, modeling with quality attributes (e.g., `cost`, `performance`), and defining and solving multiple objective problems (e.g., minimize cost while maximizing performance and security). The assignment uses on-line tools: ClaferIDE and Clafer Multi-Objective Optimizer and Visualizer.

# Working with Clafer models

Clafer is a textual language and in order to be used effectively, it requires a powerful text editor.
Specifically, since a model in Clafer is a tree and the nesting is expressed through indentation, the editor should support

* **block indentation** to be able to indent a few lines of clafers for nesting,
* **indentation level visualization** to be able to see the nesting depth of clafers, and
* **name completion** to be able to easily refer to the names of already defined clafers in other parts of the model.

## On desktop

We provide extensions for

* [Microsoft VS Code](https://code.visualstudio.com/): [clafer-vscode](https://github.com/gsdlab/clafer-vscode)
* [Sublime Text 4](http://www.sublimetext.com/): [ClaferToolsST](https://github.com/gsdlab/ClaferToolsST)

### Using Clafer Tools from Command Line

#### Set up

There is no need for installation. Just download the archive from [Clafer Tools Binary Distributions](https://wiselab.uwaterloo.ca/clafer-tools-binary-distributions/) and unzip to the hard drive or a USB memory stick. Add the location to `PATH`.

#### Invoking the Clafer compiler and the instance generator

The instructions are in the READMEs of the respective tools:

* [Clafer compiler usage](https://github.com/gsdlab/Clafer#usage).
* [Choco-based instance generator and optimizer](https://github.com/gsdlab/chocosolver#getting-started-with-the-cli). See the detailed [interactive session usage](https://github.com/gsdlab/chocosolver#cli-interactive-mode).
* [Choco-based instance generator and optimizer, `clafersg`](https://github.com/gsdlab/chocosolver#getting-started-with-the-cli), which also generates the traces of temporal models with Alloy. See the detailed [interactive session usage](https://github.com/gsdlab/chocosolver#cli-interactive-mode).
* [Alloy-based instance generator](https://github.com/gsdlab/ClaferIG#usage). See the detailed [interactive session usage](https://github.com/gsdlab/claferIG/#interactive-session-usage).

We recommend using the Choco-based instance generator for most purposes since it is faster and it can perform multi-objective optimization.

## On-line

### ClaferIDE

For editing, compiling, and instantiating full Clafer models, we provide [ClaferIDE](https://wiselab.uwaterloo.ca/claferide/). The tool provides an editor with syntax highlighting and good indentation support. The tool also integrates the compiler and the Alloy-based and Choco3-based instance generators.

### ClaferConfigurator

For exploring multiple valid configurations of a feature model we provide [ClaferConfigurator](https://wiselab.uwaterloo.ca/claferconfigurator/).

### ClaferMooVisualizer

For visualizing and exploring optimal configurations of a feature model with quality attributes and optimization objectives we provide [ClaferMooVisualizer](https://wiselab.uwaterloo.ca/clafervisualizer/).