Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [ETL] Accessing specific output of a transformation rule(Is it possible to use .equivalent() in a similar kind of way as ATL's resolveTemp())
[ETL] Accessing specific output of a transformation rule [message #1843021] Mon, 12 July 2021 08:37 Go to next message
Guillaume Dupont is currently offline Guillaume DupontFriend
Messages: 21
Registered: April 2017
Junior Member
Hello,

I have two metamodels. One called SimplePDL:
https://i.ibb.co/cXwTkDQ/simplepdl.png

The other called PetriNet:
https://i.ibb.co/RBWNCsW/petrinet.png

I want to transform a model of SimplePDL to PetriNet; to do so, there exist the following "informal" rules:
- we can transform a WorkDefinition to a fragment of Petri net as so:
https://i.ibb.co/9T480M0/simplepdl2tina-wd.png

- we can transform a WorkSequence using two arrows between the corresponding fragments of the WorkDefinitions, as so:
https://i.ibb.co/W67R1sX/simplepdl2petrinet-ws.png

To transform WorkDefinition, I can write the following piece of ETL:
rule WorkDefinition2PetriNet 
  transform wd : simplepdl!WorkDefinition
  to p_ready : petrinet!Place,
     p_started : petrinet!Place,
     p_running : petrinet!Place,
     p_finished : petrinet!Place,
     t_start : petrinet!Transition,
     t_finish : petrinet!Transition,
     a_ready_start : petrinet!Arc,
     a_start_started : petrinet!Arc,
     a_start_running : petrinet!Arc,
     a_running_finish : petrinet!Arc,
     a_finish_finished : petrinet!Arc extends Process2PetriNet {
          p_ready.name = wd.name + "_ready";
          p_ready.marking = 1;
          p_started.name = wd.name + "_started";
	 // Etc.
}


But to transform the WorkSequence, I need to make reference to a specific output of the WorkDefinition2PetriNet rule... For instance, if we say I only transform start2finish type WorkSequences, I have:
rule WorkSequence2PetrInet
  transform ws : simplepdl!WorkSequence
  to arc_1 : petrinet!Arc,
     arc_2 : petrinet!Arc {
          arc_1.source = ???; // output 'p_started' of rule 'WorkDefinition2PetriNet' applied to 'ws.predecessor'...
...


How do I do that? I understand that there is the .equivalent() method, but I do not feel like it allows to filter which element we retrieve; i.e.: if I write ws.predecessor.equivalent(), what element will I get? Probably not the element I want, right?

For the record, there is something in ATL to do exactly that, called .resolveTemp(). It works like so:
object.resolveTemp('<rule name>', '<output variable name>');


This retrieves the result of applying the given rule to the given object and select the given output variable. For instance, in the example I have, I would write:
arc_1.source = ws.predecessor.resolveTemp('WorkDefinition2PetriNet', 'p_started');


(This is not proper ATL this is just for the example)

Is there an equivalent in ETL? Or is there another "conventional" way specific to it?

Thank you very much for your help.

G.
Re: [ETL] Accessing specific output of a transformation rule [message #1843022 is a reply to message #1843021] Mon, 12 July 2021 08:45 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Guillaume,

Would using equivalents() which returns all target elements created from a source element - instead of equivalent() which only returns the first element - help with this?

Best,
Dimitris
Re: [ETL] Accessing specific output of a transformation rule [message #1843023 is a reply to message #1843022] Mon, 12 July 2021 08:50 Go to previous messageGo to next message
Guillaume Dupont is currently offline Guillaume DupontFriend
Messages: 21
Registered: April 2017
Junior Member
Hello Dimitris,

Maybe it could, but how do I manage to select the specific element I want from the bag returned by .equivalents()?

Thanks,
G.
Re: [ETL] Accessing specific output of a transformation rule [message #1843024 is a reply to message #1843023] Mon, 12 July 2021 08:54 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

You could use something like

.equivalents().selectByKind(petrinet!Place).second()


Best,
Dimitris
Re: [ETL] Accessing specific output of a transformation rule [message #1843027 is a reply to message #1843024] Mon, 12 July 2021 12:58 Go to previous messageGo to next message
Guillaume Dupont is currently offline Guillaume DupontFriend
Messages: 21
Registered: April 2017
Junior Member
Hello Dimitris,

My guess is that, if I reorganize slightly the output of the rule I break my script completely; this also means the output of the rule has a sense of absolute, non-deterministic ordering.
Also, what happens if there are several rules that may produce a place? I saw that .equivalents() could take as optional argument the name of the rule (but I haven't seen it used in any example).

Thanks,
G.
Re: [ETL] Accessing specific output of a transformation rule [message #1843028 is a reply to message #1843027] Mon, 12 July 2021 13:59 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Guillaume,

> My guess is that, if I reorganize slightly the output of the rule I break my script completely; this also means the output of the rule has a sense of absolute, non-deterministic ordering.

This could be brittle indeed so better have some unit tests in this case (which is a good idea for any non-trivial transformation anyway). Not sure what you mean by "absolute, non-deterministic ordering".

> Also, what happens if there are several rules that may produce a place? I saw that .equivalents() could take as optional argument the name of the rule (but I haven't seen it used in any example).

I've put together an example demonstrating equivalents() with multiple rules that produce multiple elements each in https://www.eclipse.org/epsilon/live/?e69a6cf6

Best,
Dimitris
Re: [ETL] Accessing specific output of a transformation rule [message #1843032 is a reply to message #1843028] Mon, 12 July 2021 15:10 Go to previous messageGo to next message
Guillaume Dupont is currently offline Guillaume DupontFriend
Messages: 21
Registered: April 2017
Junior Member
Hello Dimitris,

You are right, unit testing is always a good (if not mandatory) thing to have!

I said "non-deterministic" but I meant "deterministic" (sorry, doing several things simultaneously...). What I mean is that the order shall always be the same, no matter the version of Epsilon and the backend for executing the rules (I do not know how much this is a reasonable assumption). Typically, in ATL, we never know in which order rules will be executed, as it is a purely declarative language with an optimized scheduler.

Thank you very much for your example playground; this is very instructive!

I guess there exists the possibility to have one rule per output element you need and then select the desired object using rules (rather than variables).

Also, I was wondering, maybe there is a possibility to declare and manage several global associative array/map variables in an ETL script? They would link an input object to an output object for each of the needed concept (this is how resolveTemp works essentially).
For example, we would have "map_readies", "map_finished", "map_finish" and "map_start", each of type "Map(WorkDefinition,Node)", that are being populated in the WorkDefinition2PetriNet rule.

The problem is that we do not know when the rules are actually executed, so there is a slight possibility we could try to access objects resulting from the transformation of a WorkDefinition that has not been executed yet...

Thanks,
G.
Re: [ETL] Accessing specific output of a transformation rule [message #1843044 is a reply to message #1843032] Tue, 13 July 2021 05:44 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Another option could be to use lazy rules and tuples [1] as shown in https://www.eclipse.org/epsilon/live/?5a642489

Best,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/eol/#tuples

[Updated on: Tue, 13 July 2021 05:48]

Report message to a moderator

Re: [ETL] Accessing specific output of a transformation rule [message #1843090 is a reply to message #1843044] Thu, 15 July 2021 08:11 Go to previous messageGo to next message
Guillaume Dupont is currently offline Guillaume DupontFriend
Messages: 21
Registered: April 2017
Junior Member
Hello Dimitris,

Again thank you very much for this example, very instructive. This is indeed, an "acceptable work-around" in my opinion.
That being said, I have this feeling I am a little bit fighting against the language... Is there any chance a future version of ETL might include a native feature to handle my situation? (which I can only imagine is not really that unusual, is it?)

Thanks again,
G.
Re: [ETL] Accessing specific output of a transformation rule [message #1843092 is a reply to message #1843090] Thu, 15 July 2021 08:17 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

I don't think this has come up as an issue before, but it'd make a lot of sense to add such a feature in a future version of ETL. Could you please submit an enhancement request in Eclipse's Bugzilla about this?

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=epsilon

Best,
Dimitris
Previous Topic:Element shown twice in target metamodel
Next Topic:Is it possible to generate a set of files using EGL/EGX?
Goto Forum:
  


Current Time: Thu Apr 25 05:13:42 GMT 2024

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

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

Back to the top