Вы находитесь на странице: 1из 33

Model Transformation as an Optimization Problem

Marouane KESSENTINI1, Houari SAHRAOUI1


{kessentm,sahraouh}@iro.umontreal.ca

MoSART-Meeting, June 19-th 2008, Montral, CANADA


1 DIRO,

Universit de Montral, Montral, CANADA


1

Outline
Context Motivations Proposal Approach Evaluation Conclusion and future work

MoSART meeting // June 19th 2008// Montral, Canada

Context
Model transformation : a key issue for MDD
Model Synchronization Model Refactoring Model Abstraction Pattern Application Code Generation

MoSART meeting // June 19th 2008// Montral, Canada

Context
Model transformation principle :
Source model
UML class diagrams,

Mapping
Rules,

Target Model
Relational schemas,

ATL rules (Jouault et al. 05)


module UML2ER; create OUT : ER from IN : UML; rule P2A { from p : UML! Property to a : ER! Attribute ( name < p . name , entity < p . owningClass ) }

MoSART meeting // June 19th 2008// Montral, Canada

Outline
Context Motivations Proposal Approach Evaluation Conclusion and future work

MoSART meeting // June 19th 2008// Montral, Canada

Motivations
Available work based on rules (Egyed 02)
VIATRA(Varro et al. 04) AGG(Taenzer et al. 03) ATL(Jouault et al. 05)

Difficult to express/define transformation rules Transformation experts


Diverge experts opinions Need to understand the source and target formalisms Easier to describe examples than rules

Idea = Model Transformation By Example


MoSART meeting // June 19th 2008// Montral, Canada 6

Model Transformation By Example


MTBE : rule extraction from examples
Semi-automatically using ILP (Varro et al. 07) Manually using ATL rules (Wimmer et al. 07)

Limitations
Dependent on source/target models Difficult to ensure rule consistency, non-redundancy, completeness, etc. Strong hypothesis : representative samples of examples Important input from experts

Proposal : Model Transformation as Optimization by Examples (MOTOE)


MoSART meeting // June 19th 2008// Montral, Canada 7

Outline
Context Motivations Proposal Approach Evaluation Conclusion and future work

MoSART meeting // June 19th 2008// Montral, Canada

Proposal
Model transformation as an optimization problem Model = { constructi | 1in} Each construct may have m transformation possibilities
Construct Possibility 1 Possibility 2 Possibility m-1 Possibility m

MoSART meeting // June 19th 2008// Montral, Canada

Proposal
Transformation problem = search in an n dimensional space Construct = dimension Solution = {<constructi,Tj(constructi)>} Heuristic search

MoSART meeting // June 19th 2008// Montral, Canada

10

Outline
Context Motivations Proposal Approach Evaluation Conclusion and future work

MoSART meeting // June 19th 2008// Montral, Canada

11

Illustration
Approach illustration : UML_CLD to RS Transformation example
SMD = source model TMD = target model MB = mapping blocks
mapping block = minimal set of constructs in SMD whose transformations are independent

MoSART meeting // June 19th 2008// Montral, Canada

12

Illustration
Transformation example?
[SMD, TMD, MB]

SMD = class diagram Class(Position). Attribute(Title, Position,_). Association(0,1,_,n_, Assigned, Position, Employee). Generalization(Employee, Operative).

TMD = relational schema Table(Position). column(Title, Position,_).

MoSART meeting // June 19th 2008// Montral, Canada

13

Illustration
Transformation example?
B32

[SMD, TMD, MB]

Block B32
Class(Position) : Table(Position). Attribute(Title, Position,_) : Column(idPosition, position, pk), Column(title, Position,_). Attribute(SalaryMin, Position,_) : Column(salaryMin, position,_). Attribute(SalaryMax, Position,_) : Column(salaryMax, position,_). Class(Employee) : Table(Employee). Attribute(Name, Employee,_) : Column(idEmployee, Employee, pk), Column(name, employee,_). Attribute(StartDate, Employee,_) : Column(startDate, Employee,_). Association(0,1,_,n,_, Position, Employee) : Column(idPosition, employee, fk).

MoSART meeting // June 19th 2008// Montral, Canada

14

Search Space
Construct = dimension

Construct

Position:class Employee:class 2

Work_at: association 3

Aggregation 4

Generalization1 . 5

Dimension 1

MoSART meeting // June 19th 2008// Montral, Canada

15

Search Method
Particle Swarm Optimization
Developed in 1995 by James Kennedy and Russell Eberhart Evolutionary computational technique based on the movement and intelligence of swarms
New motion Component in the Direction of previous motion Component in the Direction of global best Component in the Direction of personal best Global best Personal Best at previous step
MoSART meeting // June 19th 2008// Montral, Canada 16

Current motion

PSO Algorithm
Initial population (particles) creation While Termination criterion not met do Foreach particle do Evaluate fitness Update local/global best (if necessary) Update velocity and position end for end while 4. Return solution corresponding to the global best

MoSART meeting // June 19th 2008// Montral, Canada

17

PSO for MOTOE


Source Model + Examples

Particle representation

Fitness function

Position/velocity

Target Model

MoSART meeting // June 19th 2008// Montral, Canada

18

Particle Representation
Transformation encoding
1 4 5 6 8 9 Position vector/solution Constructs Transformations blocks 1 2 3 4 5 6 7 8 9 10 11 12 7 3 12 11 10 2

20 18 1 17 12 7 15 2
Block number

5 29
19

MoSART meeting // June 19th 2008// Montral, Canada

Particle Representation
Example 1

Initialization
Swarm initialization = Generating k particles randomly

Example 2

Example 3

Example n

1 Particlei 1 Particlej

10

11

12

10

11

12

MoSART meeting // June 19th 2008// Montral, Canada

20

Fitness Function
Good model transformation
Good transformation for individual constructs Consistency between construct transformations

Fitness function
f fn = 2*n
Where

f = e j ( p j + d j )
n j =1

1, if a transform ation exemple in the associated block exists ej = 0, else.

pj =

# matched parameters # parameters

dj =

# consistent dependent constructs # dependent constructs


21

MoSART meeting // June 19th 2008// Montral, Canada

Fitness Function
20 18 1 17 12 7 15 2 9 3 5

e3 = 1 p3 = 5/7 = 0.71 d3 = 2/2 = 1 Association (0,1,_,n,_, Position, Employee)


Begin b1 Class(Client) : Table(client). Attribute(N_Client, Client, unique) : Column(n_Client, client, pk). Class(Reservation) : Table(Reservation). Attribute(N_reservation, Reservation, unique) : Column(n_reservation, Reservation, pk). Association (1,1,0,n,_, Client, Reservation) : Column(n_Client, Reservation, fk). End b1

MoSART meeting // June 19th 2008// Montral, Canada

22

Particle Velocity
Influencing factors
Inertia Individual experience Group experience
vi +1 = w vi + c1 rand1() ( pbest ,i positioni ) + c2 rand 2() * ( gbest ,i positioni )
vi: Velocity of particle at ith iteration w: c1 : acceleration factor related to gbest, c2 : acceleration factor related to lbest rand1( ) and rand2( ): random numbers in [0, 1] gbest: (global) best position of swarm pbest: (local) best position of particle

MoSART meeting // June 19th 2008// Montral, Canada

23

Position
Particle position (discrete PSO)
Positionn+1 = Positionn + vn+1
Position[n]

20 +
V[n+1]

18

17

12

15

29

2.4

-1.2

0.8

3.7

-2.3

0.12

1.3

2.6

-1.02 3.01

5.6

-2.9

Position[n+1]

22

16

20

16

10

26

MoSART meeting // June 19th 2008// Montral, Canada

24

Outline
Context Motivations Proposal Approach Evaluation Conclusion and future work

MoSART meeting // June 19th 2008// Montral, Canada

25

Evaluation
CLD-to-RS transformation 10 examples 10-fold cross validation
Transform each example using the 9 other examples Average precision

Model transformation precision


# constructs with correct transformation P= # constrcuts

MoSART meeting // June 19th 2008// Montral, Canada

26

Setting parameters
Experimental Setting
Swarm = 20 particles Maximum iterations = 40 (twice the size of the swarm) Best result from 5 executions c1=1 ,c2 = 1 (Eberhart et al. 01) Inertia weight (w) (Eberhart et al. 01)
wmax wmin w = wmax iter itermax
MoSART meeting // June 19th 2008// Montral, Canada

wmax: Upper bound of weighting coefficient, wmin: Lower bound of weighting coefficient, itermax: Maximum number of iterations, iter: Current iteration number.

27

Results and Interpretation


Execution trace example
Iteration Best particle position Fitness

1 2 3 21 22 29 39 40

4 7 6 4 6 6 4 9 9 3 5 4 7 8 6 1 8 1 7 8 6 2 6 1 3 9 5 8 5 2 4 5 5 9 8 5 1 1 1 22 1 2 1 18 24 1 14 24 1 1 1 22 1 2 1 17 23 4 21 27 1 1 12 22 12 1 1 4 32 4 1 1 1 1 12 22 12 1 1 4 32 4 1 1 1 1 12 22 12 1 1 4 32 4 1 1

0.671 0.678 0.669 0.798 0.696 0.821 0.821 0.821

MoSART meeting // June 19th 2008// Montral, Canada

28

Results and Interpretation


Precision of the 10 generated transformations
Source Model 1 2 3 4 5 6 7 8 9 10 Average precision Standard deviation Best global fitness 0.830 0.865 0.754 0.785 0.910 0.821 0.935 0.814 0.636 0.802 Precision P (%) 100 100 91.6 87.5 100 100 100 87.5 75 90 93.16 8.86

MoSART meeting // June 19th 2008// Montral, Canada

29

Outline
Context Motivations Proposal Approach Evaluation Conclusion and future work

MoSART meeting // June 19th 2008// Montral, Canada

30

Conclusion
Novel approach (MOTOE) for automating model transformation
Transformation by examples Optimization problem

Advantages
No rules used/derived Independent from the source-target formalisms

Validation
UML_CLD to Relational Schema Good preliminary results
MoSART meeting // June 19th 2008// Montral, Canada 31

Conclusion
Validation limitations
Small-size examples Only one transformation type

MoSART meeting // June 19th 2008// Montral, Canada

32

Future work
Validation with (large-scale) industrial projects Other transformation types
e.g., sequence diagrams to Petri nets

Other search-based algorithms


Performance comparison

Refinement of fitness function


Construct relative importance in transformation

Application to other transformation problems


Code generation Model refinement
MoSART meeting // June 19th 2008// Montral, Canada 33