From ef532561da3b0a0ffdff52514f44fb33d7868b98 Mon Sep 17 00:00:00 2001 From: tomas-muller Date: Wed, 30 Oct 2019 20:24:52 +0100 Subject: [PATCH] Online Student Scheduling: Suggestions - consider order of the courses within a course request when comparing two suggestions --- .../online/selection/SuggestionsBranchAndBound.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/org/cpsolver/studentsct/online/selection/SuggestionsBranchAndBound.java b/src/org/cpsolver/studentsct/online/selection/SuggestionsBranchAndBound.java index 5594cf37..719826c9 100644 --- a/src/org/cpsolver/studentsct/online/selection/SuggestionsBranchAndBound.java +++ b/src/org/cpsolver/studentsct/online/selection/SuggestionsBranchAndBound.java @@ -597,6 +597,7 @@ public class Suggestion implements Comparable { private Section iSelectedEnrollment = null; private boolean iSelectedEnrollmentChangeTime = false; private TreeSet
iSelectedSections = new TreeSet
(new EnrollmentSectionComparator()); + private int iSelectedChoice = 0; /** * Create suggestion @@ -657,8 +658,10 @@ public Suggestion(ArrayList resolvedRequests) { if (iSelectedRequest != null) { Enrollment enrollment = iAssignment.getValue(iSelectedRequest); if (enrollment.isCourseRequest() && enrollment.getAssignments() != null - && !enrollment.getAssignments().isEmpty()) + && !enrollment.getAssignments().isEmpty()) { iSelectedSections.addAll(enrollment.getSections()); + iSelectedChoice = ((CourseRequest)iSelectedRequest).getCourses().indexOf(enrollment.getCourse()); + } } } @@ -773,6 +776,10 @@ public int compareTo(Suggestion suggestion) { cmp = Double.compare(getNrChanges(), suggestion.getNrChanges()); if (cmp != 0) return cmp; + + cmp = Double.compare(iSelectedChoice, suggestion.iSelectedChoice); + if (cmp != 0) + return cmp; Iterator
i1 = iSelectedSections.iterator(); Iterator
i2 = suggestion.iSelectedSections.iterator();