Tuesday, August 04, 2015

Repairing model constraint violations with MOMoT

Introduction

Model Transformation are the key concept of the Model Driven Engineering today. Usually, Model Transformations are applied through Transformation Rules. However, the orchestration of the rules is a very complex task. Manually, it is very hard to determine what would be the best order to apply such rules. One possible way to tackle this, is to apply Search-based optimization techniques. Therefore, a framework called MOMoT has been created which combines two worlds, Model Transformations and Search-based Software Engineering. It is a new framework which has already been applied on 3 problem domains - Stack, Modularization and Refactoring problem. Our goal is to define a new problem domain to apply MOMoT and to evaluate behaviour, vulnerabilities and threats of such an approach.

Problem Definition

Often, models represent real-world problems. As such, they also have constraints and restrictions that need to be fulfilled. Such constraints can be violated and one of the essential tasks in model engineering is to repair such model so that they satisfy all the constraints. Our goal is apply MOMoT approach on such models and to repair them so that at the end they satisfy all the constraints. We applied this approach to many different constraints sequentially and observed their results. In the following, we describe very simple model and have MOMoT can be applied on that. We tested this approach on many different constraint violations including:
  • Multiplicity upper bound
  • ID not set
  • Duplicate id
  • Not-Null attribute
  • OCL constraint(s)
  • Unique attribute
  • Value aggregation and counting
All the projects can be found at public repository at GitHub.

Running Example

In order to apply this approach on this specific problem domain, we need to define a model which violates some of the constraints. First step would naturally be to define meta-model with some specific constraints. In this example we define a very simple meta-model which represents a university.

Meta-model of the university

Here, we see that an university consists of student and courses, where course should have at least 5 students. Now we create a model which doesn't satisfy this constraint. Our model consists of 8 students and 3 courses where each course has 5, 3 and 2 students assigned to it respectively. In order to repair such models we need to define transformation rules which are applied on the models to resolve the constraint violations. We use Henshin to define them.

Henshin transformation rules for our example

We can see that first rule creates a new student while the second rule assigns new student to a course. Orchestration of those rules is defined in a Java class.

Evaluation 

With such approach we were able to repair almost all models. Models that have manipulated ID (null or duplicate) were not able to get repaired since parsing of such models already produces an exception. Therefore, we have removed the ID attribute and replaced it by an equivalent unique, not-null attribute for which a constraint in OCL has been defined.
Concluding, we have discovered that it is very important how a specific OCL is defined in our approach. For example, one way to define that students have unique numbers would be to define it in a class University. However, this would lead to only one constraint violation no matter how many students actually violate that constraint. When we try to minimize the number of constraint violations in the search, a better guidance can be given by defining the constraint in the context of the Student class resulting in a better representation of the actual number of constraint violations.

No comments:

Post a Comment