Re: [rules-users] Weighted rules / scoring
by Greg Barton
Don't forget that if you want other rules to react to the changed score you must call update() on the altered object:
rule "Myscoreincreaserule"
dialect "mvel"
when
a : Applicant( name == "chris")
then
a.setScore( a.score + 2 );
update( a );
end
--- On Mon, 6/8/09, Chris Strachan <chris.strac(a)googlemail.com> wrote:
> From: Chris Strachan <chris.strac(a)googlemail.com>
> Subject: Re: [rules-users] Weighted rules / scoring
> To: "Rules Users List" <rules-users(a)lists.jboss.org>
> Date: Monday, June 8, 2009, 1:06 PM
>
> Hi,
>
> Don't think I intended to create a new instance, just
> modify the one
> matched in the rule. The following seems to have got
> it working.
>
> rule "Myscoreincreaserule"
> dialect "mvel"
> when
> a : Applicant( name == "chris"
> )
> then
> a.setScore( a.score + 2 );
> end
>
> Thanks for pointing me in the right direction.
>
> Greg Barton wrote:
> > 1) Where is the variable "score" initialized? If it's
> not a global the rule wouldn't compile.
> >
> > 2) Is your intent to create a new Applicant instance,
> or modify the one matched in the rule? (Or maybe you
> want to gather the score from the matched instance and put
> it (+2) into a new instance?
> >
> > --- On Sun, 6/7/09, Chris Strachan <chris.strac(a)googlemail.com>
> wrote:
> >
> >
> >> From: Chris Strachan <chris.strac(a)googlemail.com>
> >> Subject: [rules-users] Weighted rules / scoring
> >> To: rules-users(a)lists.jboss.org
> >> Date: Sunday, June 7, 2009, 1:11 PM
> >> Hi,
> >>
> >>
> >>
> >> I want to be able to use drools / guvnor brms to
> store
> >> weighted rules
> >>
> >> (scoring), however I can't seem to find a way to
> do
> >> this.
> >>
> >>
> >>
> >> I attempted the following,
> >>
> >>
> >>
> >> rule "Myscoreincreaserule"
> >>
> >> dialect
> "mvel"
> >>
> >> when
> >>
> >>
> Applicant( name ==
> >> "chris" )
> >>
> >> then
> >>
> >>
> Applicant fact0 = new Applicant();
> >>
> >>
> fact0.setScore( score + 2 );
> >>
> >>
> insert(fact0 );
> >>
> >> end
> >>
> >>
> >>
> >> drools didn't seem to like the way I did this.
> >> Perhaps this isn't
> >>
> >> permitted, in effect I am trying to do - score =
> score +
> >> 2.
> >>
> >>
> >>
> >> Upon validation I get the following error.
> >>
> >>
> >>
> >>
> [Myscoreincreaserule] Unable to build
> >> expression for 'consequence': Failed
> >>
> >> to compile: 1 compilation error(s): - (1,3)
> unqualified
> >> type in strict mode
> >>
> >> for: age ' Applicant fact0 = new Applicant();
> >> fact0.setScore( score + 2 );
> >>
> >> insert(fact0 ); '
> >>
> >>
> >>
> >> Any ideas on how I should be approaching this?
> >>
> >>
> >>
> >> Thanks,
> >>
> >>
> >> -----Inline Attachment Follows-----
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users(a)lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >>
> >
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
15 years, 6 months
Re: [rules-users] Weighted rules / scoring
by Greg Barton
1) Where is the variable "score" initialized? If it's not a global the rule wouldn't compile.
2) Is your intent to create a new Applicant instance, or modify the one matched in the rule? (Or maybe you want to gather the score from the matched instance and put it (+2) into a new instance?
--- On Sun, 6/7/09, Chris Strachan <chris.strac(a)googlemail.com> wrote:
> From: Chris Strachan <chris.strac(a)googlemail.com>
> Subject: [rules-users] Weighted rules / scoring
> To: rules-users(a)lists.jboss.org
> Date: Sunday, June 7, 2009, 1:11 PM
> Hi,
>
>
>
> I want to be able to use drools / guvnor brms to store
> weighted rules
>
> (scoring), however I can't seem to find a way to do
> this.
>
>
>
> I attempted the following,
>
>
>
> rule "Myscoreincreaserule"
>
> dialect "mvel"
>
> when
>
> Applicant( name ==
> "chris" )
>
> then
>
> Applicant fact0 = new Applicant();
>
> fact0.setScore( score + 2 );
>
> insert(fact0 );
>
> end
>
>
>
> drools didn't seem to like the way I did this.
> Perhaps this isn't
>
> permitted, in effect I am trying to do - score = score +
> 2.
>
>
>
> Upon validation I get the following error.
>
>
>
> [Myscoreincreaserule] Unable to build
> expression for 'consequence': Failed
>
> to compile: 1 compilation error(s): - (1,3) unqualified
> type in strict mode
>
> for: age ' Applicant fact0 = new Applicant();
> fact0.setScore( score + 2 );
>
> insert(fact0 ); '
>
>
>
> Any ideas on how I should be approaching this?
>
>
>
> Thanks,
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
15 years, 6 months
Templates / Generated rules debugging
by Malenfant, Andre
Hi,
Can some of your share your technique for debugging/troubleshooting rules:
Here is the situation:
- I have a web application that uses rules at specific points.
- I use templates and decision tables so the actual rules are compiled by my application using a spread sheet compiler.
- Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something)
I must not be the only one asking this question but I cannot find answers in the archives.
Thanks,
André Malenfant
15 years, 6 months
Strange situation when defining arrays in Drools 5
by Luis Silva
Last friday, I had the next situation. In drools 4.0.7 I had the expression:
new double[]{-1, 1}
And it worked.
But in Drools 5.0 I had to erase the blank space (before "1" and after ","),
because I was getting a warning message, during knowledge base building :
"line 29:114 extraneous input '1' expecting RIGHT_CURLY"
and an exception, during rule execution :
"org.drools.runtime.rule.ConsequenceException:
java.lang.IndexOutOfBoundsException"
So the working expression for Drool 5.0 was: new double[]{-1,1}
--
Luis Enrique Silva Valdivieso
15 years, 6 months
Timestamp for processing Historical Data
by PriyaSha
Hi,
I had a chance to go through the fusion sample. I tried the same example
with another logfile as input
Input:
1000 critical Symantec
5000 critical Symantec
6000 critical Symantec
Here I set the timestamp as ( some date in the past + first column of the
input).
*
Following is the simple DRL which has the rule to count number of OMTicket
using sliding window.
package* org.drools.examples.broker;
*
import* org.drools.examples.broker.model.OMTicket;
*
dialect* "mvel"
*
declare* OMTicket
@role( event )
@timestamp (timestamp)
@expires (1h)
*
end*
*
rule* "Count over last 5 seconds"
*
salience* 10
*
no-loop* *true
when
*
Number( $count : intValue ) *from* *accumulate* (
OMTicket($severity:severity) over window:time(5s) *from* entry-point "OM
stream", count() )
*
then*
System.out.println("Number of Critical Tickets over last 5 seconds : " +
$count);
*end*
Here, I just read and insert facts as events with no scheduling.
But the ouput varies for each invocation and it is also not as expected.
Am I missing any configuration here?
15 years, 6 months
ResourceChangeNotifier and subscribeResourceChangeListener()
by Andrew Nguyen
I am using Guvnor and have configured a change-set.xml to look towards
http://..../LATEST. I would like to add a listener to
ResourceChangeNotifier that will respond to detected changes. I
implemented the ResourceChangeListener interface and have added it via
the subscribeResourceChangeListener() but my resourcesChanged()
function never seems to be called. I'm wondering if my assumption and
usage of everything is correct...
Thanks,
Andrew
15 years, 6 months
Rules storage in a database
by Bhamidi, Krishna
Hello,
we have stored rules in a database, and require to migrate the rules from say a development database to a test database, and further to a production database and use Guvnor for analysts to view current rules in the production database. Has anyone attempted this, and is there an appropriate deployment scenario for this? Has anyone attempted a similar deployment scenario?
We have found that the tables that get created are not always the same - we have had 4 tables created in one environment, and 8 in another; what drives the table creation? Any documentation we can refer to?
Would appreciate pointers.
Krishna
15 years, 6 months
Problem with modify sentence
by Kevin Alonso
Hi all,
I get a compilation error in a "then" part of the rule with the next
sentence:
modify ( rules ) { allowedGuesses -= 1 }
This problem has appeared after update from 5.0 CR1 to Drools 5.0
final version.
Is it a bug?
Thank you,
Kevin.
15 years, 6 months
Weighted rules / scoring
by Chris Strachan
Hi,
I want to be able to use drools / guvnor brms to store weighted rules
(scoring), however I can't seem to find a way to do this.
I attempted the following,
rule "Myscoreincreaserule"
dialect "mvel"
when
Applicant( name == "chris" )
then
Applicant fact0 = new Applicant();
fact0.setScore( score + 2 );
insert(fact0 );
end
drools didn't seem to like the way I did this. Perhaps this isn't
permitted, in effect I am trying to do - score = score + 2.
Upon validation I get the following error.
[Myscoreincreaserule] Unable to build expression for 'consequence':
Failed
to compile: 1 compilation error(s): - (1,3) unqualified type in strict mode
for: age ' Applicant fact0 = new Applicant(); fact0.setScore( score + 2 );
insert(fact0 ); '
Any ideas on how I should be approaching this?
Thanks,
15 years, 6 months