Home » Modeling » VIATRA » Can't Use 'iterate'
Can't Use 'iterate' [message #1229934] |
Fri, 10 January 2014 15:32 |
Huseyin Ergin Messages: 4 Registered: January 2014 |
Junior Member |
|
|
Hi everyone. When I try to execute a rule with iterate (to make it as long as possible), I get an error that says the 'in parameters' can not be undefined. But I am doing exactly the same thing from the tutorial pdf of Viatra2. Does anyone has an idea what happened?
This is the full error:
org.eclipse.viatra2.gtasm.interpreter.impl.machine.ASMInterpreterException: The value of the N1 variable can not be 'UNDEF' as it is an INPUT parameter for the immediateLink gtRule
This is my gtrule:
pattern isDirectConnected(N1, N2) =
{
node(N1);
node(N2);
node.next(NXT,N1,N2);
}
gtrule immediateLink(in N1, in N2, out T, out SRC, out TGT) =
{
precondition pattern lhs(N1, N2) =
{
find isDirectConnected(N1,N2);
}
action
{
new(node2node(T));
new(node2node.src(SRC,T,N1));
new(node2node.target(TGT,T,N2));
}
}
This is my execution under main:
let T=undef,SRC=undef,TGT=undef in
iterate
choose N1 below tree.models, N2 below tree.models
with apply immediateLink(N1,N2,T,SRC,TGT);
|
|
|
Re: Can't Use 'iterate' [message #1230266 is a reply to message #1229934] |
Sat, 11 January 2014 13:49 |
Abel Hegedus Messages: 197 Registered: September 2015 |
Senior Member |
|
|
Hi Ergin,
first of all welcome to the VIATRA2 forums.
Can you point out which tutorial pdf you are using? Unfortunately, it may be outdated, as the pdf version of these materials are not kept up to date.
The error message is correct, the problem is that the GT rule needs a value for N1, but it is undef (since it is defined in the choose). If you would like to use an iterate over all possible values of N1, N2 and apply the immediateLink rule, you can do it like this:
iterate choose N1 below tree.models, N2 below tree.models with find isDirectConnected(N1,N2) do
let T=undef, SRC=undef, TGT=undef in try choose with apply immediateLink(N1,N2,T,SRC,TGT) do skip;
If you need additional details or have further questions, it helps a lot to attach at least a VPML and a VTCL file so we can reproduce your issue. The VPML is needed both to see your metamodel (and parse the VTCL) and the instance model (to execute the VTCL).
Finally, if you did not already, please take a look at our new project EMF-IncQuery, which is the very efficient, incremental query evaluation framework of VIATRA2 adopted to EMF models with a nice development tooling and many extensions.
|
|
|
Re: Can't Use 'iterate' [message #1230652 is a reply to message #1230266] |
Sun, 12 January 2014 17:57 |
Huseyin Ergin Messages: 4 Registered: January 2014 |
Junior Member |
|
|
Yes you are right. The pdf is dated as "May 29, 2006".
But I checked what you suggested and I could execute my rules that has as long as possible meaning succesfully. Thanks.
Now my question is: Do I have to put a "find" before "do" because it seems what I write with "find" should totaly be same as precondition pattern of the rule?
pattern preconditionOfImmediateLink(N1, N2) =
{
node(N1);
node(N2);
node.next(NXT,N1,N2);
neg find isGenericConnected(N1,N2);
}
pattern isGenericConnected(N1, N2) =
{
node(N1);
node(N2);
node2node(T);
node2node.src(SRC,T,N1);
node2node.target(TGT,T,N2);
}
gtrule immediateLink(in N1, in N2, out T, out SRC, out TGT) =
{
precondition pattern lhs(N1, N2) =
{
find preconditionOfImmediateLink(N1,N2);
}
action
{
new(node2node(T));
new(node2node.src(SRC,T,N1));
new(node2node.target(TGT,T,N2));
}
}
rule main() = seq {
iterate choose N1 below tree.models, N2 below tree.models with find preconditionOfImmediateLink(N1, N2) do
let T=undef,SRC=undef,TGT=undef in
try choose with apply immediateLink(N1,N2,T,SRC,TGT) do seq {
rename(T,"trace("+name(N1)+":"+name(N2)+")");
move(T,treeTrace.models);
}
}
|
|
| | |
Goto Forum:
Current Time: Thu Nov 07 00:18:11 GMT 2024
Powered by FUDForum. Page generated in 0.28813 seconds
|