Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Applying the same tranformation rule multiple times on the same match
Applying the same tranformation rule multiple times on the same match [message #1748103] Fri, 18 November 2016 13:56 Go to next message
Erhan Leblebici is currently offline Erhan LeblebiciFriend
Messages: 5
Registered: November 2016
Junior Member
Hello,

I am running a transformation in the incremental mode and trying to apply rules randomly. How can I apply a rule multiple times on the same match? I get exactly one event for a match, so I can react exactly once to the match.

I could of course apply the rule directly multiple times after getting the match event. But I don't always know if the match is still valid after applying the rule for the first (second, third...) time. A rule application can alter its match.

My question: Is there a best practice to get the same match occurrence event multiple times (as long as the match is not broken)?

Cheers,
Erhan
Re: Applying the same tranformation rule multiple times on the same match [message #1748113 is a reply to message #1748103] Fri, 18 November 2016 14:34 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
Hi Erhan,

first of all, the best practice depends a lot on your specific use case. The main question is:


  • are you running the transformation in event-driven mode (incremental in your usage), because the match does not exist at the time when you start the transformation but you want to react to it later?
  • or you have a larger set of rules, some of which you want to run multiple times, and some of which behave as regular event-driven rules (fire on appear/update/disappear)?


Furthermore, what is the stop condition of the rule application?
If a specific case appears, then you will stop the random application?
Are you by any chance doing "design space exploration" (applying a set of rules on a given model until you find preferable modified models)?

If you simply have a set of rules and would like to start executing them randomly, you could use the BatchTransformationStatements.fireUntil and fireWhilePossible methods using rule groups (see https://wiki.eclipse.org/VIATRA/Transformation/Transformation_API#Batch_Transformation_Statements)

If you need design space exploration, read https://wiki.eclipse.org/VIATRA/DSE

If you use event-driven transformation, because the match does not exist yet at the time of the transformation, you can create a "hybrid" transformation, where the action part of the event-driven transformation would execute a batch transformation itself.

If you really need to apply the rules multiple times while running an event-driven transformation (please explain why you want that!), you can do that by defining a specific life-cycle (using EventDrivenTransformationRuleBuilder.addLifeCycle) and provide something similar to DefaultActivationLifeCycle. Please consider the other options and if you find that this is the only one that would work, than tell us.

Cheers,
Ábel
Re: Applying the same tranformation rule multiple times on the same match [message #1748119 is a reply to message #1748113] Fri, 18 November 2016 15:24 Go to previous messageGo to next message
Erhan Leblebici is currently offline Erhan LeblebiciFriend
Messages: 5
Registered: November 2016
Junior Member
Hello Abel,

thanks for the answer.

I am running the transformation in event-driven mode, because matches do not exist at the beginning but I want to react to them when they occur.

In particular, I am developing a random model generator, lets say a tree generator. Starting with an empty resource, I create nodes. I match these nodes with my patterns, and create new ones (child nodes). For example, I'm not able to create a second child for a parent, because I get the match of the parent only once.

I have my own stop conditions like timeout, model size etc. I stop to react to matches when one of them is met.

The "hybrid" solution you suggested seems to be practical. I can start a batch transformation (with its own stop conditions) as a reaction to a match appearance.
Yet I'm still not aware of what can be achieved by own ActivationLifeCycle.


Edit: I guess I need a state transition like the following?
addStateTransition(CRUDActivationStateEnum.CREATED, EventType.RuleEngineEventType.FIRE,
CRUDActivationStateEnum.CREATED);

But of course, then I get termination problems

Cheers,
Erhan

[Updated on: Fri, 18 November 2016 16:03]

Report message to a moderator

Re: Applying the same tranformation rule multiple times on the same match [message #1748361 is a reply to message #1748119] Tue, 22 November 2016 13:13 Go to previous message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
Hi Erhan,

sorry for not responding sooner, it seems that the forum ate my topic subscription...

For a random model generator, the VIATRA DSE component is quite useful, it should solve some common exploration related issues that you may not want to deal with. Of course, if you want to explicitly work on solving these issues in your own way, that is understandable.

VIATRA DSE also uses BatchTransformation rules with stateless life-cycle and simply executes the rules in a big loop with some logic to decide which rule to fire next.

You said you are starting from an empty resource, and if I get it right, it is only modified by your own generator rules, so you don't need event-driven execution, since there is no outside change that you need to react to.

If you would be interested in adopting the VIATRA DSE component to your use case, I can ask the main developer to help you out (if the existing examples are not enough, e.g. https://wiki.eclipse.org/VIATRA/DSE/UserGuide/BPMNExample ).

If you don't want to use VIATRA DSE, you would probably be best off using stateless batch transformation rules and your own logic to decide which rule to fire in any given point. You can still use event-driven rules to drive this logic instead of always looking at the activations of all rules.

Finally, based on what you wrote, using a different life-cycle is not what you need.

Cheers,
Ábel
Previous Topic:Checking the EClass of an EObject in a pattern
Next Topic:referencing VIATRA feature s in our own feature
Goto Forum:
  


Current Time: Thu Apr 25 10:55:02 GMT 2024

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

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

Back to the top