[jboss-svn-commits] JBL Code SVN: r19217 - in labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main: java/org/drools/solver/examples/itc2007/examination/solver/solution/initializer and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Mar 23 10:17:12 EDT 2008
Author: ge0ffrey
Date: 2008-03-23 10:17:11 -0400 (Sun, 23 Mar 2008)
New Revision: 19217
Modified:
labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/curriculumcourse/solver/solution/initializer/CurriculumCourseStartingSolutionInitializer.java
labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/examination/solver/solution/initializer/ExaminationStartingSolutionInitializer.java
labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseScoreRules.drl
labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseSolverConfig.xml
Log:
a real starting solution initializer
Modified: labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/curriculumcourse/solver/solution/initializer/CurriculumCourseStartingSolutionInitializer.java
===================================================================
--- labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/curriculumcourse/solver/solution/initializer/CurriculumCourseStartingSolutionInitializer.java 2008-03-23 12:59:11 UTC (rev 19216)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/curriculumcourse/solver/solution/initializer/CurriculumCourseStartingSolutionInitializer.java 2008-03-23 14:17:11 UTC (rev 19217)
@@ -4,6 +4,8 @@
import java.util.Collections;
import java.util.List;
+import org.apache.commons.lang.builder.CompareToBuilder;
+import org.drools.FactHandle;
import org.drools.WorkingMemory;
import org.drools.solver.core.evaluation.EvaluationHandler;
import org.drools.solver.core.solution.Solution;
@@ -14,6 +16,7 @@
import org.drools.solver.examples.itc2007.curriculumcourse.domain.Lecture;
import org.drools.solver.examples.itc2007.curriculumcourse.domain.Period;
import org.drools.solver.examples.itc2007.curriculumcourse.domain.Room;
+import org.drools.solver.examples.itc2007.curriculumcourse.domain.UnavailablePeriodConstraint;
/**
* @author Geoffrey De Smet
@@ -35,79 +38,94 @@
EvaluationHandler evaluationHandler = solver.getEvaluationHandler();
List<Period> periodList = schedule.getPeriodList();
List<Room> roomList = schedule.getRoomList();
-// List<Lecture> lectureList = new ArrayList<Lecture>(schedule.getCourseList().size() * 5);
evaluationHandler.setSolution(schedule);
WorkingMemory workingMemory = evaluationHandler.getStatefulSession();
List<Lecture> lectureList = createLectureList(schedule);
- int tmp = 0;
for (Lecture lecture : lectureList) {
- lecture.setPeriod(periodList.get(tmp % periodList.size()));
- lecture.setRoom(roomList.get(tmp % roomList.size()));
- workingMemory.insert(lecture);
- tmp++;
+ double unscheduledScore = evaluationHandler.fireAllRulesAndCalculateStepScore();
+ FactHandle lectureHandle = null;
+
+ List<PeriodScoring> periodScoringList = new ArrayList<PeriodScoring>(periodList.size());
+ for (Period period : periodList) {
+ if (lectureHandle == null) {
+ lecture.setPeriod(period);
+ lectureHandle = workingMemory.insert(lecture);
+ } else {
+ workingMemory.modifyRetract(lectureHandle);
+ lecture.setPeriod(period);
+ workingMemory.modifyInsert(lectureHandle, lecture);
+ }
+ double score = evaluationHandler.fireAllRulesAndCalculateStepScore();
+ periodScoringList.add(new PeriodScoring(period, score));
+ }
+ Collections.sort(periodScoringList);
+
+ boolean almostPerfectMatch = false;
+ double bestScore = Double.NEGATIVE_INFINITY;
+ Period bestPeriod = null;
+ Room bestRoom = null;
+ for (PeriodScoring periodScoring : periodScoringList) {
+ if (bestScore >= periodScoring.getScore()) {
+ // No need to check the rest
+ break;
+ }
+ workingMemory.modifyRetract(lectureHandle);
+ lecture.setPeriod(periodScoring.getPeriod());
+ workingMemory.modifyInsert(lectureHandle, lecture);
+
+ for (Room room : roomList) {
+ workingMemory.modifyRetract(lectureHandle);
+ lecture.setRoom(room);
+ workingMemory.modifyInsert(lectureHandle, lecture);
+ double score = evaluationHandler.fireAllRulesAndCalculateStepScore();
+ if (score < unscheduledScore) {
+ if (score > bestScore) {
+ bestScore = score;
+ bestPeriod = periodScoring.getPeriod();
+ bestRoom = room;
+ }
+ } else if (score >= unscheduledScore) {
+ // TODO due to the score rules, the score can unscheduledScore can be higher than the score
+ // In theory every possibility should be looked into
+ almostPerfectMatch = true;
+ break;
+ }
+ }
+ if (almostPerfectMatch) {
+ break;
+ }
+ }
+ if (!almostPerfectMatch) {
+ if (bestPeriod == null || bestRoom == null) {
+ throw new IllegalStateException("The bestPeriod (" + bestPeriod + ") or the bestRoom ("
+ + bestRoom + ") cannot be null.");
+ }
+ workingMemory.modifyRetract(lectureHandle);
+ lecture.setPeriod(bestPeriod);
+ lecture.setRoom(bestRoom);
+ workingMemory.modifyInsert(lectureHandle, lecture);
+ }
+ logger.debug(" Lecture ({}) initialized for starting solution.", lecture);
}
-// List<ExamInitialWeight> examInitialWeightList = createExamAssigningScoreList(schedule);
-//
-// for (ExamInitialWeight examInitialWeight : examInitialWeightList) {
-// double unscheduledScore = evaluationHandler.fireAllRulesAndCalculateStepScore();
-// Exam leader = examInitialWeight.getExam();
-// FactHandle leaderHandle = null;
-//
-// List<ExamToHandle> examToHandleList = new ArrayList<ExamToHandle>(5);
-// if (leader.getExamCoincidence() == null) {
-// examToHandleList.add(new ExamToHandle(leader));
-// } else {
-// for (Exam coincidenceExam : leader.getExamCoincidence().getCoincidenceExamSet()) {
-// examToHandleList.add(new ExamToHandle(coincidenceExam));
-// }
-// }
-//
-// List<PeriodScoring> periodScoringList = new ArrayList<PeriodScoring>(periodList.size());
-// for (Period period : periodList) {
-// for (ExamToHandle examToHandle : examToHandleList) {
-// if (examToHandle.getExamHandle() == null) {
-// examToHandle.getExam().setPeriod(period);
-// examToHandle.setExamHandle(workingMemory.insert(examToHandle.getExam()));
-// if (examToHandle.getExam().isCoincidenceLeader()) {
-// leaderHandle = examToHandle.getExamHandle();
-// }
-// } else {
-// workingMemory.modifyRetract(examToHandle.getExamHandle());
-// examToHandle.getExam().setPeriod(period);
-// workingMemory.modifyInsert(examToHandle.getExamHandle(), examToHandle.getExam());
-// }
-// }
-// double score = evaluationHandler.fireAllRulesAndCalculateStepScore();
-// periodScoringList.add(new PeriodScoring(period, score));
-// }
-// Collections.sort(periodScoringList);
-//
-// scheduleLeader(periodScoringList, roomList, evaluationHandler, workingMemory, unscheduledScore,
-// examToHandleList, leader, leaderHandle);
-// lectureList.add(leader);
-//
-// // Schedule the non leaders
-// for (ExamToHandle examToHandle : examToHandleList) {
-// Exam exam = examToHandle.getExam();
-// // Leader already has a room
-// if (!exam.isCoincidenceLeader()) {
-// scheduleNonLeader(roomList, evaluationHandler, workingMemory, exam, examToHandle.getExamHandle());
-// lectureList.add(exam);
-// }
-// }
-// }
Collections.sort(lectureList, new PersistableIdComparator());
schedule.setLectureList(lectureList);
}
-
public List<Lecture> createLectureList(CurriculumCourseSchedule schedule) {
List<Course> courseList = schedule.getCourseList();
+ List<CourseInitializationWeight> courseInitializationWeightList
+ = new ArrayList<CourseInitializationWeight>(courseList.size());
+ for (Course course : courseList) {
+ courseInitializationWeightList.add(new CourseInitializationWeight(schedule, course));
+ }
+ Collections.sort(courseInitializationWeightList);
+
List<Lecture> lectureList = new ArrayList<Lecture>(courseList.size() * 5);
int lectureId = 0;
- for (Course course : courseList) {
+ for (CourseInitializationWeight courseInitializationWeight : courseInitializationWeightList) {
+ Course course = courseInitializationWeight.getCourse();
for (int i = 0; i < course.getLectureSize(); i++) {
Lecture lecture = new Lecture();
lecture.setId((long) lectureId);
@@ -120,270 +138,62 @@
return lectureList;
}
-// private void scheduleLeader(List<PeriodScoring> periodScoringList, List<Room> roomList,
-// EvaluationHandler evaluationHandler, WorkingMemory workingMemory, double unscheduledScore,
-// List<ExamToHandle> examToHandleList, Exam leader, FactHandle leaderHandle) {
-// boolean perfectMatch = false;
-// double bestScore = Double.NEGATIVE_INFINITY;
-// Period bestPeriod = null;
-// Room bestRoom = null;
-// for (PeriodScoring periodScoring : periodScoringList) {
-// if (bestScore >= periodScoring.getScore()) {
-// // No need to check the rest
-// break;
-// }
-// for (ExamToHandle examToHandle : examToHandleList) {
-// workingMemory.modifyRetract(examToHandle.getExamHandle());
-// examToHandle.getExam().setPeriod(periodScoring.getPeriod());
-// workingMemory.modifyInsert(examToHandle.getExamHandle(), examToHandle.getExam());
-// }
-// for (Room room : roomList) {
-// workingMemory.modifyRetract(leaderHandle);
-// leader.setRoom(room);
-// workingMemory.modifyInsert(leaderHandle, leader);
-// double score = evaluationHandler.fireAllRulesAndCalculateStepScore();
-// if (score < unscheduledScore) {
-// if (score > bestScore) {
-// bestScore = score;
-// bestPeriod = periodScoring.getPeriod();
-// bestRoom = room;
-// }
-// } else if (score == unscheduledScore) {
-// perfectMatch = true;
-// break;
-// } else {
-// throw new IllegalStateException("The score (" + score
-// + ") cannot be higher than unscheduledScore (" + unscheduledScore + ").");
-// }
-// }
-// if (perfectMatch) {
-// break;
-// }
-// }
-// if (!perfectMatch) {
-// if (bestPeriod == null || bestRoom == null) {
-// throw new IllegalStateException("The bestPeriod (" + bestPeriod + ") or the bestRoom ("
-// + bestRoom + ") cannot be null.");
-// }
-// workingMemory.modifyRetract(leaderHandle);
-// leader.setRoom(bestRoom);
-// workingMemory.modifyInsert(leaderHandle, leader);
-// for (ExamToHandle examToHandle : examToHandleList) {
-// workingMemory.modifyRetract(examToHandle.getExamHandle());
-// examToHandle.getExam().setPeriod(bestPeriod);
-// workingMemory.modifyInsert(examToHandle.getExamHandle(), examToHandle.getExam());
-// }
-// }
-// logger.debug(" Exam ({}) initialized for starting solution.", leader);
-// }
-//
-// private void scheduleNonLeader(List<Room> roomList,
-// EvaluationHandler evaluationHandler, WorkingMemory workingMemory,
-// Exam exam, FactHandle examHandle) {
-// if (exam.getRoom() != null) {
-// throw new IllegalStateException("Exam (" + exam + ") already has a room.");
-// }
-// double unscheduledScore = evaluationHandler.fireAllRulesAndCalculateStepScore();
-// boolean perfectMatch = false;
-// double bestScore = Double.NEGATIVE_INFINITY;
-// Room bestRoom = null;
-// for (Room room : roomList) {
-// workingMemory.modifyRetract(examHandle);
-// exam.setRoom(room);
-// workingMemory.modifyInsert(examHandle, exam);
-// double score = evaluationHandler.fireAllRulesAndCalculateStepScore();
-// if (score < unscheduledScore) {
-// if (score > bestScore) {
-// bestScore = score;
-// bestRoom = room;
-// }
-// } else if (score == unscheduledScore) {
-// perfectMatch = true;
-// break;
-// } else {
-// throw new IllegalStateException("The score (" + score
-// + ") cannot be higher than unscheduledScore (" + unscheduledScore + ").");
-// }
-// }
-// if (!perfectMatch) {
-// if (bestRoom == null) {
-// throw new IllegalStateException("The bestRoom ("
-// + bestRoom + ") cannot be null.");
-// }
-// workingMemory.modifyRetract(examHandle);
-// exam.setRoom(bestRoom);
-// workingMemory.modifyInsert(examHandle, exam);
-// }
-// logger.debug(" Exam ({}) initialized for starting solution. *", exam);
-// }
-//
-// public static class ExamToHandle {
-//
-// private Exam exam;
-// private FactHandle examHandle;
-//
-// public ExamToHandle(Exam exam) {
-// this.exam = exam;
-// }
-//
-// public Exam getExam() {
-// return exam;
-// }
-//
-// public FactHandle getExamHandle() {
-// return examHandle;
-// }
-//
-// public void setExamHandle(FactHandle examHandle) {
-// this.examHandle = examHandle;
-// }
-// }
-//
-// /**
-// * Create and order the exams in the order which we 'll assign them into periods and rooms.
-// * @param examination not null
-// * @return not null
-// */
-// private List<ExamInitialWeight> createExamAssigningScoreList(Examination examination) {
-// List<Exam> examList = createExamList(examination);
-// List<ExamInitialWeight> examInitialWeightList = new ArrayList<ExamInitialWeight>(examList.size());
-// for (Exam exam : examList) {
-// if (exam.isCoincidenceLeader()) {
-// examInitialWeightList.add(new ExamInitialWeight(exam));
-// }
-// }
-// Collections.sort(examInitialWeightList);
-// return examInitialWeightList;
-// }
-//
-// public List<Exam> createExamList(Examination examination) {
-// List<Topic> topicList = examination.getTopicList();
-// List<Exam> examList = new ArrayList<Exam>(topicList.size());
-// Map<Topic, Exam> topicToExamMap = new HashMap<Topic, Exam>(topicList.size());
-// for (Topic topic : topicList) {
-// Exam exam = new Exam();
-// exam.setId(topic.getId());
-// exam.setTopic(topic);
-// examList.add(exam);
-// topicToExamMap.put(topic, exam);
-// }
-// for (PeriodHardConstraint periodHardConstraint : examination.getPeriodHardConstraintList()) {
-// if (periodHardConstraint.getPeriodHardConstraintType() == PeriodHardConstraintType.EXAM_COINCIDENCE) {
-// Exam leftExam = topicToExamMap.get(periodHardConstraint.getLeftSideTopic());
-// Exam rightExam = topicToExamMap.get(periodHardConstraint.getRightSideTopic());
-//
-// Set<Exam> newCoincidenceExamSet = new LinkedHashSet<Exam>(4);
-// ExamCoincidence leftExamCoincidence = leftExam.getExamCoincidence();
-// if (leftExamCoincidence != null) {
-// newCoincidenceExamSet.addAll(leftExamCoincidence.getCoincidenceExamSet());
-// } else {
-// newCoincidenceExamSet.add(leftExam);
-// }
-// ExamCoincidence rightExamCoincidence = rightExam.getExamCoincidence();
-// if (rightExamCoincidence != null) {
-// newCoincidenceExamSet.addAll(rightExamCoincidence.getCoincidenceExamSet());
-// } else {
-// newCoincidenceExamSet.add(rightExam);
-// }
-// ExamCoincidence newExamCoincidence = new ExamCoincidence(newCoincidenceExamSet);
-// for (Exam exam : newCoincidenceExamSet) {
-// exam.setExamCoincidence(newExamCoincidence);
-// }
-// } else if (periodHardConstraint.getPeriodHardConstraintType() == PeriodHardConstraintType.AFTER) {
-// Exam afterExam = topicToExamMap.get(periodHardConstraint.getLeftSideTopic());
-// Exam beforeExam = topicToExamMap.get(periodHardConstraint.getRightSideTopic());
-// ExamBefore examBefore = beforeExam.getExamBefore();
-// if (examBefore == null) {
-// examBefore = new ExamBefore(new LinkedHashSet<Exam>(2));
-// beforeExam.setExamBefore(examBefore);
-// }
-// examBefore.getAfterExamSet().add(afterExam);
-// }
-// }
-// return examList;
-// }
-//
-// private class ExamInitialWeight implements Comparable<ExamInitialWeight> {
-//
-// private Exam exam;
-// private int totalStudentSize;
-// private int maximumDuration;
-//
-// private ExamInitialWeight(Exam exam) {
-// this.exam = exam;
-// totalStudentSize = calculateTotalStudentSize(exam);
-// maximumDuration = calculateMaximumDuration(exam);
-// }
-//
-// private int calculateTotalStudentSize(Exam innerExam) {
-// int innerTotalStudentSize = 0;
-// if (innerExam.getExamCoincidence() == null) {
-// innerTotalStudentSize = innerExam.getTopicStudentSize();
-// } else {
-// for (Exam coincidenceExam : innerExam.getExamCoincidence().getCoincidenceExamSet()) {
-// innerTotalStudentSize += coincidenceExam.getTopicStudentSize();
-// }
-// }
-// if (innerExam.getExamBefore() != null) {
-// for (Exam afterExam : innerExam.getExamBefore().getAfterExamSet()) {
-// innerTotalStudentSize += calculateTotalStudentSize(afterExam); // recursive
-// }
-// }
-// return innerTotalStudentSize;
-// }
-//
-// private int calculateMaximumDuration(Exam innerExam) {
-// int innerMaximumDuration = innerExam.getTopic().getDuration();
-// if (innerExam.getExamCoincidence() != null) {
-// for (Exam coincidenceExam : innerExam.getExamCoincidence().getCoincidenceExamSet()) {
-// innerMaximumDuration = Math.max(innerMaximumDuration, coincidenceExam.getTopicStudentSize());
-// }
-// }
-// if (innerExam.getExamBefore() != null) {
-// for (Exam afterExam : innerExam.getExamBefore().getAfterExamSet()) {
-// innerMaximumDuration = Math.max(innerMaximumDuration, calculateMaximumDuration(afterExam)); // recursive
-// }
-// }
-// return innerMaximumDuration;
-// }
-//
-// public Exam getExam() {
-// return exam;
-// }
-//
-// public int compareTo(ExamInitialWeight other) {
-// // TODO calculate a assigningScore based on the properties of a topic and sort on that assigningScore
-// return new CompareToBuilder()
-// .append(other.totalStudentSize, totalStudentSize) // Descending
-// .append(other.maximumDuration, maximumDuration) // Descending
-// .append(exam.getId(), other.exam.getId()) // Ascending
-// .toComparison();
-// }
-//
-// }
-//
-// private class PeriodScoring implements Comparable<PeriodScoring> {
-//
-// private Period period;
-// private double score;
-//
-// private PeriodScoring(Period period, double score) {
-// this.period = period;
-// this.score = score;
-// }
-//
-// public Period getPeriod() {
-// return period;
-// }
-//
-// public double getScore() {
-// return score;
-// }
-//
-// public int compareTo(PeriodScoring other) {
-// return -new CompareToBuilder().append(score, other.score).toComparison();
-// }
-//
-// }
+ private class CourseInitializationWeight implements Comparable<CourseInitializationWeight> {
+ private Course course;
+ private int unavailablePeriodConstraintCount;
+
+ private CourseInitializationWeight(CurriculumCourseSchedule schedule, Course course) {
+ this.course = course;
+ unavailablePeriodConstraintCount = 0;
+ // TODO this could be improved by iteration the unavailablePeriodConstraintList and using a hashmap
+ for (UnavailablePeriodConstraint constraint : schedule.getUnavailablePeriodConstraintList()) {
+ if (constraint.getCourse().equals(course)) {
+ unavailablePeriodConstraintCount++;
+ }
+ }
+ }
+
+ public Course getCourse() {
+ return course;
+ }
+
+ public int compareTo(CourseInitializationWeight other) {
+
+ return new CompareToBuilder()
+ .append(other.course.getCurriculumList().size(), course.getCurriculumList().size()) // Descending
+ .append(other.unavailablePeriodConstraintCount, unavailablePeriodConstraintCount) // Descending
+ .append(other.course.getLectureSize(), course.getLectureSize()) // Descending
+ .append(other.course.getStudentSize(), course.getStudentSize()) // Descending
+ .append(other.course.getMinWorkingDaySize(), course.getMinWorkingDaySize()) // Descending
+ .append(course.getId(), other.course.getId()) // Ascending
+ .toComparison();
+ }
+
+ }
+
+ private class PeriodScoring implements Comparable<PeriodScoring> {
+
+ private Period period;
+ private double score;
+
+ private PeriodScoring(Period period, double score) {
+ this.period = period;
+ this.score = score;
+ }
+
+ public Period getPeriod() {
+ return period;
+ }
+
+ public double getScore() {
+ return score;
+ }
+
+ public int compareTo(PeriodScoring other) {
+ return -new CompareToBuilder().append(score, other.score).toComparison();
+ }
+
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/examination/solver/solution/initializer/ExaminationStartingSolutionInitializer.java
===================================================================
--- labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/examination/solver/solution/initializer/ExaminationStartingSolutionInitializer.java 2008-03-23 12:59:11 UTC (rev 19216)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/java/org/drools/solver/examples/itc2007/examination/solver/solution/initializer/ExaminationStartingSolutionInitializer.java 2008-03-23 14:17:11 UTC (rev 19217)
@@ -45,13 +45,13 @@
EvaluationHandler evaluationHandler = solver.getEvaluationHandler();
List<Period> periodList = examination.getPeriodList();
List<Room> roomList = examination.getRoomList();
- List<Exam> examList = new ArrayList<Exam>(examination.getTopicList().size());
+ List<Exam> examList = new ArrayList<Exam>(examination.getTopicList().size()); // TODO this can be returned from createExamAssigningScoreList
evaluationHandler.setSolution(examination);
WorkingMemory workingMemory = evaluationHandler.getStatefulSession();
- List<ExamInitialWeight> examInitialWeightList = createExamAssigningScoreList(examination);
+ List<ExamInitializationWeight> examInitialWeightList = createExamAssigningScoreList(examination);
- for (ExamInitialWeight examInitialWeight : examInitialWeightList) {
+ for (ExamInitializationWeight examInitialWeight : examInitialWeightList) {
double unscheduledScore = evaluationHandler.fireAllRulesAndCalculateStepScore();
Exam leader = examInitialWeight.getExam();
FactHandle leaderHandle = null;
@@ -227,12 +227,12 @@
* @param examination not null
* @return not null
*/
- private List<ExamInitialWeight> createExamAssigningScoreList(Examination examination) {
+ private List<ExamInitializationWeight> createExamAssigningScoreList(Examination examination) {
List<Exam> examList = createExamList(examination);
- List<ExamInitialWeight> examInitialWeightList = new ArrayList<ExamInitialWeight>(examList.size());
+ List<ExamInitializationWeight> examInitialWeightList = new ArrayList<ExamInitializationWeight>(examList.size());
for (Exam exam : examList) {
if (exam.isCoincidenceLeader()) {
- examInitialWeightList.add(new ExamInitialWeight(exam));
+ examInitialWeightList.add(new ExamInitializationWeight(exam));
}
}
Collections.sort(examInitialWeightList);
@@ -286,13 +286,13 @@
return examList;
}
- private class ExamInitialWeight implements Comparable<ExamInitialWeight> {
+ private class ExamInitializationWeight implements Comparable<ExamInitializationWeight> {
private Exam exam;
private int totalStudentSize;
private int maximumDuration;
- private ExamInitialWeight(Exam exam) {
+ private ExamInitializationWeight(Exam exam) {
this.exam = exam;
totalStudentSize = calculateTotalStudentSize(exam);
maximumDuration = calculateMaximumDuration(exam);
@@ -334,7 +334,7 @@
return exam;
}
- public int compareTo(ExamInitialWeight other) {
+ public int compareTo(ExamInitializationWeight other) {
// TODO calculate a assigningScore based on the properties of a topic and sort on that assigningScore
return new CompareToBuilder()
.append(other.totalStudentSize, totalStudentSize) // Descending
Modified: labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseScoreRules.drl
===================================================================
--- labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseScoreRules.drl 2008-03-23 12:59:11 UTC (rev 19216)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseScoreRules.drl 2008-03-23 14:17:11 UTC (rev 19217)
@@ -117,6 +117,8 @@
causes contains $course,
eval(weight != (($minWorkingDaySize - $dayCount.intValue()) * 5))
);
+ // An uninitialized schedule should have no constraints broken
+ exists Lecture(course == $course);
then
insertLogical(new IntConstraintOccurrence("minimumWorkingDays", ConstraintType.NEGATIVE_SOFT,
(($minWorkingDaySize - $dayCount.intValue()) * 5),
Modified: labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseSolverConfig.xml
===================================================================
--- labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseSolverConfig.xml 2008-03-23 12:59:11 UTC (rev 19216)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-examples/src/main/resources/org/drools/solver/examples/itc2007/curriculumcourse/solver/curriculumCourseSolverConfig.xml 2008-03-23 14:17:11 UTC (rev 19217)
@@ -11,7 +11,7 @@
ge0ffrey's main pc: 429
ge0ffrey's old pc: 1152
-->
- <maximumSecondsSpend>30</maximumSecondsSpend>
+ <maximumSecondsSpend>1</maximumSecondsSpend>
<!--<feasableScore>-999999.0</feasableScore>-->
<!--<maximumStepCount>100</maximumStepCount>-->
</finish>
More information about the jboss-svn-commits
mailing list