Moved the availability comparison to the class Pair. Tests should be written for this...

This commit is contained in:
Tom Vahlman 2012-02-27 21:57:27 +01:00
parent 604a38152c
commit 91f9a4584b
2 changed files with 23 additions and 27 deletions
src/main/java/se/su/dsv/scipro/match

@ -263,7 +263,7 @@ public class GreedyMatchingAlgorithm implements MatchingAlgorithm {
*/
@Override
public int compareTo(Pair otherPair) {
if(match.getPoints() > otherPair.getMatch().getPoints()) {
if(match.getPoints() > otherPair.getMatch().getPoints()) { // points is the most important criteria
return -1;
} else if(otherPair.getMatch().getPoints() > match.getPoints()) {
return 1;
@ -272,20 +272,27 @@ public class GreedyMatchingAlgorithm implements MatchingAlgorithm {
return -1;
} else if(otherPair.getTotalAvailability() > totalAvailability) {
return 1;
} else { // the points and the slots are equal, we must now sort on Project Class because a master supervisor can supervise
// both a master project idea and a bachelor project idea, the "best" match however is if a master supervisor supervises a master project idea...
if(match.getProjectIdea().getProjectClass().equals(availability.getProjectClass()) &&
!otherPair.getMatch().getProjectIdea().getProjectClass().equals(otherPair.getAvailability().getProjectClass())) {
return -1;
} else if(!match.getProjectIdea().getProjectClass().equals(availability.getProjectClass()) &&
otherPair.getMatch().getProjectIdea().getProjectClass().equals(otherPair.getAvailability().getProjectClass())) {
return 1;
} else { // the project class is the same sort on the highest availability
return availability.compareTo(otherPair.getAvailability());
} else {
// we must now sort on Project Class because a master supervisor can supervise both a master project idea and
// a bachelor project idea, however the "best" match is if a "master supervisor" handles a "master project idea"...
if(match.getProjectIdea().getProjectClass().equals(availability.getProjectClass()) &&
!otherPair.getMatch().getProjectIdea().getProjectClass().equals(otherPair.getAvailability().getProjectClass())) {
return -1;
} else if(!match.getProjectIdea().getProjectClass().equals(availability.getProjectClass()) &&
otherPair.getMatch().getProjectIdea().getProjectClass().equals(otherPair.getAvailability().getProjectClass())) {
return 1;
} else {
// the most suited supervisor is now the one that has highest slots for the specific project class
if(availability.getAvailability() > otherPair.getAvailability().getAvailability()) {
return -1;
} else if(otherPair.getAvailability().getAvailability() > availability.getAvailability()) {
return 1;
} else { // the project classes is the same
return 0;
}
}
}
}
}
}
}
}
}

@ -8,7 +8,7 @@ import se.su.dsv.scipro.data.dataobjects.ProjectClass;
/**
* A class that specifies how available a supervisor is(in terms of thesis supervision)
*/
public class Availability implements Serializable, Comparable<Availability> {
public class Availability implements Serializable {
private static final long serialVersionUID = 1L;
@ -53,18 +53,7 @@ public class Availability implements Serializable, Comparable<Availability> {
public void setNumMatched(Long num) {
numMatched = num;
}
@Override
public int compareTo(Availability availability) {
if(getAvailability() > availability.getAvailability()) {
return -1;
} else if(availability.getAvailability() > getAvailability()) {
return 1;
} else {
return 0;
}
}
@Override
public String toString() {
return "Availability [supervisorId=" + supervisor + ", numMatched="