I think your issue is resolved Chris, but just curious would putting the rule like below make it more efficient?<br><br>rule "Myscoreincreaserule"<br>
dialect "mvel"<br>
when<br>
a : Applicant( name == "chris",$score:score )<br>
then<br>
a.setScore( $score + 2 );<br>
end<br><br clear="all">--Sarish<br><br>"Shoot for the moon. Even if you miss it you will land among the stars." - Les Brown
<br><br><div class="gmail_quote">On Mon, Jun 8, 2009 at 11:06 AM, Chris Strachan <span dir="ltr"><<a href="mailto:chris.strac@googlemail.com">chris.strac@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi,<br>
<br>
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.<div class="im"><br>
<br>
rule "Myscoreincreaserule"<br>
dialect "mvel"<br>
when<br></div>
a : Applicant( name == "chris" )<br>
then<br>
a.setScore( a.score + 2 );<br>
end<br>
<br>
Thanks for pointing me in the right direction.<div><div></div><div class="h5"><br>
<br>
Greg Barton wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
1) Where is the variable "score" initialized? If it's not a global the rule wouldn't compile.<br>
<br>
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?<br>
<br>
--- On Sun, 6/7/09, Chris Strachan <<a href="mailto:chris.strac@googlemail.com" target="_blank">chris.strac@googlemail.com</a>> wrote:<br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
From: Chris Strachan <<a href="mailto:chris.strac@googlemail.com" target="_blank">chris.strac@googlemail.com</a>><br>
Subject: [rules-users] Weighted rules / scoring<br>
To: <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
Date: Sunday, June 7, 2009, 1:11 PM<br>
Hi,<br>
<br>
<br>
<br>
I want to be able to use drools / guvnor brms to store<br>
weighted rules<br>
<br>
(scoring), however I can't seem to find a way to do<br>
this.<br>
<br>
<br>
<br>
I attempted the following,<br>
<br>
<br>
<br>
rule "Myscoreincreaserule"<br>
<br>
dialect "mvel"<br>
<br>
when<br>
<br>
Applicant( name ==<br>
"chris" )<br>
<br>
then<br>
<br>
Applicant fact0 = new Applicant();<br>
<br>
fact0.setScore( score + 2 );<br>
<br>
insert(fact0 );<br>
<br>
end<br>
<br>
<br>
<br>
drools didn't seem to like the way I did this.<br>
Perhaps this isn't<br>
<br>
permitted, in effect I am trying to do - score = score +<br>
2.<br>
<br>
<br>
<br>
Upon validation I get the following error.<br>
<br>
<br>
<br>
[Myscoreincreaserule] Unable to build<br>
expression for 'consequence': Failed<br>
<br>
to compile: 1 compilation error(s): - (1,3) unqualified<br>
type in strict mode<br>
<br>
for: age ' Applicant fact0 = new Applicant();<br>
fact0.setScore( score + 2 );<br>
<br>
insert(fact0 ); '<br>
<br>
<br>
<br>
Any ideas on how I should be approaching this?<br>
<br>
<br>
<br>
Thanks,<br>
<br>
<br>
-----Inline Attachment Follows-----<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
</blockquote>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>