<span class="Apple-style-span" style="font-family: 'times new roman'; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Hi,<br><br>I'm a student currently evaluating Drools Solver for my dissertation. I am currently trying to solve an optimization problem with two different solvers (one of which is Drools Solver) and I am comparing the results with earlier obtained results from literature. However I am having some troubles with the performance of Drools Solver, and I was hoping if someone could look at my rules to see if they could be tuned:<br>
<br>rule "patientsToBeAssignedToRoomsOfAppropriateSex"<br> when<br> $n : Night();<br> $room : Room(sexRestriction == Sex.Dependent && capacity > 1);<br> $genders : ArrayList(size>1) from collect( PatientStay(bed.room == $room, night == $n) );<br>
exists PatientStay(bed.room == $room, night == $n, $a : admission, eval(((PatientStay)$genders.get(0)).getAdmission().getPatient().getSex() != $a.getPatient().getSex()));<br> then<br> insertLogical(new IntConstraintOccurrence("patientsToBeAssignedToRoomsOfAppropriateSex",ConstraintType.NEGATIVE_HARD,50,$room,$n));<br>
end<br><br>rule "hasRequiredRoomProperties"<br> when<br> $pr : RequiredRoomPropertiesConstraint($a : admission, $r : room, $w : weight );<br> $ps : PatientStay(admission == $a, bed.room == $r);<br>
then<br> insertLogical(new IntConstraintOccurrence("hasPreferredRoomProperties",ConstraintType.NEGATIVE_SOFT,50*$w,$ps));<br>end<br><br>rule "unplannedTransfers"<br> when<br>
$ps : PatientStay($a : admission, $b : bed, $n : night);<br> $ps2 : PatientStay(admission == $a, bed != $b, $n2 : night,eval($n.getIndex()+1 == $n2.getIndex()));<br> then<br> insertLogical(new IntConstraintOccurrence("unplannedTransfers",ConstraintType.NEGATIVE_SOFT,110,$ps,$ps2));<br>
end<br><br>rule "hasPreferredRoomProperties"<br> when<br> $pr : PreferredRoomPropertiesConstraint($a : admission, $r : room, $w : weight );<br> $ps : PatientStay(admission == $a, bed.room == $r);<br>
then<br> insertLogical(new IntConstraintOccurrence("hasPreferredRoomProperties",ConstraintType.NEGATIVE_SOFT,20*$w,$ps));<br>end<br><br>rule "meetsRoomPreference"<br> when<br>
$mr : MeetsRoomPreferenceConstraint($a : admission, $r : room);<br> $ps : PatientStay(admission == $a, bed.room == $r);<br> then<br> insertLogical(new IntConstraintOccurrence("meetsRoomPreference",ConstraintType.NEGATIVE_SOFT,8,$ps));<br>
end<br><br>rule "inGoodDepartment"<br> when<br> $gd : GoodDepartmentConstraint($a : admission, $d : department);<br> $ps : PatientStay(admission == $a, $b : bed, eval($b.getRoom().getDepartment().equals($d)));<br>
then<br> insertLogical(new IntConstraintOccurrence("inGoodDepartment",ConstraintType.NEGATIVE_SOFT,10,$ps));<br>end<br><br>rule "inGoodRoom"<br> when<br> $gr : GoodRoomConstraint($a : admission, $r : room, $w : weight);<br>
$ps : PatientStay(admission == $a, bed.room == $r);<br> then<br> insertLogical(new IntConstraintOccurrence("inGoodRoom",ConstraintType.NEGATIVE_SOFT,10*$w,$ps)); <br>
end<br><br>rule "calcScore"<br>salience -10<br> when<br> $count : Number() from accumulate( IntConstraintOccurrence($w : weight) ,<br> sum($w) );<br>
then<br> scoreCalculator.setScore(-$count.doubleValue());<br>end<br><br>The classes with **Constraint in it are possible combinations that cause a constraint to be violated, and are calculated and inserted at initialization time (and are never changed). I know that the rule "patientsToBeAssignedToRoomsOfAppropriateSex" is fairly complex, but even when I remove it, the performance is not fantastic. Is there anything else I can do to get better performance? I'm already using JDK 1.6 and -server mode. Furthermore, all classes used here have their default equals and hashCode methods, so they don't have an impact on performance.<br>
<br>Sincerely,<br><br>Wim Vancroonenburg</span><br>