use of org.cpsolver.studentsct.StudentSectioningModel in project cpsolver by UniTime.
the class EnrollmentSelection method isAllowed.
/** true, if it is allowed to assign given value
* @param assignment current assignment
* @param value given value
* @param conflicts conflicting assignments
* @return true if it is allowed
**/
public boolean isAllowed(Assignment<Request, Enrollment> assignment, Enrollment value, Set<Enrollment> conflicts) {
if (value == null)
return true;
StudentSectioningModel model = (StudentSectioningModel) value.variable().getModel();
if (model.getNrLastLikeRequests(false) == 0 || model.getNrRealRequests(false) == 0)
return true;
Request request = value.variable();
if (request.getStudent().isDummy()) {
if (conflicts == null)
conflicts = value.variable().getModel().conflictValues(assignment, value);
for (Enrollment conflict : conflicts) {
if (!conflict.getRequest().getStudent().isDummy())
return false;
}
} else {
if (conflicts == null)
conflicts = value.variable().getModel().conflictValues(assignment, value);
if (conflicts.size() > (assignment.getValue(request) == null ? 1 : 0))
return false;
}
return true;
}
use of org.cpsolver.studentsct.StudentSectioningModel in project cpsolver by UniTime.
the class PriorityConstructionSelection method nextCycle.
/** Increment cycle
* @param solution current solution
**/
protected void nextCycle(Solution<Request, Enrollment> solution) {
iCycle++;
iImproved = false;
sLog.debug("Assigning up to " + iCycle + " requests...");
StudentSectioningModel m = (StudentSectioningModel) solution.getModel();
double tv = m.getTotalValue(solution.getAssignment(), true);
sLog.debug("**CURR** " + solution.getModel().toString() + ", TM:" + sDF.format(solution.getTime() / 3600.0) + "h, " + "TV:" + sDF.format(-tv) + " (" + sDF.format(-100.0 * tv / m.getStudents().size()) + "%)");
iStudentsEnumeration = iStudents.iterator();
Progress.getInstance(solution.getModel()).setPhase("Construction[" + iCycle + "]...", iStudents.size());
}
Aggregations