The Epsilon Pattern Language

17
The Epsilon Pattern Language Dimitris Kolovos, Richard Paige May 22, 2017 Department of Computer Science University of York 9th Workshop on Modelling in Software Engineering (MiSE) ICSE 2017, Buneos Aires, Argentina

Transcript of The Epsilon Pattern Language

Page 1: The Epsilon Pattern Language

The Epsilon Pattern Language

Dimitris Kolovos, Richard Paige

May 22, 2017

Department of Computer Science

University of York

9th Workshop on Modelling in Software Engineering (MiSE)

ICSE 2017, Buneos Aires, Argentina

Page 2: The Epsilon Pattern Language

Pattern Matching

• In general: finding sub-structures of interest within morecomplex structures

• e.g. character sequences that look like email addresses

• In modelling: finding sets of model elements that have certain

properties and/or are connected in interesting ways

1

Page 3: The Epsilon Pattern Language

Example: Attributes to Pull Up

• Find pairs of attributes that can be moved up to a common

supertype

2

Page 4: The Epsilon Pattern Language

Declarative Pattern Matching

• Describe patterns declaratively

• Let the pattern matching engine figure out the optimal

execution plan

1

1from Arend et. al. – Henshin: Advanced Concepts and Tools for In-Place

EMF Model Transformations, ACM/IEEE MoDELS 2010

3

Page 5: The Epsilon Pattern Language

Declarative Pattern Matching Languages

Strengths

• Lots of room for behind-the-scene optimisation

• Can be executed incrementally (speed/memory trade-off)

Weaknesses

• Complex patterns can be challenging/verbose to express

graphically

• Falling back to complex expressions can reduce the scope for

optimisation/incrementality

• Current execution planners are not great

4

Page 6: The Epsilon Pattern Language

Practical Considerations

• Bound to a particular modelling technology / modelrepresentation format

• Non-negligible conversion cost

• No support for patterns that involve elements from different(heterogeneous) models

• e.g. UML activities and Simulink blocks

• No out-of-the-box support for “exporting” the results of

pattern matching to downstream activities (e.g. M2M, M2T)

5

Page 7: The Epsilon Pattern Language

Epsilon Pattern Language

• Hybrid OCL-based pattern matching language

• Modelling-technology independent

• Support for patterns that involve elements from multiple

heterogeneous models

• Support for “exporting” detected pattern instances to M2T,

M2M transformations etc.

6

Page 8: The Epsilon Pattern Language

Epsilon Organisation

eclipse.org/epsilon

7

Page 9: The Epsilon Pattern Language

Example: Attributes to Pull Up

• Find pairs of attributes that can be moved up to a common

supertype

8

Page 10: The Epsilon Pattern Language

Finding Attributes to Pull Up using EPL

pattern AttributesToPullUp

c : EClass ,

a1, a2 : EAttribute {

match :

a1.name = a2.name

and a1.eType = a2.eType

and a1 <> a2

and a1.eContainingClass.eAllSuperTypes.includes(c)

and a2.eContainingClass.eAllSuperTypes.includes(c)

}

9

Page 11: The Epsilon Pattern Language

A More Performant Version

pre {

var attributes = EAttribute.all.mapBy(a|a.name);

}

pattern AttributesToPullUp

c : EClass ,

a1 : EAttribute ,

a2 : EAttribute

from : attributes.get(a1.name). excluding(a1) {

match :

a1.eType = a2.eType

and a1.eContainingClass.eAllSuperTypes.includes(c)

and a2.eContainingClass.eAllSuperTypes.includes(c)

}

10

Page 12: The Epsilon Pattern Language

Adding a Second Model

• To specify attributes which should be ignored during pattern

detection

• The second model is an Excel spreadsheet with one worksheet

called “Ignore”

M

class attribute

. . . . . .

Employee name

. . . . . .

C

11

Page 13: The Epsilon Pattern Language

Pattern Matching on Two Models

pre { var attributes = M!EAttribute.all.mapBy(a|a.name); }

pattern AttributesToPullUp

c : M!EClass ,

a1 : M!EAttribute ,

a2 : M!EAttribute

from : attributes.get(a1.name). excluding(a1)

guard : not a1.isIgnored() and not a2.isIgnored() {

match :

a1.eType = a2.eType

and a1.eContainingClass.eAllSuperTypes.includes(c)

and a2.eContainingClass.eAllSuperTypes.includes(c)

}

operation M!EAttribute isIgnored() {

return C!Ignore.all.exists(i|i.attribute = self.name

and i.class = self.eContainingClass.name);

}12

Page 14: The Epsilon Pattern Language

Consuming Pattern Instances

• Pattern instances are wrapped as an EMC-compatiblein-memory “model”

• Patterns become types (e.g. AttributesToPullUp)

• Roles become fields (e.g. c, a1, a2)

• Other Epsilon programs can query and navigate them

• To transform, validate them etc.

• . . . even to detect patterns of patterns

13

Page 15: The Epsilon Pattern Language

Pattern Matching in a Workflow

<project default="main"> <target name="main">

<epsilon.emf.loadModel name="M" modelfile="model.ecore"

metamodeluri="http://www.eclipse.org/emf/2002/Ecore"/>

<epsilon.loadModel name="C" type="ExcelModel">

<parameter name="SPREADSHEET FILE" file="config.xlsx"/>

</epsilon.loadModel>

<epsilon.epl src="patterns.epl" exportas="P">

<model ref="M"/> <model ref="C"/>

</epsilon.epl>

<epsilon.eol>

for (atp in P!AttributesToPullUp.all) { atp.c.name.println(); }

<model ref="M"/><model ref="C"/><model ref="P"/>

</epsilon.eol>

</target > </project >14

Page 16: The Epsilon Pattern Language

Future Work

• Experimental evaluation against GrGen.NET, Henshin,

VIATRA/EMF-IncQuery, AGG etc.

• Static analysis

• Parallel and incremental pattern matching

15

Page 17: The Epsilon Pattern Language

Summary

• Hybrid OCL-based pattern matching language

• Modelling-technology independent

• Support for “exporting” detected patterns to downstream

model management programs

eclipse.org/epsilon

16