use of org.cpsolver.coursett.sectioning.SctModel.SctSolution in project cpsolver by UniTime.
the class SctSectioning method switchStudents.
@Override
public void switchStudents(Solution<Lecture, Placement> solution, TerminationCondition<Lecture, Placement> termination) {
getProgress().setStatus("Student Sectioning...");
getProgress().info("Student Conflicts: " + sDF2.format(value(solution)) + " (group: " + sDF2.format(StudentSwapSectioning.gp(solution)) + "%)");
for (int i = 1; i <= iNrRounds; i++) {
getProgress().setPhase("Swapping students [" + i + "]...", iModel.variables().size());
Set<Long> offeringIds = new HashSet<Long>();
for (Lecture lecture : iModel.variables()) {
getProgress().incProgress();
if (lecture.students().isEmpty() || lecture.isSingleSection())
continue;
if (termination != null && !termination.canContinue(solution))
return;
if (offeringIds.add(lecture.getConfiguration().getOfferingId())) {
SctModel model = new SctModel(iModel, solution.getAssignment());
model.setConfiguration(lecture.getConfiguration());
SctSolution s1 = model.currentSolution();
SctSolution s2 = model.computeSolution();
if (model.isTimeOutReached())
getProgress().info("Timeout reached for " + lecture.getName());
if (s2.isBetter(s1)) {
model.unassign();
model.assign(s2);
getProgress().info("Student Conflicts: " + sDF2.format(value(solution)) + " (group: " + sDF2.format(StudentSwapSectioning.gp(solution)) + "%)");
}
}
}
getProgress().info("Student Conflicts: " + sDF2.format(value(solution)) + " (group: " + sDF2.format(StudentSwapSectioning.gp(solution)) + "%)");
}
}
use of org.cpsolver.coursett.sectioning.SctModel.SctSolution in project cpsolver by UniTime.
the class SctSectioning method resection.
@Override
public void resection(Assignment<Lecture, Placement> assignment, Lecture lecture, boolean recursive, boolean configAsWell) {
SctModel model = new SctModel(iModel, assignment);
model.setConfiguration(lecture.getConfiguration());
SctSolution s1 = model.currentSolution();
SctSolution s2 = model.computeSolution();
if (s2.isBetter(s1)) {
model.unassign();
model.assign(s2);
}
}
Aggregations