[jboss-svn-commits] JBL Code SVN: r33018 - 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
Sun May 23 10:31:39 EDT 2010
Author: ge0ffrey
Date: 2010-05-23 10:31:38 -0400 (Sun, 23 May 2010)
New Revision: 33018
Modified:
labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl
Log:
nurse rostering score rules minimumTotalAssignments and maximumTotalAssignments
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-23 07:29:57 UTC (rev 33017)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl 2010-05-23 14:31:38 UTC (rev 33018)
@@ -67,13 +67,42 @@
// Soft constraints
// ############################################################################
+// Minimum number of assignments
+rule "minimumTotalAssignments"
+ when
+ $contractLine : MinMaxContractLine(
+ contractLineType == ContractLineType.TOTAL_ASSIGNMENTS, minimumEnabled == true,
+ $contract : contract, $minimumValue : minimumValue
+ )
+ $employee : Employee(contract == $contract)
+ $totalAssignmentSize : Number(intValue < $minimumValue) from accumulate(
+ $assignment : EmployeeAssignment(employee == $employee),
+ count($assignment)
+ )
+ then
+ insertLogical(new IntConstraintOccurrence("minimumTotalAssignments", ConstraintType.NEGATIVE_SOFT,
+ Math.abs($minimumValue - $totalAssignmentSize.intValue()),
+ $employee));
+end
// Maximum number of assignments
-// TODO
+rule "maximumTotalAssignments"
+ when
+ $contractLine : MinMaxContractLine(
+ contractLineType == ContractLineType.TOTAL_ASSIGNMENTS, maximumEnabled == true,
+ $contract : contract, $maximumValue : maximumValue
+ )
+ $employee : Employee(contract == $contract)
+ $totalAssignmentSize : Number(intValue > $maximumValue) from accumulate(
+ $assignment : EmployeeAssignment(employee == $employee),
+ count($assignment)
+ )
+ then
+ insertLogical(new IntConstraintOccurrence("maximumTotalAssignments", ConstraintType.NEGATIVE_SOFT,
+ Math.abs($totalAssignmentSize.intValue() - $maximumValue),
+ $employee));
+end
-// Minimum number of assignments
-// TODO
-
rule "insertEmployeeConsecutiveAssignmentStart"
salience 2 // Do these rules first (optional, for performance)
when
@@ -125,49 +154,46 @@
insertLogical(new EmployeeConsecutiveAssignment($employee, $firstShiftDate, $lastShiftDate));
end
-// Maximum number of consecutive working days
-rule "maximumConsecutiveWorkingDays"
+// Minimum number of consecutive working days
+rule "minimumConsecutiveWorkingDays"
when
$contractLine : MinMaxContractLine(
- contractLineType == ContractLineType.CONSECUTIVE_WORKING_DAYS, maximumEnabled == true,
- $contract : contract, $maximumValue : maximumValue
+ contractLineType == ContractLineType.CONSECUTIVE_WORKING_DAYS, minimumEnabled == true,
+ $contract : contract, $minimumValue : minimumValue
)
$employee : Employee(contract == $contract)
$employeeConsecutiveAssignment : EmployeeConsecutiveAssignment(
employee == $employee,
- dayLength > $maximumValue,
+ dayLength < $minimumValue,
$dayLength : dayLength
)
then
- insertLogical(new IntConstraintOccurrence("maximumConsecutiveWorkingDays", ConstraintType.NEGATIVE_SOFT,
- ($dayLength - $maximumValue) * $contractLine.getMaximumWeight(),
+ insertLogical(new IntConstraintOccurrence("minimumConsecutiveWorkingDays", ConstraintType.NEGATIVE_SOFT,
+ ($minimumValue - $dayLength) * $contractLine.getMinimumWeight(),
$employeeConsecutiveAssignment));
end
-// Minimum number of consecutive working days
-rule "minimumConsecutiveWorkingDays"
+// Maximum number of consecutive working days
+rule "maximumConsecutiveWorkingDays"
when
$contractLine : MinMaxContractLine(
- contractLineType == ContractLineType.CONSECUTIVE_WORKING_DAYS, minimumEnabled == true,
- $contract : contract, $minimumValue : minimumValue
+ contractLineType == ContractLineType.CONSECUTIVE_WORKING_DAYS, maximumEnabled == true,
+ $contract : contract, $maximumValue : maximumValue
)
$employee : Employee(contract == $contract)
$employeeConsecutiveAssignment : EmployeeConsecutiveAssignment(
employee == $employee,
- dayLength < $minimumValue,
+ dayLength > $maximumValue,
$dayLength : dayLength
)
then
- insertLogical(new IntConstraintOccurrence("minimumConsecutiveWorkingDays", ConstraintType.NEGATIVE_SOFT,
- ($minimumValue - $dayLength) * $contractLine.getMinimumWeight(),
+ insertLogical(new IntConstraintOccurrence("maximumConsecutiveWorkingDays", ConstraintType.NEGATIVE_SOFT,
+ ($dayLength - $maximumValue) * $contractLine.getMaximumWeight(),
$employeeConsecutiveAssignment));
end
-// Maximum number of consecutive free days
-// TODO
-
// Minimum number of consecutive free days
//rule "minimumConsecutiveFreeDays"
// when
@@ -206,6 +232,9 @@
// $employee, $firstDayIndex, $lastDayIndex));
//end
+// Maximum number of consecutive free days
+// TODO
+
// Maximum number of consecutive working weekends
// TODO
More information about the jboss-svn-commits
mailing list