[jboss-svn-commits] JBL Code SVN: r17469 - labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Dec 31 09:26:04 EST 2007


Author: ge0ffrey
Date: 2007-12-31 09:26:04 -0500 (Mon, 31 Dec 2007)
New Revision: 17469

Modified:
   labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationScoreRules.drl
   labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationSolverConfig.xml
Log:
fix twoInARow, twoInADay

Modified: labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationScoreRules.drl
===================================================================
--- labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationScoreRules.drl	2007-12-31 14:10:55 UTC (rev 17468)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationScoreRules.drl	2007-12-31 14:26:04 UTC (rev 17469)
@@ -158,30 +158,32 @@
 // ############################################################################
 
 // Two exams in a row which share students.
-// TODO implement me
-//rule "twoExamsInARow"
-//    when
-//        $institutionalWeighting : InstitutionalWeighting();
-//        $topicConflict : TopicConflict($leftTopic : leftTopic, $rightTopic : rightTopic);
-//        $leftExam : Exam(topic == $leftTopic, $period : period);
-//        $rightExam : Exam(topic == $rightTopic, period == $period); // TODO FIXME
-//    then
-//        insertLogical(new IntConstraintOccurrence("twoExamsInARow", ConstraintType.NEGATIVE_SOFT,
-//            $topicConflict.getStudentSize() * $institutionalWeighting.getTwoInARowPenality(),
-//            $leftExam, $rightExam));
-//end
+rule "twoExamsInARow"
+    when
+        $institutionalWeighting : InstitutionalWeighting();
+        $topicConflict : TopicConflict($leftTopic : leftTopic, $rightTopic : rightTopic);
+        $leftExam : Exam(topic == $leftTopic, $leftPeriod : period);
+        $rightExam : Exam(topic == $rightTopic, $rightPeriod : period);
+        eval($leftPeriod.getDayIndex() == $rightPeriod.getDayIndex());
+        eval((($leftPeriod.getPeriodIndex() + 1) == $rightPeriod.getPeriodIndex())
+            || ($leftPeriod.getPeriodIndex() == ($rightPeriod.getPeriodIndex() + 1)));
+    then
+        insertLogical(new IntConstraintOccurrence("twoExamsInARow", ConstraintType.NEGATIVE_SOFT,
+            $topicConflict.getStudentSize() * $institutionalWeighting.getTwoInARowPenality(),
+            $leftExam, $rightExam));
+end
 
 // Two exams in a day which share students.
 rule "twoExamsInADay"
     when
         $institutionalWeighting : InstitutionalWeighting();
         $topicConflict : TopicConflict($leftTopic : leftTopic, $rightTopic : rightTopic);
-        $leftExam : Exam(topic == $leftTopic, $period : period);
-        // This implementation is slower (turn into MVEL complilation):
-        // $rightExam : Exam(topic == $rightTopic, period.dayIndex == $period.dayIndex);
-        // This implementation is faster:
-        $rightExam : Exam(topic == $rightTopic, eval(period.getDayIndex() == $period.getDayIndex()));
-        // TODO twoExamsInARow should be excluded from twoExamsInADay
+        $leftExam : Exam(topic == $leftTopic, $leftPeriod : period);
+        $rightExam : Exam(topic == $rightTopic, $rightPeriod : period);
+        eval($rightPeriod.getDayIndex() == $leftPeriod.getDayIndex());
+        eval($leftPeriod != $rightPeriod);
+        eval(($leftPeriod.getPeriodIndex() + 1) != $rightPeriod.getPeriodIndex());
+        eval($leftPeriod.getPeriodIndex() != ($rightPeriod.getPeriodIndex() + 1));
     then
         insertLogical(new IntConstraintOccurrence("twoExamsInADay", ConstraintType.NEGATIVE_SOFT,
             $topicConflict.getStudentSize() * $institutionalWeighting.getTwoInADayPenality(),

Modified: labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationSolverConfig.xml
===================================================================
--- labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationSolverConfig.xml	2007-12-31 14:10:55 UTC (rev 17468)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationSolverConfig.xml	2007-12-31 14:26:04 UTC (rev 17469)
@@ -5,27 +5,28 @@
         <scoreCalculatorType>HARD_AND_SOFT_CONSTRAINTS</scoreCalculatorType>
     </scoreCalculator>
     <finish>
-        <maximumSecondsSpend>429</maximumSecondsSpend>
-        <!--<maximumStepCount>100</maximumStepCount>-->
+        <!--<feasableScore>-999999.0</feasableScore>-->
+        <!--<maximumSecondsSpend>429</maximumSecondsSpend>-->
+        <maximumStepCount>100</maximumStepCount>
     </finish>
+    <selector>
+        <moveFactoryClass>org.drools.solver.examples.itc2007.examination.solver.NeighbourExaminationMoveFactory</moveFactoryClass>
+    </selector>
+    <accepter>
+        <completeSolutionTabuSize>1500</completeSolutionTabuSize>
+    </accepter>
+    <forager>
+        <foragerType>MAX_SCORE_OF_ALL</foragerType>
+    </forager>
     <!--<selector>-->
-        <!--<moveFactoryClass>org.drools.solver.examples.itc2007.examination.solver.NeighbourExaminationMoveFactory</moveFactoryClass>-->
+        <!--<moveFactoryClass>org.drools.solver.examples.itc2007.examination.solver.ExaminationMoveFactory</moveFactoryClass>-->
+        <!--<shuffleMovesEveryStep>true</shuffleMovesEveryStep>-->
     <!--</selector>-->
     <!--<accepter>-->
-        <!--<completeSolutionTabuSize>1500</completeSolutionTabuSize>-->
+        <!--<accepterType>SIMULATED_ANNEALING</accepterType>-->
     <!--</accepter>-->
     <!--<forager>-->
-        <!--<foragerType>MAX_SCORE_OF_ALL</foragerType>-->
+        <!--<foragerType>FIRST_RANDOMLY_ACCEPTED</foragerType>-->
     <!--</forager>-->
-    <selector>
-        <moveFactoryClass>org.drools.solver.examples.itc2007.examination.solver.ExaminationMoveFactory</moveFactoryClass>
-        <shuffleMovesEveryStep>true</shuffleMovesEveryStep>
-    </selector>
-    <accepter>
-        <accepterType>SIMULATED_ANNEALING</accepterType>
-    </accepter>
-    <forager>
-        <foragerType>FIRST_RANDOMLY_ACCEPTED</foragerType>
-    </forager>
 </localSearchSolver>
         
\ No newline at end of file




More information about the jboss-svn-commits mailing list