Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EVL: How to define a Generic Constraint
EVL: How to define a Generic Constraint [message #1726179] Thu, 10 March 2016 11:10 Go to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi,

I want to enforce some first-order predicates on a UML model. To define the quantifier formulas like FORALL and THERE EXISTS on the model elements like stereotypes, classifiers and etc, I need to define constraints which are required to have generic types. These constraints' generic types must be bound to the real model elements to satisfy the defined quantifier formulas.

Is there a mechanism like the generic type definition on the generic functions of the programming languages like C++ and Java to define such generic constraints?

If the answer to the above question is negative, would you recommend any similar method or trick to define the mentioned quantifier formulas in the EVL language?

Best regards,
Alireza
Re: EVL: How to define a Generic Constraint [message #1726180 is a reply to message #1726179] Thu, 10 March 2016 11:21 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Off the top of my head, would it be enough to define an EVL rule on a superclass of all UML objects and use as guard that it has one of those annotations?

Your constraints would probably need to be implemented using EMF's reflection capabilities (going through x.eClass.eAllAttributes or x.eClass.eAllReferences).
Re: EVL: How to define a Generic Constraint [message #1726246 is a reply to message #1726180] Thu, 10 March 2016 17:35 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Antonio,

Excuse me. Actually, I did not get your suggested solution. Please, if it is possible, explain it more.
I have a constraint like the following as one of the constituent predicates of the quantifier formulas which must be satisfied:
@lazy
constraint GetOperationOfHandlerMustBeAbstract {
	guard : self.satisfies("DefinesGet")
    check : self.base_Interface.hasAbstractOperation(GetStereotype)
	message : self.base_Interface.missedAbstractPropertyOfOperationMsg(GetStereotype)
	fix {
		title : "Change the " + self.base_Interface.getOperation(GetStereotype).name + " to a/an abstract."
		do {
			self.base_Interface.getOperation(GetStereotype).isAbstract = true;
		}
	}
}


I mean, how can I change the above constraint to have a generic constraint like the following:
@lazy
constraint [X]OperationOf[Y]MustBeAbstract {
	guard : self.satisfies("Defines[X]")
    check : self.base_Interface.hasAbstractOperation([X]Stereotype)
	message : self.base_Interface.missedAbstractPropertyOfOperationMsg([X]Stereotype)
	fix {
		title : "Change the " + self.base_Interface.getOperation([X]Stereotype).name + " to a/an abstract."
		do {
			self.base_Interface.getOperation([X]Stereotype).isAbstract = true;
		}
	}
}


In other words, the X and Y are the quantifier variables in a formula like:
FORALL Y: Handler | EXISTS X: Operation  => isAbstract(Y::X)


Best regards,
Alireza
Re: EVL: How to define a Generic Constraint [message #1726250 is a reply to message #1726246] Thu, 10 March 2016 17:44 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Sorry, I thought you were annotating UML models with another model and then running EVL scripts on the combination.

EVL doesn't have any "meta" facilities for generating constraints on the fly, but you could write an EGL script that generates an EVL script, for instance.

How do you define the values of Y in that formula? Do they come from another model, or are they fixed in some way?
Re: EVL: How to define a Generic Constraint [message #1726254 is a reply to message #1726250] Thu, 10 March 2016 18:26 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Antonio,

Thanks a lot for your reply.

Here, in the mentioned example, the Handler is a given class's stereotype and X is one of its operation.
In other words, each model which has a <<Handler>> stereotyped class with an operation stereotyped with <<Get>> can be a candidate to satisfy my quantifier formula. The model can have multiple classes of Handler stereotyped but this number is fixed for any given model. In fact, the bounded values of the variables like X and Y are fixed in the given model. Depending on the kind of the quantifier formulas (FORALL/EXISTS), these variables are bounded to the model elements and may satisfy the predicates in the form of constraints.

Best regards,
Alireza

[Updated on: Fri, 11 March 2016 06:39]

Report message to a moderator

Re: EVL: How to define a Generic Constraint [message #1726306 is a reply to message #1726254] Fri, 11 March 2016 09:36 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Do you only have one fixed Handler stereotype, or multiple Handler stereotypes?

If you have a fixed Handler stereotype, you could use it as context for the EVL rule and it would be like the "forall" you're looking for, and then within the rule you could do the "exists".

If you have multiple Handler stereotypes, can you group them into a common superstereotype and define the EVL rule on that?

You could also use superstereotypes for the operation stereotypes (like <<Get>>).

[Updated on: Fri, 11 March 2016 09:37]

Report message to a moderator

Re: EVL: How to define a Generic Constraint [message #1726309 is a reply to message #1726306] Fri, 11 March 2016 09:45 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Antonio,

Thanks a lot for the reply.
There is only one Handler stereotype.

For now, I think your suggested solution can resolve my problem. Did you mean, I should use "Handler" and "Get" in the constraint definition instead of using the "X", "Y", ... which are the quantifier variable names?

Best regards,
Alireza

[Updated on: Fri, 11 March 2016 09:49]

Report message to a moderator

Re: EVL: How to define a Generic Constraint [message #1726315 is a reply to message #1726309] Fri, 11 March 2016 10:23 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

What I mean is using Handler as the context:

context Handler {
  constraint YourConstraint {
    check {
       ... evaluate exists formula ...
    }
  }
}
Re: EVL: How to define a Generic Constraint [message #1726316 is a reply to message #1726315] Fri, 11 March 2016 10:27 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Antonio,

What is your suggestion for the formula which has the EXISTS quantifier on the Handler itself?
Re: EVL: How to define a Generic Constraint [message #1726422 is a reply to message #1726316] Sun, 13 March 2016 11:38 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

I suppose I'd write it as an exists(...) query on a list:

yourSequence.exists(e | condition on e);
Re: EVL: How to define a Generic Constraint [message #1726432 is a reply to message #1726422] Sun, 13 March 2016 13:49 Go to previous message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Thanks a lot.

Best regards,
Alireza
Previous Topic:[EVL] Call Operations of Metamodel
Next Topic:[emfatic] Converting ecore to emfatic - exception
Goto Forum:
  


Current Time: Thu Apr 25 05:12:51 GMT 2024

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

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

Back to the top