[jboss-svn-commits] JBL Code SVN: r32740 - labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed May 5 07:03:23 EDT 2010


Author: ge0ffrey
Date: 2010-05-05 07:03:23 -0400 (Wed, 05 May 2010)
New Revision: 32740

Modified:
   labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl
Log:
nurseRostering: shift on/off requests

Modified: labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl
===================================================================
--- labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl	2010-05-05 10:48:18 UTC (rev 32739)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl	2010-05-05 11:03:23 UTC (rev 32740)
@@ -80,40 +80,40 @@
 // TODO
 
 // Maximum number of consecutive working days // TODO too slow!
-rule "maximumConsecutiveWorkingDays"
-    when
-        $contractLine : ContractLine(
-            contractLineType == ContractLineType.CONSECUTIVE_WORKING_DAYS, maximumEnabled == true,
-            $contract : contract, $maximumIndexDiff : maximumIndexDiff
-        );
-        $employee : Employee(contract == $contract);
+//rule "maximumConsecutiveWorkingDays"
+//    when
+//        $contractLine : ContractLine(
+//            contractLineType == ContractLineType.CONSECUTIVE_WORKING_DAYS, maximumEnabled == true,
+//            $contract : contract, $maximumIndexDiff : maximumIndexDiff
+//        );
+//        $employee : Employee(contract == $contract);
+//
+//        // The first day has no working day before it
+//        EmployeeAssignment(
+//            employee == $employee,
+//            $firstDayIndex : shiftDateDayIndex
+//        );
+//        not EmployeeAssignment(employee == $employee, shiftDateDayIndex == ($firstDayIndex - 1));
+//
+//        // The last day has no working day after it
+//        EmployeeAssignment(
+//            employee == $employee,
+//            shiftDateDayIndex > ($firstDayIndex + $maximumIndexDiff), // Too many days
+//            $lastDayIndex : shiftDateDayIndex
+//        );
+//        not EmployeeAssignment(employee == $employee, shiftDateDayIndex == ($lastDayIndex + 1));
+//
+//        // There are no free days between the first and last day
+//        not(
+//            $shiftDate : ShiftDate(dayIndex > $firstDayIndex && < $lastDayIndex)
+//            and not EmployeeAssignment(employee == $employee, shiftDate == $shiftDate)
+//        );
+//    then
+//        insertLogical(new IntConstraintOccurrence("maximumConsecutiveWorkingDays", ConstraintType.NEGATIVE_SOFT,
+//                ($lastDayIndex - $firstDayIndex - $maximumIndexDiff) * $contractLine.getMaximumWeight(),
+//                $employee, $firstDayIndex, $lastDayIndex));
+//end
 
-        // The first day has no working day before it
-        EmployeeAssignment(
-            employee == $employee,
-            $firstDayIndex : shiftDateDayIndex
-        );
-        not EmployeeAssignment(employee == $employee, shiftDateDayIndex == ($firstDayIndex - 1));
-
-        // The last day has no working day after it
-        EmployeeAssignment(
-            employee == $employee,
-            shiftDateDayIndex > ($firstDayIndex + $maximumIndexDiff), // Too many days
-            $lastDayIndex : shiftDateDayIndex
-        );
-        not EmployeeAssignment(employee == $employee, shiftDateDayIndex == ($lastDayIndex + 1));
-
-        // There are no free days between the first and last day
-        not(
-            $shiftDate : ShiftDate(dayIndex > $firstDayIndex && < $lastDayIndex)
-            and not EmployeeAssignment(employee == $employee, shiftDate == $shiftDate)
-        );
-    then
-        insertLogical(new IntConstraintOccurrence("maximumConsecutiveWorkingDays", ConstraintType.NEGATIVE_SOFT,
-                ($lastDayIndex - $firstDayIndex - $maximumIndexDiff) * $contractLine.getMaximumWeight(),
-                $employee, $firstDayIndex, $lastDayIndex));
-end
-
 // Minimum number of consecutive working days
 //rule "minimumConsecutiveWorkingDays"
 //    when
@@ -223,7 +223,24 @@
 end
 
 // Requested shift on/off
-// TODO
+rule "shiftOffRequest"
+    when
+        $shiftOffRequest : ShiftOffRequest($employee : employee, $shift : shift, $weight : weight);
+        $employeeAssignment : EmployeeAssignment(employee == $employee, shift == $shift);
+    then
+        insertLogical(new IntConstraintOccurrence("shiftOffRequest", ConstraintType.NEGATIVE_SOFT,
+                $weight,
+                $shiftOffRequest, $employeeAssignment));
+end
+rule "shiftOnRequest"
+    when
+        $shiftOnRequest : ShiftOnRequest($employee : employee, $shift : shift, $weight : weight);
+        not EmployeeAssignment(employee == $employee, shift == $shift);
+    then
+        insertLogical(new IntConstraintOccurrence("shiftOnRequest", ConstraintType.NEGATIVE_SOFT,
+                $weight,
+                $shiftOnRequest));
+end
 
 // Alternative skill
 // TODO



More information about the jboss-svn-commits mailing list