title: Grouping Drools Rules in AND/OR groups
body: <p>I have several domain rules (I'll call them 'preconditions') that I am describing as Drools Rules. For example, for a Student to be considered as <code>HasGoodGrades</code>, they must maintain a GPA > 3.0. I also have rules that are basically boolean logic groupings of these preconditions -- such as <code>IsInHonorRoll</code>. For <code>IsInHonorRoll</code> to be true, the rule <code>HasGoodGrades</code> needs to to be satisfied, OR (<code>HasOkGrades</code> AND <code>HasPerfectAttendance</code>).</p>
  
  <p>How I'm handling this is I'm inserting <code>PreconditionResult</code> facts when the rule is satisfied. Then, in these larger 'grouping' rules, I'm checking for these <code>PreconditionResult</code> facts and doing the boolean logic there:</p>
  
  <pre class="lang-drools prettyprint-override"><code>rule "IsInHonorRoll"
        dialect "mvel"
    when
        $s : Student()
        PreconditionResult( id == "HasGoodGrades", student == $s)
        or
        ( PreconditionResult( id == "HasOkGrades", student == $s)
        and
        PreconditionResult( id == "HasPerfectAttendance", student == $s) )
    then
        System.out.print("Student is in the Honor Roll.");
  
  end
  
  rule "HasOkGrades"
        dialect "mvel"
    when
        $s : Student( gpa &gt; 2.0 )
    then
        insert(new PreconditionResult("HasOkGrades", $s))
  end
  
  rule "HasGoodGrades"
        dialect "mvel"
    when
        $s : Student( gpa &lt; 3.0 )
    then
        insert(new PreconditionResult("HasGoodGrades", $s))
  end
  
  rule "HasPerfectAttendance"
        dialect "mvel"
    when
        $s : Student( daysAbsent == 0 )
    then
        insert(new PreconditionResult("HasPerfectAttendance", $s))
  end
  </code></pre>
  
  <p>This seems to work, but feels unnatural, and I'm sure there is a better way to do this type of thing within Drools. More importantly, given enough of these rules and large and complex enough boolean clauses, Drools starts dying with Out of Memory errors, even given very large heap sizes.</p>
  
  <p>What is the best way to handle these boolean logic 'groupings' of Drools Rules? Thanks!</p>