use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.
the class BranchBoundSelection method selectNeighbour.
/**
* Select neighbour. All students are taken, one by one in a random order.
* For each student a branch & bound search is employed.
*/
@Override
public Neighbour<Request, Enrollment> selectNeighbour(Solution<Request, Enrollment> solution) {
Student student = null;
while ((student = nextStudent()) != null) {
Progress.getInstance(solution.getModel()).incProgress();
Neighbour<Request, Enrollment> neighbour = getSelection(solution.getAssignment(), student).select();
if (neighbour != null)
return neighbour;
}
return null;
}
use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.
the class OnlineSelection method setPenalties.
/**
* Set online sectioning penalties to all sections of all courses of the
* given student
*/
private static void setPenalties(Assignment<Request, Enrollment> assignment, Student student) {
for (Request request : student.getRequests()) {
if (!(request instanceof CourseRequest))
continue;
CourseRequest courseRequest = (CourseRequest) request;
for (Course course : courseRequest.getCourses()) {
for (Config config : course.getOffering().getConfigs()) {
for (Subpart subpart : config.getSubparts()) {
for (Section section : subpart.getSections()) {
section.setPenalty(section.getOnlineSectioningPenalty(assignment));
}
}
}
}
courseRequest.clearCache();
}
}
use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.
the class ResectionIncompleteStudentsSelection method selectNeighbour.
/**
* Select neighbour. All students with an incomplete and non-empty schedule
* are taken, one by one in a random order. For each student a branch &
* bound search is employed.
*/
@Override
public Neighbour<Request, Enrollment> selectNeighbour(Solution<Request, Enrollment> solution) {
Student student = null;
while ((student = nextStudent()) != null) {
Progress.getInstance(solution.getModel()).incProgress();
if (student.nrAssignedRequests(solution.getAssignment()) == 0 || student.isComplete(solution.getAssignment()))
continue;
Neighbour<Request, Enrollment> neighbour = getSelection(solution.getAssignment(), student).select();
if (neighbour != null)
return neighbour;
}
return null;
}
use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.
the class StudentConflict method computeConflicts.
/**
* A given enrollment is conflicting when the student is enrolled into
* another course / free time request that has an assignment that is
* overlapping with one or more assignments of the given section. See
* {@link Enrollment#isOverlapping(Enrollment)} for more details. All such
* overlapping enrollments are added into the provided set of conflicts.
*
* @param enrollment
* {@link Enrollment} that is being considered
* @param conflicts
* resultant list of conflicting enrollments
*/
@Override
public void computeConflicts(Assignment<Request, Enrollment> assignment, Enrollment enrollment, Set<Enrollment> conflicts) {
// enrollment -> conflict
for (Request request : variables()) {
if (request.equals(enrollment.getRequest()))
continue;
Enrollment e = assignment.getValue(request);
if (e == null)
continue;
if (enrollment.isOverlapping(e))
conflicts.add(e);
}
// schedule) -> unassignd a lowest priority request
if (!enrollment.getAssignments().isEmpty() && !enrollment.getStudent().canAssign(assignment, enrollment.getRequest())) {
Enrollment lowestPriorityEnrollment = null;
int lowestPriority = -1;
for (Request request : variables()) {
if (request.equals(enrollment.getRequest()))
continue;
Enrollment e = assignment.getValue(request);
if (e == null)
continue;
if (lowestPriority < request.getPriority()) {
lowestPriority = request.getPriority();
lowestPriorityEnrollment = e;
}
}
if (lowestPriorityEnrollment != null)
conflicts.add(lowestPriorityEnrollment);
}
}
use of org.cpsolver.studentsct.model.Request in project cpsolver by UniTime.
the class DistanceConflict method countTotalNrConflicts.
/**
* Compute the actual number of all distance conflicts. Should be equal to
* {@link DistanceConflict#getTotalNrConflicts(Assignment)}.
* @param assignment current assignment
* @return computed number of all distance conflicts
*/
public int countTotalNrConflicts(Assignment<Request, Enrollment> assignment) {
int total = 0;
for (Request r1 : getModel().variables()) {
if (assignment.getValue(r1) == null || !(r1 instanceof CourseRequest))
continue;
Enrollment e1 = assignment.getValue(r1);
total += nrConflicts(e1);
for (Request r2 : r1.getStudent().getRequests()) {
Enrollment e2 = assignment.getValue(r2);
if (e2 == null || r1.getId() >= r2.getId() || !(r2 instanceof CourseRequest))
continue;
total += nrConflicts(e1, e2);
}
}
return total;
}
Aggregations