Skip to content

Commit f0eaf10

Browse files
committed
allow some negative values, also increase penalty
1 parent b373597 commit f0eaf10

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

src/MaxWeightMatching/Matcher.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static void match(Data dat, Weighting waiter) {
3737
for (int r = 0; r < 2; r++) {
3838
assign();
3939
}
40+
4041
// one more time to make sure all tutors have enough slots
4142
// this will allow some slots to have more than one person
4243
// however now all slots can be used
@@ -82,7 +83,7 @@ private static void assign() {
8283
int j = perm2[k];
8384
// ignore used slots and any slots a tutor can not make
8485
double r = w.weight(t[i], s[j]);
85-
if (!used[j] && !t[i].conflict(s[j]) && r > 0)
86+
if (!used[j] && !t[i].conflict(s[j]) && r > -10)
8687
updateMatching(i, j + t.length, r);
8788
// note that this case naturally doesn't let us assign 2
8889
// of the same slot to one tutor.

src/Schedule/Schedule.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,16 @@ public static void main(String[] args) {
116116
}
117117

118118
double s = 0;
119-
{
120-
String assign = dat.readableFormattedAssignments();
121-
double[] r = Evaluator.evaluate (dat, w, false);
122-
double stdmin = r[0], maxhap = r[1];
123-
s = r[1];
124-
System.out.println(assign);
125-
System.out.println(stdmin + " " + maxhap);
126-
}
119+
do {
120+
dat.clearAssignments();
121+
Matcher.match(dat, w);
122+
String assign = dat.readableFormattedAssignments();
123+
double[] r = Evaluator.evaluate (dat, w, false);
124+
double stdmin = r[0], maxhap = r[1];
125+
s = r[1];
126+
// System.out.println(assign);
127+
System.out.println(stdmin + " " + maxhap);
128+
} while (s < 0);
127129

128130
System.out.println("Swapping");
129131
// now do some random swapping to make it stable

src/Weighting/Evaluator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import Items.Tutor;
1212

1313
public class Evaluator {
14-
public static final double PENALTY = 1000000;
14+
public static final double PENALTY = 10000000;
1515
public static final double ADJACENT_PREF = 50;
1616
public static final double ADJACENT_DISPREF = 50;
1717

test/sp14_1.json

-1
This file was deleted.

test/t6.json

-1
This file was deleted.

0 commit comments

Comments
 (0)