Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

mattmadhavan
Hello,
Recently I read/cam across couple of posts regarding Custom operators and Accumulators in Drools 6.x.

I seems that I can import them as functions and use them directly without having to declare them in the configurationBuilder etc.

Can some on Elaborate on this one please?

Do I still extend the Evaluator class? Is there any syntax changes?

Thanks in advance!

Matt'M
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

Edson Tirelli-4

   Matt,

   Accumulate functions can now be imported as described in the documentation:


   AFAIK, there are no changes on how evaluators are used in Drools 6.0, but we do want to make them simpler to use, so we might also add an import-like statement as we did for accumulate functions in the future. 

   Edson




On Wed, Mar 5, 2014 at 12:04 PM, mattmadhavan <[hidden email]> wrote:
Hello,
Recently I read/cam across couple of posts regarding Custom operators and
Accumulators in Drools 6.x.

I seems that I can import them as functions and use them directly without
having to declare them in the configurationBuilder etc.

Can some on Elaborate on this one please?

Do I still extend the Evaluator class? Is there any syntax changes?

Thanks in advance!

Matt'M




--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-x-and-Custom-Operators-Evaluators-and-Accumulators-Using-them-as-regular-functions-tp4028543.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
  Edson Tirelli
  Principal Software Engineer 
  Red Hat Business Systems and Intelligence Group


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

mattmadhavan
Hello,
I am still suck on Drools 5.4/5.5 since I have issues with Custom operators/Evaluators in 5.6.

I am not able to move to Drools 6.x because the spring configuration is screwed up. There is no option to configure Custom operator/Evaluators in kie-spring.

Looks like I just cannot move to 6.x because most of my rules are highly dependent on the Custom operator/evaluator I created!

I am mighty confused.

Any ideas?

Thanks
Matt
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

mattmadhavan
In reply to this post by Edson Tirelli-4
Hello,
Do you have any more information on the Custom Evaluators/Operators for Drools 6.1?

Any information will be appreciated.

Thanks
Matt
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

Mark Proctor
In reply to this post by mattmadhavan
you no longer need to declare custom accumulators, instead they are specified via imports. See docs, notice the “import” bit.


7.8.3.7.4.1. Accumulate CE (preferred syntax)

….

The code for the function is very simple, as we could expect, as all the "dirty" integration work is done by the engine. Finally, to use the function in the rules, the author can import it using the "import accumulate" statement:

import accumulate <class_name> <function_name>

For instance, if one implements the class some.package.VarianceFunction function that implements thevariance function and wants to use it in the rules, he would do the following:


On 5 Mar 2014, at 23:13, mattmadhavan <[hidden email]> wrote:

Hello,
I am still suck on Drools 5.4/5.5 since I have issues with Custom
operators/Evaluators in 5.6.

I am not able to move to Drools 6.x because the spring configuration is
screwed up. There is no option to configure Custom operator/Evaluators in
kie-spring.

Looks like I just cannot move to 6.x because most of my rules are highly
dependent on the Custom operator/evaluator I created!

I am mighty confused.

Any ideas?

Thanks
Matt



--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-x-and-Custom-Operators-Evaluators-and-Accumulators-Using-them-as-regular-functions-tp4028543p4028553.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

mattmadhavan
Hi Mark,
My apologies if I am not clear with my question. I am looking for a way to create and use my own custom evaluator. (I know its similar to custom evaluator)  I have a written a custom eval operator called inlist that will look to see if the left hand is in a range of values as follows: This function again encapsulates a very powerful RegEx utility method my co-worker created:

when
  customer:Customer (cancerType == "THYROID"  && age inlist (10-20, 30- 45, 50, 52,  57-60)
then
   .........................

Note that this works only for Drools 5.3, I could not make it to work for 5.6 due to API compatibility.

And I have no idea how to implement this in Drools 6.x. (I used to spring to configure this)

I doubt I am the only one out there who has a need to write a Custom evaluator.

Another question is if I follow the sane syntax as the custom accumulator - can I use the function on the right hand side. How do I get my operands etc.

I appreciate your help in advance!

Any ideas please?

Thanks
Matt'M
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

mattmadhavan
Hello Mark et all,
I referred the source of the class (FOr API etc) of the built-in evaluator below :

org.drools.core.base.evaluators.MatchesEvaluatorsDefinition
and drools.packagebuilder.conf

drools.evaluator.coincides = org.drools.core.base.evaluators.CoincidesEvaluatorDefinition
drools.evaluator.before = org.drools.core.base.evaluators.BeforeEvaluatorDefinition
drools.evaluator.after = org.drools.core.base.evaluators.AfterEvaluatorDefinition
drools.evaluator.meets = org.drools.core.base.evaluators.MeetsEvaluatorDefinition

It was a breeze, took me less than 10 minutes!

As Mark Proctor mentioned, lots of plumbing has been taken care of in 6.1 and actually this port was really nice and easy.

I was able to port my old inlistoperator from Drools 5.3 to 6.1

Now I am willing to recommend my client to use Drools 6.x for our forth coming major initiative. We have a custom in-house built Rule Engine which I am trying to replace with Drools. The "Custom Evaluator" is a major thing for as as all its really powerful and all the analysts need this.

Without this inlist<.b> operator I am not going anywhere with Drools with my client. We will be processing in excess of 30 million FACTS, (Stateless Session) using Drools when I am done converting the project to use Drools!

Thanks for all

Matt'M