Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EMF-IncQuery » Model transformation: how to force the order of output elements based on the order of input elements
Model transformation: how to force the order of output elements based on the order of input elements [message #1022746] Fri, 22 March 2013 13:15 Go to next message
Joost van Pinxten is currently offline Joost van PinxtenFriend
Messages: 51
Registered: November 2012
Member
I'm using the IncQuery API for a model transformation; the source model is based on a DSL which describes a design space. The target model is a somewhat similar DSL, but which describes a concrete instance of a model that conforms to one of the combination of parameters in this design space.

The internal behavior of the elements is described by blocks of procedural expressions and the order of these expression is therefore crucial to the correctness.

When transforming one model into another, one can specify that the activations should be fired in a specific order, but this does not fully guarantee that when an expression 'appears' in between two others (e.g. by programmatically inserting one) that the order in the output model is consistent with the order in the input model.

As far as I have seen, there is no such construction in the EVM yet to enforce this kind of order. Although this may not necessarily be a motivating use-case in case of programmatically starting a transformation, this can become a problem for 'live' model transformations.

I'm thinking it may be possible to solve this by creating an additional pattern, which looks for the 'sibling' of such expressions, so that in the model transformation code the developer can 'see'/deduce what position the newly created element should be inserted.

Although I may not run into this problem in my current use-case (haven't found a case where it matters) it may become a problem in future use-cases. What are your thoughts on this?
Re: Model transformation: how to force the order of output elements based on the order of input elem [message #1022757 is a reply to message #1022746] Fri, 22 March 2013 13:24 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

the VIATRA2 transformation language (that motivated the language/runtime of EMF-IncQuery) allowed putting annotations on patterns that provided a really rough level of ordering - basically you could select a single parameter and set direction to ascending/descending, and then all constructs working within the language received the results in that order.

The same function has not been implemented for EMF-IncQuery yet, but we have an open ticket for it in Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398768 Basically, it would be a nice to have feature, but we did not have time to implement it.

Cheers,
Zoltán
Re: Model transformation: how to force the order of output elements based on the order of input elem [message #1022768 is a reply to message #1022757] Fri, 22 March 2013 13:36 Go to previous messageGo to next message
Joost van Pinxten is currently offline Joost van PinxtenFriend
Messages: 51
Registered: November 2012
Member
Hi Zoltán,

Thanks, that's exactly what I was looking for. Somehow I've used the wrong search terms and did not come up with this item.

I've added myself to the CC of that item Smile Hope that I won't need this functionality in my transformation, as it seems that adding the indices to the matches is not a trivial task.

Cheers!
Joost
Re: Model transformation: how to force the order of output elements based on the order of input elem [message #1028611 is a reply to message #1022768] Thu, 28 March 2013 13:46 Go to previous messageGo to next message
Joost van Pinxten is currently offline Joost van PinxtenFriend
Messages: 51
Registered: November 2012
Member
Thanks to the RulePriorityActivationComparator (RPAC) I'm now able to specify:

1. rule ordering by priority
2. activation ordering (with same rule type) using the original order of containment (see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=403825)

Unfortunately, this is not yet enough for my use case; expression trees do not have a 'static' priority, as they can be nested arbitrarily. Such nesting occurs if you metamodel allows some kind of containment cycles (as is quite common with nested expressions).

Say that I have an abstract Primary element, which specializes into Expression and Literal. Expression specializes again into multiple types: e.g. a BinaryExpression (like add, multiply, etc). Any BinaryExpression has a left and right hand side, which is a containment reference to a Primary (e.g. either a Literal or an Expression).

Based on this, I would like to be able to extend/annotate/label an expression pattern with a 'depth' or 'transformationOrder'. By making all Expression rules the same priority in the RPAC, it would be possible to arrange the activations for the expression containment tree such that the container elements are created before the contained elements are created.

How can I make something like this possible? I've tried the following:

pattern depth(primary : Primary, depth) = {
	Literal(primary);
	depth == 1;
	// Always a leaf element
} or {
	BinaryExpression(primary);
	BinaryExpression.left(primary, left);
	BinaryExpression.right(primary, right);
	
	find primaryExpressionDepth(left, ldepth);
	find primaryExpressionDepth(right, rdepth);
	
//	check(depth == Math::max(ldepth, rdepth) + 1); // No positive inference
//	depth == Math::max(ldepth, rdepth) + 1; // Invalid syntax
}


Is it possible to write such a bottom-up (or top-down) labeling mechanism with the currently available pattern language?

If not, then I'll probably resort to writing a custom solution by modifying the comparison mechanism of the RPAC.

P.S. I'm aware the the RPAC will probably get refactored soon.
Re: Model transformation: how to force the order of output elements based on the order of input elem [message #1028618 is a reply to message #1028611] Thu, 28 March 2013 14:03 Go to previous messageGo to next message
Joost van Pinxten is currently offline Joost van PinxtenFriend
Messages: 51
Registered: November 2012
Member
Enhancement 398722 would do it for me. Also, Enhancement 398770 would be a nice addendum (even nicer in combination with the ability to use eval()).

So my guess is that at the moment this is not possible using the pattern language.
Re: Model transformation: how to force the order of output elements based on the order of input elem [message #1028781 is a reply to message #1028618] Thu, 28 March 2013 18:30 Go to previous message
Istvan Rath is currently offline Istvan RathFriend
Messages: 59
Registered: July 2009
Member
Hi,
to answer your question: indeed, what you wish to do doesn't seem currently possible purely with the query language. In fact, I also suspect that eval() (https://bugs.eclipse.org/bugs/show_bug.cgi?id=398722) would be necessary for your idea to work.

Note that those enhancements are in the "Future" milestone for a reason: they would require a significant conceptual extension / re-work of the evaluation strategy behind IncQuery's queries. While they could be implemented with the current incremental engine with some limitations, a more complete support would probably necessitate to develop a top-down search-based (i.e. non-incremental) evaluation strategy. This is in the works, but in an early research state at the moment.

cheers
Istvan
Previous Topic:Invoke IncQuery in JUnit test cases
Next Topic:Substring search in Atributes [Double-post]
Goto Forum:
  


Current Time: Fri Apr 19 16:34:11 GMT 2024

Powered by FUDForum. Page generated in 0.01682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top