[jboss-svn-commits] JBL Code SVN: r33035 - in labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main: resources/org/drools/planner/examples/nurserostering/solver and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon May 24 08:19:19 EDT 2010
Author: ge0ffrey
Date: 2010-05-24 08:19:18 -0400 (Mon, 24 May 2010)
New Revision: 33035
Modified:
labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/domain/solver/EmployeeFreeDaySequence.java
labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl
Log:
nurse rostering: free days
Modified: labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/domain/solver/EmployeeFreeDaySequence.java
===================================================================
--- labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/domain/solver/EmployeeFreeDaySequence.java 2010-05-24 11:57:26 UTC (rev 33034)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/domain/solver/EmployeeFreeDaySequence.java 2010-05-24 12:19:18 UTC (rev 33035)
@@ -6,7 +6,6 @@
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.drools.planner.examples.nurserostering.domain.Employee;
-import org.drools.planner.examples.nurserostering.domain.ShiftDate;
/**
* @author Geoffrey De Smet
@@ -14,13 +13,13 @@
public class EmployeeFreeDaySequence implements Comparable<EmployeeFreeDaySequence>, Serializable {
private Employee employee;
- private ShiftDate firstShiftDate;
- private ShiftDate lastShiftDate;
+ private int firstDayIndex;
+ private int lastDayIndex;
- public EmployeeFreeDaySequence(Employee employee, ShiftDate firstShiftDate, ShiftDate lastShiftDate) {
+ public EmployeeFreeDaySequence(Employee employee, int firstDayIndex, int lastDayIndex) {
this.employee = employee;
- this.firstShiftDate = firstShiftDate;
- this.lastShiftDate = lastShiftDate;
+ this.firstDayIndex = firstDayIndex;
+ this.lastDayIndex = lastDayIndex;
}
public Employee getEmployee() {
@@ -31,20 +30,20 @@
this.employee = employee;
}
- public ShiftDate getFirstShiftDate() {
- return firstShiftDate;
+ public int getFirstDayIndex() {
+ return firstDayIndex;
}
- public void setFirstShiftDate(ShiftDate firstShiftDate) {
- this.firstShiftDate = firstShiftDate;
+ public void setFirstDayIndex(int firstDayIndex) {
+ this.firstDayIndex = firstDayIndex;
}
- public ShiftDate getLastShiftDate() {
- return lastShiftDate;
+ public int getLastDayIndex() {
+ return lastDayIndex;
}
- public void setLastShiftDate(ShiftDate lastShiftDate) {
- this.lastShiftDate = lastShiftDate;
+ public void setLastDayIndex(int lastDayIndex) {
+ this.lastDayIndex = lastDayIndex;
}
public boolean equals(Object o) {
@@ -54,8 +53,8 @@
EmployeeFreeDaySequence other = (EmployeeFreeDaySequence) o;
return new EqualsBuilder()
.append(employee, other.employee)
- .append(firstShiftDate, other.firstShiftDate)
- .append(lastShiftDate, other.lastShiftDate)
+ .append(firstDayIndex, other.firstDayIndex)
+ .append(lastDayIndex, other.lastDayIndex)
.isEquals();
} else {
return false;
@@ -65,34 +64,26 @@
public int hashCode() {
return new HashCodeBuilder()
.append(employee)
- .append(firstShiftDate)
- .append(lastShiftDate)
+ .append(firstDayIndex)
+ .append(lastDayIndex)
.toHashCode();
}
public int compareTo(EmployeeFreeDaySequence other) {
return new CompareToBuilder()
.append(employee, other.employee)
- .append(firstShiftDate, other.firstShiftDate)
- .append(lastShiftDate, other.lastShiftDate)
+ .append(firstDayIndex, other.firstDayIndex)
+ .append(lastDayIndex, other.lastDayIndex)
.toComparison();
}
- public int getFirstShiftDateDayIndex() {
- return firstShiftDate.getDayIndex();
- }
-
- public int getLastShiftDateDayIndex() {
- return lastShiftDate.getDayIndex();
- }
-
public int getDayLength() {
- return lastShiftDate.getDayIndex() - firstShiftDate.getDayIndex() + 1;
+ return lastDayIndex - firstDayIndex + 1;
}
@Override
public String toString() {
- return employee + " is free between " + firstShiftDate + " - " + lastShiftDate;
+ return employee + " is free between " + firstDayIndex + " - " + lastDayIndex;
}
}
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-24 11:57:26 UTC (rev 33034)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl 2010-05-24 12:19:18 UTC (rev 33035)
@@ -142,7 +142,7 @@
insertLogical(new EmployeeConsecutiveAssignmentEnd($employee, $shiftDate));
end
-
+// TODO rename EmployeeConsecutiveAssignment and use dayIndex ints
rule "insertEmployeeConsecutiveAssignment"
salience 1 // Do these rules first (optional, for performance)
when
@@ -214,65 +214,58 @@
when
EmployeeConsecutiveAssignmentEnd(
$employee : employee,
- $firstShiftDate : shiftDate,
- $firstDayIndex : shiftDateDayIndex
+ $firstDayIndexMinusOne : shiftDateDayIndex
)
EmployeeConsecutiveAssignmentStart(
employee == $employee,
- shiftDateDayIndex > $firstDayIndex,
- $lastShiftDate : shiftDate,
- $lastDayIndex : shiftDateDayIndex
+ shiftDateDayIndex > $firstDayIndexMinusOne,
+ $lastDayIndexPlusOne : shiftDateDayIndex
)
// There are no working days between the first and last day
not EmployeeConsecutiveAssignmentStart(
employee == $employee,
- shiftDateDayIndex > $firstDayIndex && < $lastDayIndex
+ shiftDateDayIndex > $firstDayIndexMinusOne && < $lastDayIndexPlusOne
)
then
- // TODO $firstShiftDate + 1 and $lastShiftDate - 1
- insertLogical(new EmployeeFreeDaySequence($employee, $firstShiftDate, $lastShiftDate));
+ insertLogical(new EmployeeFreeDaySequence($employee, $firstDayIndexMinusOne + 1, $lastDayIndexPlusOne - 1));
end
-//rule "insertFirstEmployeeFreeDaySequence"
-// salience 1 // Do these rules first (optional, for performance)
-// when
-// EmployeeConsecutiveAssignmentStart(
-// $employee : employee,
-// $lastShiftDate : shiftDate,
-// $lastDayIndex : shiftDateDayIndex
-// )
-//
-// // There are no working days before the first day
-// not EmployeeConsecutiveAssignmentEnd(
-// employee == $employee,
-// shiftDateDayIndex < $lastDayIndex
-// )
-// RosterInfo(firstShiftDateDayIndex < $lastDayIndex, $firstShiftDate : firstShiftDate)
-// then
-// // TODO $lastShiftDate - 1
-// insertLogical(new EmployeeFreeDaySequence($employee, $firstShiftDate, $lastShiftDate));
-//end
-//rule "insertLastEmployeeFreeDaySequence"
-// salience 1 // Do these rules first (optional, for performance)
-// when
-// EmployeeConsecutiveAssignmentEnd(
-// $employee : employee,
-// $firstShiftDate : shiftDate,
-// $firstDayIndex : shiftDateDayIndex
-// )
-//
-// // There are no working days after the last day
-// not EmployeeConsecutiveAssignmentStart(
-// employee == $employee,
-// shiftDateDayIndex > $firstDayIndex
-// )
-// RosterInfo(lastShiftDateDayIndex > $firstDayIndex, $lastShiftDate : lastShiftDate)
-// then
-// // TODO $firstShiftDate + 1
-// insertLogical(new EmployeeFreeDaySequence($employee, $firstShiftDate, $lastShiftDate));
-//end
+rule "insertFirstEmployeeFreeDaySequence"
+ salience 1 // Do these rules first (optional, for performance)
+ when
+ EmployeeConsecutiveAssignmentStart(
+ $employee : employee,
+ $lastDayIndexPlusOne : shiftDateDayIndex
+ )
+ // There are no working days before the first day
+ not EmployeeConsecutiveAssignmentEnd(
+ employee == $employee,
+ shiftDateDayIndex < $lastDayIndexPlusOne
+ )
+ RosterInfo(firstShiftDateDayIndex < $lastDayIndexPlusOne, $firstDayIndex : firstShiftDateDayIndex)
+ then
+ insertLogical(new EmployeeFreeDaySequence($employee, $firstDayIndex, $lastDayIndexPlusOne - 1));
+end
+rule "insertLastEmployeeFreeDaySequence"
+ salience 1 // Do these rules first (optional, for performance)
+ when
+ EmployeeConsecutiveAssignmentEnd(
+ $employee : employee,
+ $firstDayIndexMinusOne : shiftDateDayIndex
+ )
+
+ // There are no working days after the last day
+ not EmployeeConsecutiveAssignmentStart(
+ employee == $employee,
+ shiftDateDayIndex > $firstDayIndexMinusOne
+ )
+ RosterInfo(lastShiftDateDayIndex > $firstDayIndexMinusOne, $lastDayIndex : lastShiftDateDayIndex)
+ then
+ insertLogical(new EmployeeFreeDaySequence($employee, $firstDayIndexMinusOne + 1, $lastDayIndex));
+end
+
// Minimum number of consecutive free days
rule "minimumConsecutiveFreeDays"
when
More information about the jboss-svn-commits
mailing list