Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Problem with OCL code while comparing the same class attribute of two instances
Problem with OCL code while comparing the same class attribute of two instances [message #1815895] Mon, 14 October 2019 15:24 Go to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Hi there,
I am using a constraint solver to check constraint satisfiability. The solver takes OCL constraint. I have written a persons2families transformation. Consider the code bellow, in which a Male with the max age is a father.
operation Persons!Male isFather() : Boolean {
	for (i in Persons!Male.all())
	{
		if (self.lastName = i.lastName)
		{
			if (i.age > self.age)
			{
				return false;
			}
		}
	}
	return true;
} 

I pass the conditions in the form of `Type.allInstances()->exists(p|Condition)` which is understandable for the solver. For the `if conditions` above I wonder whether how I can send the logic to solver. Because the type of both sides of operator is the same.
CSP constraint: Male.allInstances.size() <> 0 and Male.allInstances()->exists(p|p.lastName = ?.lastName and p.age>?.age)


Member of MDSE Research Group
http://mdse.ui.ac.ir
Re: Problem with OCL code while comparing the same class attribute of two instances [message #1815900 is a reply to message #1815895] Mon, 14 October 2019 19:29 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Your example is clearly not OCL. "for" rather than "forAll". "return". "if" without "endif". "{...}" rather than" (...)". "Person!Male" looks a bit like ATL. Also your snippet is a query not a constraint.

I have never used a Constraint solver so I cannot advise you on how to condition your code for a solver, other than to observe that OCL to constraint solver is the topic of many academic papers. Since you ask a question on an Eclipse forum, you may find EMFtoCSP helpful.

Regards

Ed Willink
Previous Topic:OCL Classic vs OCL Pivot: IllegalArgumentException:
Next Topic:OCL XText Console not available in Eclipse 2019-09
Goto Forum:
  


Current Time: Thu Apr 25 09:10:46 GMT 2024

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

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

Back to the top