[jboss-svn-commits] JBL Code SVN: r17482 - 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
Tue Jan 1 08:29:27 EST 2008
Author: ge0ffrey
Date: 2008-01-01 08:29:26 -0500 (Tue, 01 Jan 2008)
New Revision: 17482
Modified:
labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationScoreRules.drl
Log:
use of Math.abs
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 2008-01-01 13:09:36 UTC (rev 17481)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/examination/solver/examinationScoreRules.drl 2008-01-01 13:29:26 UTC (rev 17482)
@@ -157,10 +157,7 @@
// Soft constraints
// ############################################################################
-// TODO check if merging twoExamsInARow and twoExamsInADay can be a noticable performance boost
-// because it avoids OR nodes.
-
-// Two exams in a row which share students.
+// Two exams in a row which share students
rule "twoExamsInARow"
when
$institutionalWeighting : InstitutionalWeighting();
@@ -168,15 +165,15 @@
$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)));
+ eval(Math.abs($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.
+// TODO check if merging twoExamsInARow and twoExamsInADay can be a noticable performance boost
+// Two exams in a day which share students
rule "twoExamsInADay"
when
$institutionalWeighting : InstitutionalWeighting();
@@ -184,16 +181,14 @@
$leftExam : Exam(topic == $leftTopic, $leftPeriod : period);
$rightExam : Exam(topic == $rightTopic, $rightPeriod : period);
eval($leftPeriod.getDayIndex() == $rightPeriod.getDayIndex());
- eval($leftPeriod != $rightPeriod);
- eval(($leftPeriod.getPeriodIndex() + 1) != $rightPeriod.getPeriodIndex());
- eval($leftPeriod.getPeriodIndex() != ($rightPeriod.getPeriodIndex() + 1));
+ eval(Math.abs($leftPeriod.getPeriodIndex() - $rightPeriod.getPeriodIndex()) > 1);
then
insertLogical(new IntConstraintOccurrence("twoExamsInADay", ConstraintType.NEGATIVE_SOFT,
$topicConflict.getStudentSize() * $institutionalWeighting.getTwoInADayPenality(),
$leftExam, $rightExam));
end
-// Exams which share students have to few periods between them.
+// Exams which share students have to few periods between them
rule "periodSpread"
when
$institutionalWeighting : InstitutionalWeighting();
More information about the jboss-svn-commits
mailing list