Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » IExpressionEvaluator Questions
IExpressionEvaluator Questions [message #1821878] Fri, 21 February 2020 14:30 Go to next message
Hans van der Laan is currently offline Hans van der LaanFriend
Messages: 34
Registered: February 2020
Member
I'm trying out the tutorial and I was wondering how one can create patterns with Java.

The documentation of the IExpressionEvaluator states that it can be used to execute arbitrary java code for the pattern matching, as long as we correctly give back all parameter names with getInputParameterNames().

Does this mean that we can thus use any java-defined pattern with Rete's / LocalSearch as long as it only depends on the input parameters? Are there any caveats?



Re: IExpressionEvaluator Questions [message #1821883 is a reply to message #1821878] Fri, 21 February 2020 15:29 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi Hans,

as you have written the Java code must _only_ depend on the input parameters and be deterministic, but otherwise anything that compiles should work. The planning assumes that the evaluation of a given expression is fast thus the evaluation is often done as soon as possible (but breaking this assumption "only" results in suboptimal performance). Two important corner cases (but still consistent with the previous semantics):

(1) if the code throws an exception (e.g. division by zero), it is considered not matching.
(2) the code should not expect any specific evaluation order - the evaluator will only be called for inputs the matcher considers potential match for the pattern in the order it finds them.

Best regards,
Zoltán
Re: IExpressionEvaluator Questions [message #1821884 is a reply to message #1821878] Fri, 21 February 2020 15:36 Go to previous messageGo to next message
Gabor Bergmann is currently offline Gabor BergmannFriend
Messages: 36
Registered: July 2009
Member
Hi Hans,

also, calling custom Java functions is available is possible not only using the IExpressionEvaluator API, but also through the VQL language as well:
https://www.eclipse.org/viatra/documentation/query-language.html#!#_function_whitelist

Best,
Gábor
Re: IExpressionEvaluator Questions [message #1821892 is a reply to message #1821884] Fri, 21 February 2020 16:06 Go to previous message
Hans van der Laan is currently offline Hans van der LaanFriend
Messages: 34
Registered: February 2020
Member
Hello,

That's great to hear! I'm considering using Viatra for my master thesis and that was the make-or-break feature.

Kind regards,

Hans
Previous Topic:Small Tutorial Bug: HostInstance with empty IP address
Next Topic:Create CheckConstraint
Goto Forum:
  


Current Time: Fri Dec 13 03:00:15 GMT 2024

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

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

Back to the top