This benchmark was presented as one of the case study of the 2007 Agtive tool contest. The goal of this case study is to measure the performance of graph transformation tools constructing Sierpinski triangles. The Sierpinski triangle is a fractal named after Waclaw Sierpinski who described it in 1915. Originally constructed as a mathematical curve, this is one of the basic examples of self-similar sets, i.e. it is a mathematically generated pattern that can be reproduced at any magnification or reduction.
An algorithm for obtaining arbitrarily close approximations to the Sierpinski triangle is as follows:
From the programmers point of view, the most difficult part of implementing the Sierpinski triangle generator is to create the correct triangle ”finder mechanisms”. In our solution, we tried to adhere to the typing scheme found in the problem description by taking advantage of the multiple-inheritance support of the Viatra2 framework resulting the metamodel depicted in Fig. 1
.
<source lang="java"> entity ( node ); entity (a); supertypeOf (node ,a); entity (b); supertypeOf (node ,b); entity ©; supertypeOf (node ,c); entity (ac); supertypeOf (a,ac ); supertypeOf (c,ac ); entity (ab); supertypeOf (a,ab ); supertypeOf (b,ab ); entity (bc); supertypeOf (b,bc ); supertypeOf (c,bc ); relation (e,node , node ); </source> As for the initial model it contained a simple triangle constructed of type A, B and a C nodes with their corresponding edges as shown in the following box: <source lang="java"> //Generating the 0 step model. new(a(A)); new(b(B)); new(c©);
new(node.e(E1,A,B)); new(node.e(E2,B,C)); new(node.e(E3,C,A)); </source>
This representation allowed us to create a very simple and elegant pattern illustrated in Fig. 2, where the left and right side describe the Viatra Textual Command Language (VTCL) representation and the graphical notation, respectively. Capital letters stand for variables, normal letters denote direct references to modelspace elements. For instance the expression (A) declares that the variable A is of type a. On the other hand, the expression node.e(ECA,C,A) means that the variable ECA refers to an edge of type node.e that points from the entity in C to A. The pattern in Fig. 2
matches a triangle with vertices type a,b,c, respectively. The order is granted by the direction of the arrows.
<source lang="java">
pattern triangle(A,B,C,EAB,EBC,ECA) =
//Nodes
a(A); b(B); c©;
//Edges
node.e(EAB,A,B); node.e(EBC,B,C);
node.e(ECA,C,A);
</source>
As for the model manipulation we used simple built in new and delete operators as described in the following box:
<source lang="java">
//delete the inner triangle
delete(EAB);
delete(EBC);
delete(ECA);
//The new nodes are created: new(ab(AB) ); new(bc(BC) ); new(ac(AC) );
//The new edges are created: new(node.e(EAAB,A,AB)); new(node.e(EABAC,AB,AC)); new(node.e(EACA,AC,A));
new(node.e(EABB,AB,B)); new(node.e(EBBC,B,BC)); new(node.e(EBCAB,BC,AB));
new(node.e(EACBC,AC,BC)); new(node.e(EBCC,BC,C)); new(node.e(ECAC,C,AC)); </source>
TODO