transformations of models containing uncertainty

60
Michalis Famelis, Rick Salay, Alessio Di Sandro, Marsha Chechik University of Toronto Transformation of Models Containing Uncertainty

Upload: michalis-famelis

Post on 10-May-2015

789 views

Category:

Technology


0 download

DESCRIPTION

Abstract. Model transformation techniques typically operate under the assumption that models do not contain uncertainty. In the presence of uncertainty, this forces modelers to either postpone working or to arti- ficially remove it, with negative impacts on software cost and quality. Instead, we propose a technique to adapt existing model transforma- tions so that they can be applied to models even if they contain un- certainty, thus enabling the use of transformations earlier. Building on earlier work, we show how to adapt graph rewrite-based model transfor- mations to correctly operate on May uncertainty, a technique that allows explicit uncertainty to be expressed in any modeling language. We eval- uate our approach on the classic Object-Relational Mapping use case, experimenting with models of varying levels of uncertainty.

TRANSCRIPT

Page 1: Transformations of Models Containing Uncertainty

Michalis Famelis, Rick Salay, Alessio Di Sandro, Marsha Chechik

University of Toronto

MODELS 2013, Miami Beach, FL

Transformation of Models Containing Uncertainty

Page 2: Transformations of Models Containing Uncertainty

2

This is Natalie.

Natalie is a modeler.

Natalie faces uncertainty in her everyday work.

Page 3: Transformations of Models Containing Uncertainty

3

Alternative Designs

Hmm, I don’t know which

one, yet.

Page 4: Transformations of Models Containing Uncertainty

4

Conflicting Stakeholder Opinions

What do I do until they decide?

Page 5: Transformations of Models Containing Uncertainty

5

Incomplete Information

I don’t know everything about

this, yet.

Page 6: Transformations of Models Containing Uncertainty

6

Uncertainty in software development

Uncertainty about the content of the model.

Many design alternatives Conflicting stakeholder opinionsIncomplete information

Page 7: Transformations of Models Containing Uncertainty

7

Transformations

Like everygood MBE practitioner,Natalie usesa variety of MTs

Page 8: Transformations of Models Containing Uncertainty

8

Transformations

The transformations assumeinputs that don’t containuncertainty

Like everygood MBE practitioner,Natalie usesa variety of MTs

Page 9: Transformations of Models Containing Uncertainty

9

Transformations

But only too often, Natalie’s models contain uncertainty:

The transformations assumeinputs that don’t containuncertainty

Like everygood MBE practitioner,Natalie usesa variety of MTs

Page 10: Transformations of Models Containing Uncertainty

10

Transforming Models with Uncertainty

Natalie should be able to use model transformations

Page 11: Transformations of Models Containing Uncertainty

11

Transforming Models with Uncertainty

Natalie should be able to use model transformations

Page 12: Transformations of Models Containing Uncertainty

12

Transforming Models with Uncertainty

Natalie should be able to use model transformations

Existing transformation techniques do not support this!

To apply MTs, Natalie is forced to artificially remove uncertainty

Page 13: Transformations of Models Containing Uncertainty

13

Transforming Models with Uncertainty

We need to lift Natalie’s transformations so that they can apply to models with uncertainty

Existing transformation techniques do not support this!

Natalie should be able to use model transformations

Page 14: Transformations of Models Containing Uncertainty

14

Outline

Representing Uncertaintywith Partial Models

Transforming Partial Models

ToolSupport

EmpiricalEvaluation

Reminder: Model Transformations

Page 15: Transformations of Models Containing Uncertainty

15

Model Transformations With Graph Rewriting

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

NegativeApplicationCondition

LeftHandSide

RightHandSide

EncapsulateVariable refactoring:Make fields private and add getter methodsunless they belong to some inner class

Example rule:

Page 16: Transformations of Models Containing Uncertainty

16

Example Input Model

SolverSolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Page 17: Transformations of Models Containing Uncertainty

17

Example Input Model

SolverSolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Match

Page 18: Transformations of Models Containing Uncertainty

18

Example Input Model

SolverSolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

NAC also matches! ABORT !

Page 19: Transformations of Models Containing Uncertainty

19

Example Input Model 2

SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Page 20: Transformations of Models Containing Uncertainty

20

Example Input Model 2

SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Match

Page 21: Transformations of Models Containing Uncertainty

21

Example Input Model 2

SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Delete

Page 22: Transformations of Models Containing Uncertainty

22

Example Input Model 2

SolverException

effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Page 23: Transformations of Models Containing Uncertainty

23

Example Input Model 2

SolverException

- effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Add

Page 24: Transformations of Models Containing Uncertainty

24

Example Input Model 2

SolverException

- effect : String + getEffect() : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Add

Page 25: Transformations of Models Containing Uncertainty

25

Example Input Model 2

SolverException

- effect : String + getEffect() : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

No more LHS matches.

Stop.

Page 26: Transformations of Models Containing Uncertainty

26

Outline

Representing Uncertaintywith Partial Models

Page 27: Transformations of Models Containing Uncertainty

27

Representing Uncertainty

Partial Models [ICSE12]

• Points of uncertainty (“May elements”) explicated using syntactic annotations

Solver

SolverException

+ effect : String

Unsure if it should be an inner class.

Unsure if we need this field.

Page 28: Transformations of Models Containing Uncertainty

28

Representing Uncertainty

Partial Models [ICSE12]

• Points of uncertainty (“May elements”) explicated using syntactic annotations

Propositional variables: “the element exists”

Solver

SolverException

+ effect : String

X

Y

Page 29: Transformations of Models Containing Uncertainty

29

Representing UncertaintySolver

SolverException

+ effect : String

X

Y

Solver

SolverException

Solver

SolverException

Solver

SolverException

+ effect : String

Solver

SolverException

+ effect : String

x=F, y=F x=T, y=F

x=F, y=T x=T, y=T

4 concretizations: 4 ways to resolve uncertainty.

Page 30: Transformations of Models Containing Uncertainty

30

Representing Uncertainty

Partial Models [ICSE12]

• Points of uncertainty (“May elements”) explicated using syntactic annotations

• Restrictions to the set of concretizations can be captured in the “May formula”

Solver

SolverException

+ effect : String

X

Y

X v Y

Page 31: Transformations of Models Containing Uncertainty

31

Representing UncertaintySolver

SolverException

+ effect : String

X

Y

Solver

SolverException

Solver

SolverException

Solver

SolverException

+ effect : String

Solver

SolverException

+ effect : String

x=F, y=F x=T, y=F

x=F, y=T x=T, y=TX v Y

Page 32: Transformations of Models Containing Uncertainty

32

Outline

Transforming Partial Models

Page 33: Transformations of Models Containing Uncertainty

33

Transforming Models With Uncertainty

Natalie wants to apply the rule to an input with uncertainty

Page 34: Transformations of Models Containing Uncertainty

34

Why Is It Hard?

Solver SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

X

Y

X v Y

Page 35: Transformations of Models Containing Uncertainty

35

Why Is It Hard?

Solver SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Match???

X

Y

X v Y

Page 36: Transformations of Models Containing Uncertainty

36

Why Is It Hard?

Solver SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Match???

X

Y

X v Y

Page 37: Transformations of Models Containing Uncertainty

37

Why Is It Hard?

Solver SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Should we delete?

Should we add?

X

Y

X v Y

Page 38: Transformations of Models Containing Uncertainty

38

Why Is It Hard?

Solver SolverException

+ effect : String

class1

+ attribute : type

class1

- attribute : type+ getAttribute() :type

class1

class2

RHSLHSNAC

Existing transformation techniques cannot be used.

X

Y

X v Y

Page 39: Transformations of Models Containing Uncertainty

39

Intuition

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

?

(And definition of correctness)

Page 40: Transformations of Models Containing Uncertainty

40

Intuition

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

Solver

SolverException

+ effect : StringSolver

SolverException

?

(And definition of correctness)

Page 41: Transformations of Models Containing Uncertainty

41

Intuition

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

Solver

SolverException

+ effect : StringSolver

SolverException

Solver

SolverException

-effect : String+getEffect() : String

Solver

SolverException

+ effect : String

Solver

SolverException

(And definition of correctness)

Page 42: Transformations of Models Containing Uncertainty

42

Intuition

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

Solver

SolverException

+ effect : StringSolver

SolverException

( X ¬Y ¬a ¬b) ∧ ∧ ∧v(¬X Y ¬a b) ∧ ∧ ∧v( X Y a ¬b)∧ ∧ ∧

Solver

SolverException

+ - effect : String+getEffect() : String

X

Ya

b

(And definition of correctness)

Page 43: Transformations of Models Containing Uncertainty

43

Intuition

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

( X ¬Y ¬a ¬b) ∧ ∧ ∧v(¬X Y ¬a b) ∧ ∧ ∧v( X Y a ¬b)∧ ∧ ∧

Solver

SolverException

+ - effect : String+getEffect() : String

X

Ya

b

(And definition of correctness)

Page 44: Transformations of Models Containing Uncertainty

44

Technique

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

Page 45: Transformations of Models Containing Uncertainty

45

Technique

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

(a) Find Match

Step 1: Determine applicability

Page 46: Transformations of Models Containing Uncertainty

46

Technique

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

(a) Find Match

(b) Make sure the rule applies to at least one concretization

(requires solvinga SAT problem)

Step 1: Determine applicability

Page 47: Transformations of Models Containing Uncertainty

47

Technique

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

Solver

X

Step 1: Determine applicabilityStep 2:Transform graph

SolverException

+ effect : StringY

(a) Copy over unchangedparts

Page 48: Transformations of Models Containing Uncertainty

48

Technique

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

Solver

SolverException

+ - effect : String+getEffect() : String

X

Ya

b

Step 1: Determine applicabilityStep 2:Transform graph

(a) Copy over unchangedparts

(b) Perform additions and deletions

Added and deleted elements become Maybe

Page 49: Transformations of Models Containing Uncertainty

49

Technique

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

Step 1: Determine applicabilityStep 2:Transform graphStep 3:Transform formula

( X ¬Y ¬a ¬b) ∧ ∧ ∧v(¬X Y ¬a b) ∧ ∧ ∧v( X Y a ¬b)∧ ∧ ∧

Solver

SolverException

+ - effect : String+getEffect() : String

X

Ya

b

Constrain Maybe elementsto ensure each thatconcretizationis correctly affected.

Page 50: Transformations of Models Containing Uncertainty

50

Overview

class1

+ attribute : type

class1

- attribute : type+ getAttribute():type

class1

class2

RHSLHSNAC

Solver

SolverException

+ effect : String

X

Y

X v Y

( X ¬Y ¬a ¬b) ∧ ∧ ∧v(¬X Y ¬a b) ∧ ∧ ∧v( X Y a ¬b)∧ ∧ ∧

Solver

SolverException

+ - effect : String+getEffect() : String

X

Ya

b

Step 1: Determine applicabilityStep 2:Transform graphStep 3:Transform formula

Page 51: Transformations of Models Containing Uncertainty

51

AnalysisIn the paper:

• Proof of correctness• The lifting algorithm implements

our intuition

• Proofs of preservation of properties:1. Confluence

The result of applying a set of rules to a model is the same regardless of the order of application or the order of matching sites.

2. TerminationRepeated applications will reach a point where the rule will no longer be applicable.

Page 52: Transformations of Models Containing Uncertainty

52

Outline

ToolSupport

EmpiricalEvaluation

Page 53: Transformations of Models Containing Uncertainty

53

Tool Support

• Reuse partial model implementation in MMTF (Eclipse / EMF)

• Algorithm implementation1. Determine rule applicability

• Henshin and the Z3 SMT solver

2. Transform the graph• Henshin

3. Transform the formula• Java (Z3 input strings) MMTF

Page 54: Transformations of Models Containing Uncertainty

54

Case Study

• Object–relational mapping (ORM)

• “Translate a class diagram to a relational database

schema.”

• Classic benchmark for model

transformation research

• Triple graph grammar with 5 layered graph rules [Varro06]

(Image from [Varro06])

Page 55: Transformations of Models Containing Uncertainty

55

Case Study

• Input model: the Ecore metamodel

• ORM for Ecore is important: cf. CDO and Teneo

• Manually flattened inheritance hierarchy and adapted to the

metamodel in [Varro06]

• Resulting model had 65 model elements:

• 17 classes, 17 associations, 6 generalization links, 25 attributes

• Manually injected points of uncertainty to create partial models

with increasing numbers of concretizations

Page 56: Transformations of Models Containing Uncertainty

56

Setup And Results

• RQ: How does lifting scale with increasing uncertainty?

• Varied: number of concretizations of input

• Measured: time to complete the ORM transformation

• Ran on Intel Core i7-2600 3.40GHz×4core, 8GB RAM, Ubuntu-64 12.10.

• Runtime does not increase dramatically. Approach scales.

# concretizations 1 24 48 108 144 192 256

Time (seconds) 32.6 32.8 32.7 32.9 32.6 33.0 48.4

Page 57: Transformations of Models Containing Uncertainty

57

Summary

Decision deferral in the presence of uncertainty

Existing techniques cannot handle uncertainty

Explicit uncertainty modelingwith Partial Models

Syntactic annotations and May formula

Transform Partial Models

1. Determine applicability2. Transform graph3. Transform formula

Approach scales for increasing levels of uncertainty

ToolSupport

EmpiricalEvaluation

Case Study: Object-relational mapping for the Ecore metamodel

Page 58: Transformations of Models Containing Uncertainty

58

Next Steps

• Implement lifted semantics as a higher-order transformation (HOT)• Given a graph rewrite rule, produce a grammar that

implements the lifted semantics• Benefit: out of the box reuse of existing graph

transformation tools (Henshin, AGG, etc.)

• Expand lifting for other types of model uncertainty, based on the rich MAVO framework [FASE12]

Page 59: Transformations of Models Containing Uncertainty

Questions?

icons by:

Page 60: Transformations of Models Containing Uncertainty

60

Bibliography[ICSE12] M. Famelis, M. Chechik, and R. Salay. “Partial Models: Towards Modeling and Reasoning with Uncertainty”. In Proc. of ICSE’12, 2012.

[Varro06] D. Varro, S. Varro-Gyapay, H. Ehrig, U. Prange, and G. Taentzer. “Termination Analysis of Model Transformations by Petri Nets”. In Proc. of ICGT’06, pages 260–274, 2006.

[FASE12] R. Salay, M. Famelis, and M. Chechik. “Language Independent Refinement using Partial Modeling”. In Proc. of FASE’12, 2012.