Search in sources :

Example 1 with SctSolution

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)) + "%)");
    }
}
Also used : Lecture(org.cpsolver.coursett.model.Lecture) SctSolution(org.cpsolver.coursett.sectioning.SctModel.SctSolution) JenrlConstraint(org.cpsolver.coursett.constraint.JenrlConstraint) HashSet(java.util.HashSet)

Example 2 with SctSolution

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);
    }
}
Also used : SctSolution(org.cpsolver.coursett.sectioning.SctModel.SctSolution)

Aggregations

SctSolution (org.cpsolver.coursett.sectioning.SctModel.SctSolution)2 HashSet (java.util.HashSet)1 JenrlConstraint (org.cpsolver.coursett.constraint.JenrlConstraint)1 Lecture (org.cpsolver.coursett.model.Lecture)1