Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] need to do a calcul one Time
[ATL] need to do a calcul one Time [message #32979] Sat, 21 April 2007 18:14 Go to next message
Eclipse UserFriend
Originally posted by: touzitou.enstimac.fr

Hi to all ATL man and women;

My problem i think it is easy but i can't resolve it (:)
i need to do some calcul(find some values) in the input model of my
transformation for one time. Because it's very heavy to do it (to call
the helper) in every matched rule.
i try to do this
use a helper :
helper def: cisPoolId: String=0;
and initialize it in a do{} section of my first matched rule.. but after
in the next rule my helper is always 0. so i understand that we apply do
sections of one matched rules once all the matched rules are applied. it
is that ?
Ok but how can i do ??
Thxs for help !!!
Re: [ATL] need to do a calcul one Time [message #33085 is a reply to message #32979] Sun, 22 April 2007 12:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marcos.didonet-del-fabro.univ-nantes.fr

Hello,

the matched rules are declarative, so it doesn't mean that the first rule in the module
will be executed first. Maybe that's the reason why the helper's value is 0.

I give below a simple example of attriuute helper that is used to count the number of
times a rule is executed:


helper def : countRules : Integer = 1;

rule Example

.....

do {
thisModule.countRules <- thisModule.countRules + 1;
}


Regards,

Marcos.

jihed wrote:
> Hi to all ATL man and women;
>
> My problem i think it is easy but i can't resolve it (:)
> i need to do some calcul(find some values) in the input model of my
> transformation for one time. Because it's very heavy to do it (to call
> the helper) in every matched rule.
> i try to do this
> use a helper :
> helper def: cisPoolId: String=0;
> and initialize it in a do{} section of my first matched rule.. but after
> in the next rule my helper is always 0. so i understand that we apply do
> sections of one matched rules once all the matched rules are applied. it
> is that ?
> Ok but how can i do ??
> Thxs for help !!!
Re: [ATL] need to do a calcul one Time [message #33118 is a reply to message #33085] Sun, 22 April 2007 14:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: touzitou.enstimac.fr

Hello Marcos!

Thxs for answer ! so the conclusion is that's not possible to do a
calcul in a input model for one time (example : extraction of some
values) and then to use the result of this calcul in matched rules.??

We have to do a calcul every time needed in matched rules ??
it's a problem because this calcul in input metamodel is heavy (2
minutes) and do it for 50 times..is really not good..!!!!

Jihed








Marcos Didonet Del Fabro a écrit :
> Hello,
>
> the matched rules are declarative, so it doesn't mean that the first
> rule in the module will be executed first. Maybe that's the reason why
> the helper's value is 0.
>
> I give below a simple example of attriuute helper that is used to count
> the number of times a rule is executed:
>
>
> helper def : countRules : Integer = 1;
>
> rule Example
>
> ....
>
> do {
> thisModule.countRules <- thisModule.countRules + 1;
> }
>
>
> Regards,
>
> Marcos.
>
> jihed wrote:
>> Hi to all ATL man and women;
>>
>> My problem i think it is easy but i can't resolve it (:)
>> i need to do some calcul(find some values) in the input model of my
>> transformation for one time. Because it's very heavy to do it (to call
>> the helper) in every matched rule.
>> i try to do this
>> use a helper :
>> helper def: cisPoolId: String=0;
>> and initialize it in a do{} section of my first matched rule.. but
>> after in the next rule my helper is always 0. so i understand that we
>> apply do sections of one matched rules once all the matched rules are
>> applied. it is that ?
>> Ok but how can i do ??
>> Thxs for help !!!
Re: [ATL] need to do a calcul one Time [message #33187 is a reply to message #33118] Sun, 22 April 2007 14:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marcos.didonet-del-fabro.univ-nantes.fr

Hi

If you do it only once, you can do it using an entrypoint rule. An entrypoint rule is
executed before all the other rules. It is typically used to initialize model elements.

Syntax:

entrypoint rule FirstRule {
to
....
do {
....
}
}

Regards,

Marcos.

jihed wrote:
> Hello Marcos!
>
> Thxs for answer ! so the conclusion is that's not possible to do a
> calcul in a input model for one time (example : extraction of some
> values) and then to use the result of this calcul in matched rules.??
>
> We have to do a calcul every time needed in matched rules ??
> it's a problem because this calcul in input metamodel is heavy (2
> minutes) and do it for 50 times..is really not good..!!!!
>
> Jihed
>
>
>
>
>
>
>
>
> Marcos Didonet Del Fabro a écrit :
>> Hello,
>>
>> the matched rules are declarative, so it doesn't mean that the first
>> rule in the module will be executed first. Maybe that's the reason why
>> the helper's value is 0.
>>
>> I give below a simple example of attriuute helper that is used to
>> count the number of times a rule is executed:
>>
>>
>> helper def : countRules : Integer = 1;
>>
>> rule Example
>>
>> ....
>>
>> do {
>> thisModule.countRules <- thisModule.countRules + 1;
>> }
>>
>>
>> Regards,
>>
>> Marcos.
>>
>> jihed wrote:
>>> Hi to all ATL man and women;
>>>
>>> My problem i think it is easy but i can't resolve it (:)
>>> i need to do some calcul(find some values) in the input model of my
>>> transformation for one time. Because it's very heavy to do it (to
>>> call the helper) in every matched rule.
>>> i try to do this
>>> use a helper :
>>> helper def: cisPoolId: String=0;
>>> and initialize it in a do{} section of my first matched rule.. but
>>> after in the next rule my helper is always 0. so i understand that we
>>> apply do sections of one matched rules once all the matched rules are
>>> applied. it is that ?
>>> Ok but how can i do ??
>>> Thxs for help !!!
Re: [ATL] need to do a calcul one Time [message #33222 is a reply to message #33187] Sun, 22 April 2007 15:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: touzitou.enstimac.fr

GREAT !!
It is exactly what i need !!
I vOte ATL !!
Thxs Marcus !!





Marcos Didonet Del Fabro a écrit :
> Hi
>
> If you do it only once, you can do it using an entrypoint rule. An
> entrypoint rule is executed before all the other rules. It is typically
> used to initialize model elements.
>
> Syntax:
>
> entrypoint rule FirstRule {
> to
> ...
> do {
> ...
> }
> }
>
> Regards,
>
> Marcos.
>
> jihed wrote:
>> Hello Marcos!
>>
>> Thxs for answer ! so the conclusion is that's not possible to do a
>> calcul in a input model for one time (example : extraction of some
>> values) and then to use the result of this calcul in matched rules.??
>>
>> We have to do a calcul every time needed in matched rules ??
>> it's a problem because this calcul in input metamodel is heavy (2
>> minutes) and do it for 50 times..is really not good..!!!!
>>
>> Jihed
>>
>>
>>
>>
>>
>>
>>
>>
>> Marcos Didonet Del Fabro a écrit :
>>> Hello,
>>>
>>> the matched rules are declarative, so it doesn't mean that the first
>>> rule in the module will be executed first. Maybe that's the reason
>>> why the helper's value is 0.
>>>
>>> I give below a simple example of attriuute helper that is used to
>>> count the number of times a rule is executed:
>>>
>>>
>>> helper def : countRules : Integer = 1;
>>>
>>> rule Example
>>>
>>> ....
>>>
>>> do {
>>> thisModule.countRules <- thisModule.countRules + 1;
>>> }
>>>
>>>
>>> Regards,
>>>
>>> Marcos.
>>>
>>> jihed wrote:
>>>> Hi to all ATL man and women;
>>>>
>>>> My problem i think it is easy but i can't resolve it (:)
>>>> i need to do some calcul(find some values) in the input model of my
>>>> transformation for one time. Because it's very heavy to do it (to
>>>> call the helper) in every matched rule.
>>>> i try to do this
>>>> use a helper :
>>>> helper def: cisPoolId: String=0;
>>>> and initialize it in a do{} section of my first matched rule.. but
>>>> after in the next rule my helper is always 0. so i understand that
>>>> we apply do sections of one matched rules once all the matched rules
>>>> are applied. it is that ?
>>>> Ok but how can i do ??
>>>> Thxs for help !!!
Re: [ATL] need to do a calcul one Time [message #34743 is a reply to message #33222] Fri, 27 April 2007 15:18 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

I would also add that when you define an attribute helper, the result is
cached. This means that the computation is actually performed only once.

You may check this by adding a .debug('message') expression within your
helper (e.g., at the end, but not within an iterator). The message
should be printed only once, which shows that the body of the helper is
evaluated only once. This would be different with an operation attribute
(try adding () after the definition and usage of your helper).

I believe it is interesting to note this, because this means that you
may solve this task *without* using imperative code, only declarative,
which is the recommended way to use ATL :-).

However, obviously, if you *really* need imperative code to perform your
computation, then the solution provided by Marcos is more appropriate.


Regards,

Frédéric Jouault

jihed wrote:
> GREAT !!
> It is exactly what i need !!
> I vOte ATL !!
> Thxs Marcus !!
>
>
>
>
>
> Marcos Didonet Del Fabro a écrit :
>> Hi
>>
>> If you do it only once, you can do it using an entrypoint rule. An
>> entrypoint rule is executed before all the other rules. It is
>> typically used to initialize model elements.
>>
>> Syntax:
>>
>> entrypoint rule FirstRule {
>> to
>> ...
>> do {
>> ...
>> }
>> }
>>
>> Regards,
>>
>> Marcos.
>>
>> jihed wrote:
>>> Hello Marcos!
>>>
>>> Thxs for answer ! so the conclusion is that's not possible to do a
>>> calcul in a input model for one time (example : extraction of some
>>> values) and then to use the result of this calcul in matched rules.??
>>>
>>> We have to do a calcul every time needed in matched rules ??
>>> it's a problem because this calcul in input metamodel is heavy (2
>>> minutes) and do it for 50 times..is really not good..!!!!
>>>
>>> Jihed
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Marcos Didonet Del Fabro a écrit :
>>>> Hello,
>>>>
>>>> the matched rules are declarative, so it doesn't mean that the first
>>>> rule in the module will be executed first. Maybe that's the reason
>>>> why the helper's value is 0.
>>>>
>>>> I give below a simple example of attriuute helper that is used to
>>>> count the number of times a rule is executed:
>>>>
>>>>
>>>> helper def : countRules : Integer = 1;
>>>>
>>>> rule Example
>>>>
>>>> ....
>>>>
>>>> do {
>>>> thisModule.countRules <- thisModule.countRules + 1;
>>>> }
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Marcos.
>>>>
>>>> jihed wrote:
>>>>> Hi to all ATL man and women;
>>>>>
>>>>> My problem i think it is easy but i can't resolve it (:)
>>>>> i need to do some calcul(find some values) in the input model of my
>>>>> transformation for one time. Because it's very heavy to do it (to
>>>>> call the helper) in every matched rule.
>>>>> i try to do this
>>>>> use a helper :
>>>>> helper def: cisPoolId: String=0;
>>>>> and initialize it in a do{} section of my first matched rule.. but
>>>>> after in the next rule my helper is always 0. so i understand that
>>>>> we apply do sections of one matched rules once all the matched
>>>>> rules are applied. it is that ?
>>>>> Ok but how can i do ??
>>>>> Thxs for help !!!
Previous Topic:[ATL] find a target element by resolveTemp
Next Topic:ATL and files
Goto Forum:
  


Current Time: Thu Apr 25 20:41:07 GMT 2024

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

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

Back to the top