Skip to content

Commit

Permalink
Online Student Scheduling: Multi-criteria Selection Criteria
Browse files Browse the repository at this point in the history
- when comparing past sections, use percentage of past sections instead of their number
- this is to avoid preference for configurations with fewer subparts (e.g., when everything is in the past)
  • Loading branch information
tomas-muller committed Oct 7, 2022
1 parent 1a67856 commit 2eb08ed
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,25 +236,27 @@ public int compare(Assignment<Request, Enrollment> assignment, Enrollment[] curr
return 1;

// 3.95 avoid past sections
int bestPast = 0, currentPast = 0;
double bestPast = 0.0, currentPast = 0.0;
for (int idx = 0; idx < current.length; idx++) {
if (best[idx] != null && best[idx].getAssignments() != null) {
for (Section section : best[idx].getSections()) {
if (section.isPast())
bestPast++;
bestPast += 1.0 / best[idx].getSections().size();
}
}
if (current[idx] != null && current[idx].getAssignments() != null) {
for (Section section : current[idx].getSections()) {
if (section.isPast())
currentPast++;
currentPast += 1.0 / current[idx].getSections().size();
}
}
}
if (currentPast < bestPast)
return -1;
if (bestPast < currentPast)
return 1;
if (Math.abs(currentPast - bestPast) > 0.0001) {
if (currentPast < bestPast)
return -1;
if (bestPast < currentPast)
return 1;
}

// 4-5. student quality
if (getModel().getStudentQuality() != null) {
Expand Down Expand Up @@ -652,25 +654,27 @@ public boolean canImprove(Assignment<Request, Enrollment> assignment, int maxIdx
return false;

// 3.95 avoid past sections
int bestPast = 0, currentPast = 0;
double bestPast = 0.0, currentPast = 0.0;
for (int idx = 0; idx < current.length; idx++) {
if (best[idx] != null && best[idx].getAssignments() != null) {
for (Section section : best[idx].getSections()) {
if (section.isPast())
bestPast++;
bestPast += 1.0 / best[idx].getSections().size();
}
}
if (current[idx] != null && idx < maxIdx && current[idx].getAssignments() != null) {
for (Section section : current[idx].getSections()) {
if (section.isPast())
currentPast++;
currentPast += 1.0 / current[idx].getSections().size();
}
}
}
if (currentPast < bestPast)
return true;
if (bestPast < currentPast)
return false;
if (Math.abs(currentPast - bestPast) > 0.0001) {
if (currentPast < bestPast)
return true;
if (bestPast < currentPast)
return false;
}

// 4-5. solution quality
if (getModel().getStudentQuality() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,25 +396,27 @@ public int compare(Assignment<Request, Enrollment> assignment, Enrollment[] curr
}

// 3.95 avoid past sections
int bestPast = 0, currentPast = 0;
double bestPast = 0.0, currentPast = 0.0;
for (int idx = 0; idx < current.length; idx++) {
if (best[idx] != null && best[idx].getAssignments() != null) {
for (Section section : best[idx].getSections()) {
if (section.isPast())
bestPast++;
bestPast += 1.0 / best[idx].getSections().size();
}
}
if (current[idx] != null && current[idx].getAssignments() != null) {
for (Section section : current[idx].getSections()) {
if (section.isPast())
currentPast++;
currentPast += 1.0 / current[idx].getSections().size();
}
}
}
if (currentPast < bestPast)
return -1;
if (bestPast < currentPast)
return 1;
if (Math.abs(currentPast - bestPast) > 0.0001) {
if (currentPast < bestPast)
return -1;
if (bestPast < currentPast)
return 1;
}

// 4-5. student quality
if (getModel().getStudentQuality() != null) {
Expand Down Expand Up @@ -839,25 +841,27 @@ public boolean canImprove(Assignment<Request, Enrollment> assignment, int maxIdx
}

// 3.95 avoid past sections
int bestPast = 0, currentPast = 0;
double bestPast = 0.0, currentPast = 0.0;
for (int idx = 0; idx < current.length; idx++) {
if (best[idx] != null && best[idx].getAssignments() != null) {
for (Section section : best[idx].getSections()) {
if (section.isPast())
bestPast++;
bestPast += 1.0 / best[idx].getSections().size();
}
}
if (current[idx] != null && idx < maxIdx && current[idx].getAssignments() != null) {
for (Section section : current[idx].getSections()) {
if (section.isPast())
currentPast++;
currentPast += 1.0 / current[idx].getSections().size();
}
}
}
if (currentPast < bestPast)
return true;
if (bestPast < currentPast)
return false;
if (Math.abs(currentPast - bestPast) > 0.0001) {
if (currentPast < bestPast)
return true;
if (bestPast < currentPast)
return false;
}

// 4-5. student quality
if (getModel().getStudentQuality() != null) {
Expand Down Expand Up @@ -1123,19 +1127,21 @@ public int compare(Assignment<Request, Enrollment> assignment, Enrollment e1, En
return 1;

// 3.95 avoid past sections
int w1 = 0, w2 = 0;
double w1 = 0, w2 = 0;
for (Section section : e1.getSections()) {
if (section.isPast())
w1++;
w1 += 1.0 / e1.getSections().size();
}
for (Section section : e2.getSections()) {
if (section.isPast())
w2++;
w2 += 1.0 / e2.getSections().size();
}
if (Math.abs(w1 - w2) > 0.0001) {
if (w1 < w2)
return -1;
if (w2 < w1)
return 1;
}
if (w1 < w2)
return -1;
if (w2 < w1)
return 1;

// 4. avoid time overlaps
if (getTimesToAvoid() == null) {
Expand Down

0 comments on commit 2eb08ed

Please sign in to comment.