Search in sources :

Example 1 with FixedAssignments

use of org.cpsolver.studentsct.constraint.FixedAssignments in project cpsolver by UniTime.

the class StudentSectioningXMLLoader method load.

public void load(Document document) {
    Element root = document.getRootElement();
    if (getModel() != null && root.element("travel-times") != null)
        loadTravelTimes(root.element("travel-times"), getModel().getDistanceMetric());
    Progress.getInstance(getModel()).load(root, true);
    Progress.getInstance(getModel()).message(Progress.MSGLEVEL_STAGE, "Restoring from backup ...");
    Map<Long, Offering> offeringTable = new HashMap<Long, Offering>();
    Map<Long, Course> courseTable = new HashMap<Long, Course>();
    if (root.element("offerings") != null) {
        loadOfferings(root.element("offerings"), offeringTable, courseTable, null);
    }
    List<Enrollment> bestEnrollments = new ArrayList<Enrollment>();
    List<Enrollment> currentEnrollments = new ArrayList<Enrollment>();
    if (root.element("students") != null) {
        loadStudents(root.element("students"), offeringTable, courseTable, bestEnrollments, currentEnrollments);
    }
    if (root.element("constraints") != null)
        loadLinkedSections(root.element("constraints"), offeringTable);
    if (!bestEnrollments.isEmpty())
        assignBest(bestEnrollments);
    if (!currentEnrollments.isEmpty())
        assignCurrent(currentEnrollments);
    if (iMoveCriticalUp)
        moveCriticalRequestsUp();
    boolean hasFixed = false;
    for (Request r : getModel().variables()) {
        if (r instanceof CourseRequest && ((CourseRequest) r).isFixed()) {
            hasFixed = true;
            break;
        }
    }
    if (hasFixed)
        getModel().addGlobalConstraint(new FixedAssignments());
}
Also used : HashMap(java.util.HashMap) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Request(org.cpsolver.studentsct.model.Request) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) FreeTimeRequest(org.cpsolver.studentsct.model.FreeTimeRequest) Offering(org.cpsolver.studentsct.model.Offering) FixedAssignments(org.cpsolver.studentsct.constraint.FixedAssignments) CourseRequest(org.cpsolver.studentsct.model.CourseRequest) Enrollment(org.cpsolver.studentsct.model.Enrollment) Course(org.cpsolver.studentsct.model.Course)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 FixedAssignments (org.cpsolver.studentsct.constraint.FixedAssignments)1 Course (org.cpsolver.studentsct.model.Course)1 CourseRequest (org.cpsolver.studentsct.model.CourseRequest)1 Enrollment (org.cpsolver.studentsct.model.Enrollment)1 FreeTimeRequest (org.cpsolver.studentsct.model.FreeTimeRequest)1 Offering (org.cpsolver.studentsct.model.Offering)1 Request (org.cpsolver.studentsct.model.Request)1 Element (org.dom4j.Element)1