[jboss-svn-commits] JBL Code SVN: r33201 - 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
Sun May 30 10:13:48 EDT 2010
Author: ge0ffrey
Date: 2010-05-30 10:13:47 -0400 (Sun, 30 May 2010)
New Revision: 33201
Modified:
labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java
labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl
Log:
unwantedPatternWorkBeforeFreeSequencePattern is not required for competition
Modified: labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java
===================================================================
--- labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java 2010-05-30 12:49:47 UTC (rev 33200)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/java/org/drools/planner/examples/nurserostering/persistence/NurseRosteringSolutionImporter.java 2010-05-30 14:13:47 UTC (rev 33201)
@@ -322,6 +322,9 @@
pattern = new FreeBeforeWorkSequencePattern();
} else if (patternEntryElementList.get(1).getChild("ShiftType").getText().equals("None")) {
pattern = new WorkBeforeFreeSequencePattern();
+ // TODO support this too (not needed for competition)
+ throw new UnsupportedOperationException("The pattern (" + code + ") is not supported."
+ + " None of the test data exhibits such a pattern.");
} else {
switch (patternEntryElementList.size()) {
case 2 :
@@ -395,7 +398,21 @@
if (pattern instanceof FreeBeforeWorkSequencePattern) {
FreeBeforeWorkSequencePattern castedPattern = (FreeBeforeWorkSequencePattern) pattern;
if (patternEntryIndex == 1) {
+ if (dayOfWeek == null) {
+ // TODO Support an any dayOfWeek too (not needed for competition)
+ throw new UnsupportedOperationException("On patternEntryIndex (" + patternEntryIndex
+ + ") of FreeBeforeWorkSequence pattern (" + pattern.getCode()
+ + ") the dayOfWeek should not be (Any)."
+ + "\n None of the test data exhibits such a pattern.");
+ }
castedPattern.setFirstWorkDayOfWeek(dayOfWeek);
+ if (shiftType != null) {
+ // TODO Support a specific shiftType too (not needed for competition)
+ throw new UnsupportedOperationException("On patternEntryIndex (" + patternEntryIndex
+ + ") of FreeBeforeWorkSequence pattern (" + pattern.getCode()
+ + ") the shiftType should be (Any)."
+ + "\n None of the test data exhibits such a pattern.");
+ }
castedPattern.setWorkShiftType(shiftType);
castedPattern.setWorkDayLength(patternEntryElementList.size() - 1);
}
@@ -425,8 +442,22 @@
} else if (pattern instanceof ShiftType2DaysPattern) {
ShiftType2DaysPattern castedPattern = (ShiftType2DaysPattern) pattern;
if (patternEntryIndex == 0) {
+ if (dayOfWeek != null) {
+ // TODO Support a specific dayOfWeek too (not needed for competition)
+ throw new UnsupportedOperationException("On patternEntryIndex (" + patternEntryIndex
+ + ") of FreeBeforeWorkSequence pattern (" + pattern.getCode()
+ + ") the dayOfWeek should be (Any)."
+ + "\n None of the test data exhibits such a pattern.");
+ }
castedPattern.setStartDayOfWeek(dayOfWeek);
}
+ if (shiftType == null) {
+ // TODO Support any shiftType too (not needed for competition)
+ throw new UnsupportedOperationException("On patternEntryIndex (" + patternEntryIndex
+ + ") of FreeBeforeWorkSequence pattern (" + pattern.getCode()
+ + ") the shiftType should not be (Any)."
+ + "\n None of the test data exhibits such a pattern.");
+ }
switch (patternEntryIndex) {
case 0 :
castedPattern.setDayIndex0ShiftType(shiftType);
@@ -440,6 +471,13 @@
if (patternEntryIndex == 0) {
castedPattern.setStartDayOfWeek(dayOfWeek);
}
+ if (shiftType == null) {
+ // TODO Support any shiftType too
+ throw new UnsupportedOperationException("On patternEntryIndex (" + patternEntryIndex
+ + ") of FreeBeforeWorkSequence pattern (" + pattern.getCode()
+ + ") the shiftType should not be (Any)."
+ + "\n None of the test data exhibits such a pattern.");
+ }
switch (patternEntryIndex) {
case 0 :
castedPattern.setDayIndex0ShiftType(shiftType);
@@ -456,6 +494,13 @@
if (patternEntryIndex == 0) {
castedPattern.setStartDayOfWeek(dayOfWeek);
}
+ if (shiftType == null) {
+ // TODO Support any shiftType too
+ throw new UnsupportedOperationException("On patternEntryIndex (" + patternEntryIndex
+ + ") of FreeBeforeWorkSequence pattern (" + pattern.getCode()
+ + ") the shiftType should not be (Any)."
+ + "\n None of the test data exhibits such a pattern.");
+ }
switch (patternEntryIndex) {
case 0 :
castedPattern.setDayIndex0ShiftType(shiftType);
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-30 12:49:47 UTC (rev 33200)
+++ labs/jbossrules/trunk/drools-planner/drools-planner-examples/src/main/resources/org/drools/planner/examples/nurserostering/solver/nurseRosteringScoreRules.drl 2010-05-30 14:13:47 UTC (rev 33201)
@@ -526,34 +526,68 @@
end
// Unwanted patterns
-rule "unwantedPatternWorkBeforeFreeSequencePattern"
- when
- $pattern : WorkBeforeFreeSequencePattern(
- $workDayOfWeek : workDayOfWeek,
- $workShiftType : workShiftType,
- $freeDayLength : freeDayLength
- )
- PatternContractLine(
- pattern == $pattern, $contract : contract
- )
-
- Assignment(
- eval($workDayOfWeek == null) || (shiftDateDayOfWeek == $workDayOfWeek),
- eval($workShiftType == null) || (shiftType == $workShiftType),
- contract == $contract,
- $employee : employee, $workDayIndex : shiftDateDayIndex
- )
- EmployeeFreeSequence(
- employee == $employee,
- firstDayIndex == ($workDayIndex + 1),
- dayLength >= $freeDayLength
- )
- then
- insertLogical(new IntConstraintOccurrence("unwantedPatternWorkBeforeFreeSequencePattern",
- ConstraintType.NEGATIVE_SOFT,
- $pattern.getWeight(),
- $employee, $pattern, $workDayIndex));
-end
+//rule "unwantedPatternFreeBeforeWorkSequencePattern"
+// when
+// $pattern : FreeBeforeWorkSequencePattern(
+// $firstWorkDayOfWeek : firstWorkDayOfWeek,
+// $workShiftType : workShiftType,
+// $workDayLength : workDayLength
+// )
+// PatternContractLine(
+// pattern == $pattern, $contract : contract
+// )
+//
+// Assignment(
+// eval($firstWorkDayOfWeek == null) || (shiftDateDayOfWeek == $firstWorkDayOfWeek),
+// eval($workShiftType == null) || (shiftType == $workShiftType),
+// contract == $contract,
+// $employee : employee, $firstWorkDayIndex : shiftDateDayIndex
+// )
+// // A free day before
+// EmployeeFreeSequence(
+// employee == $employee,
+// lastDayIndex == ($firstWorkDayIndex - 1)
+// )
+// $employeeWorkSequence(
+// employee == $employee,
+// shiftDateDayIndex == $firstWorkDayIndex,
+// dayLength >= $workDayLength
+// )
+// then
+// insertLogical(new IntConstraintOccurrence("unwantedPatternFreeBeforeWorkSequencePattern",
+// ConstraintType.NEGATIVE_SOFT,
+// $pattern.getWeight(),
+// $employee, $pattern, $firstWorkDayIndex));
+//end
+// TODO support WorkBeforeFreeSequencePattern too (not needed for competition)
+//rule "unwantedPatternWorkBeforeFreeSequencePattern"
+// when
+// $pattern : WorkBeforeFreeSequencePattern(
+// $workDayOfWeek : workDayOfWeek,
+// $workShiftType : workShiftType,
+// $freeDayLength : freeDayLength
+// )
+// PatternContractLine(
+// pattern == $pattern, $contract : contract
+// )
+//
+// Assignment(
+// eval($workDayOfWeek == null) || (shiftDateDayOfWeek == $workDayOfWeek),
+// eval($workShiftType == null) || (shiftType == $workShiftType),
+// contract == $contract,
+// $employee : employee, $workDayIndex : shiftDateDayIndex
+// )
+// EmployeeFreeSequence(
+// employee == $employee,
+// firstDayIndex == ($workDayIndex + 1),
+// dayLength >= $freeDayLength
+// )
+// then
+// insertLogical(new IntConstraintOccurrence("unwantedPatternWorkBeforeFreeSequencePattern",
+// ConstraintType.NEGATIVE_SOFT,
+// $pattern.getWeight(),
+// $employee, $pattern, $workDayIndex));
+//end
rule "unwantedPatternShiftType2DaysPattern"
when
$pattern : ShiftType2DaysPattern(
More information about the jboss-svn-commits
mailing list