Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Attribute problem(Attribute problem)
Attribute problem [message #1535317] Mon, 29 December 2014 16:45 Go to next message
MSh h2 is currently offline MSh h2Friend
Messages: 5
Registered: October 2014
Junior Member
Hi all,

I am having an error to execute the bellow code, it gives this error.
The transformation encountered an error: Entity excepted as the Container parameter of the ElementCreateRule rule instead of String. (see the Error Log view for details)

The error happens when I create Vote1 as an attribute inside element Voter1:
new(Agent.vote(Vote1) in fqn(Voter1));

It executes only to creates the Voter1, but not the rest (Vote1, and the relations).

When I change fqn() to:
new(Agent.vote(Vote1) in startGraph.model.Voter1);

the problem is :
- Model element constant 'startGraph.model.Voter1' is non-existing in the model space.

index.php/fa/20327/0/

gtrule createNode()=
{
precondition pattern lhs(Voter2,Vote2)=
{
Agent(Voter2);
Agent.vote(Vote2);
Agent.attr(V2Attr,Voter2,Vote2);
check(toBoolean(value(Vote2))==false);
}

action {
let Voter1=undef,Vote1=undef,V1Attr=undef in
seq
{
new(Agent(Voter1) in startGraph.model);
new(instanceOf(Voter1,metamodel.Agent));
rename(Voter1,"Voter"+name(Voter1));

// node Vote1 in Voter1
new(Agent.vote(Vote1) in fqn(Voter1));
new(Agent.attr(V1Attr,Voter1,Vote1));
setValue(Vote1,"false");
new(instanceOf(V1Attr,metamodel.Agent.attr));
new(instanceOf(Vote1,metamodel.Agent.vote));
println("nodes created");

}
}

}
  • Attachment: Vote1.jpg
    (Size: 65.56KB, Downloaded 457 times)
Re: Attribute problem [message #1535557 is a reply to message #1535317] Mon, 29 December 2014 19:52 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

I guess the problematic line is " new(Agent.vote(Vote1) in fqn(Voter1)); " where the fqn function returns a string, but the new operation expects a model element (as described by the error message you have seen).

I have not tried it, but I guess, simply removing the fqn call would work, as follows:

new(Agent.vote(Vote1) in Voter1);

Cheers,
Zoltán
Re: Attribute problem [message #1536811 is a reply to message #1535557] Tue, 30 December 2014 12:47 Go to previous messageGo to next message
MSh h2 is currently offline MSh h2Friend
Messages: 5
Registered: October 2014
Junior Member
Hi Zoltan,

Thanks for the reply. Now it works.

Just one more question please, to run a loop for creating certain amount of nodes, any better idea than the bellow? Because (Transformation executing) doesn't stop.

The idea is to create up to 1000 nodes with 'false' attribute and the same number with 'true'. Then make random connections between them.

rule main()= seq
{
let K=5 in
iterate
seq{
if (K>0)
seq{
forall with apply createNode();
update K=K-1;
}
skip;
}
}

Thanks
Moss
Re: Attribute problem [message #1536836 is a reply to message #1536811] Tue, 30 December 2014 13:07 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
This way it looks a bit easier to read:
rule main()= seq {
  let K=5 in iterate seq{
    if (K>0) seq{
      forall with apply createNode();
      update K=K-1;
    }
    skip;
  }
}


The problem might be that skip will not break the iterate loop, just restart the cycle core. You should use fail to exit the loop.

See https://wiki.eclipse.org/VIATRA2/Examples/VTCL/ASM
Re: Attribute problem [message #1537946 is a reply to message #1536836] Wed, 31 December 2014 03:50 Go to previous message
MSh h2 is currently offline MSh h2Friend
Messages: 5
Registered: October 2014
Junior Member
Hi Abel,

sorry my bad.

Yes, fail does the job.

Many Thanks
Previous Topic:Type Casting
Next Topic:[model obfuscator] error while saving obfuscated model
Goto Forum:
  


Current Time: Thu Mar 28 09:31:38 GMT 2024

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

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

Back to the top