Skip to content
Magnus edited this page May 6, 2020 · 3 revisions

Welcome to the projectparmorel wiki!

How to use the algorithm

This is a brief introduction on how to use the algorithm to repair models.

1. Create an instance of a ModelFxer

First, create an instance of a ModelFixer. You need to create a model fixer implementation that handle the type of model you want to handle. For now, the only implementation that exists is for Ecore. If you want to handle other model-types you can create an implementations as described here.

Example: private ModelFixer modelFixer = new EcoreQModelFixer();

2. Set the preferences

Second, you need to select some preferences. The preferences are fed to the algorithm through a List of PreferenceOptions. This is stored in the Q-table with their respecive ID's. The preferences are as follows:

Integer Meaning
0 Prefer shorter sequences of actions
1 Prefer longer sequences of actions
2 Prefer to repair higher in the context hierarchy
3 Prefer to repair lower in the context hierarchy
4 Punish deletion
5 Punish modification of the original model
6 Reward modification of the original model

3. Get a reference to the model-file

Retrieve a reference to the file containing the model you want to fix. The reference needs to be of type java.io.File.

4. Feed the information to the algorithm.

First, set the preferences as a List of PreferenceOptions. modelFixer.setPreferences(preferences); Then, call fix model with the file as a parameter. Solution optimalSolution = modelFixer.fixModel(modelfile);

5. Look at the solutions

the fixModel-method returns what it thinks is the optimal solutions based on the solutions weight. In reality, the algorithm remembers all the solutions calculated. These can be fetched by calling getPossibleSolutions() on the ModelFixer.

The Solution-object holds a reference to the sequence of all the actions performed to solve a given error, in order to achieve that specific solution. It also holds a reference to the original model and a temporary file with the possible solution. The file can be used to overwrite the current model, or the actions can be applied to the model.