org.cpsolver.studentsct

## Class StudentSectioningXMLLoader

- java.lang.Object
- - org.cpsolver.ifs.util.ProblemLoader<Request,Enrollment,StudentSectioningModel>
  - - org.cpsolver.studentsct.StudentSectioningLoader
    - - org.cpsolver.studentsct.StudentSectioningXMLLoader

- All Implemented Interfaces:
    Runnable

      public class StudentSectioningXMLLoader
      extends StudentSectioningLoader

  Load student sectioning model from an XML file.
  Parameters:

  Parameter | Type | Comment
  --- | --- | ---
  General.Input | `String` | Path of an XML file to be loaded
  Xml.LoadBest | `Boolean` | If true, load best assignments
  Xml.LoadInitial | `Boolean` | If false, load initial assignments
  Xml.LoadCurrent | `Boolean` | If true, load current assignments
  Xml.LoadOfferings | `Boolean` | If true, load offerings (and their stucture, i.e., courses, configurations, subparts and sections)
  Xml.LoadStudents | `Boolean` | If true, load students (and their requests)
  Xml.StudentFilter | `StudentFilter` | If provided, students are filtered by the given student filter

  Usage:

       StudentSectioningModel model = new StudentSectioningModel(cfg);

       new StudentSectioningXMLLoader(model).load();

  Version:
    StudentSct 1.3 (Student Sectioning)
    Copyright (C) 2007 - 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StudentSectioningXMLLoader(StudentSectioningModel model, Assignment<Request,Enrollment> assignment)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `assignBest(List<Enrollment> bestEnrollments)` Save best enrollments
    `protected void` | `assignCurrent(List<Enrollment> currentEnrollments)` Assign current enrollments
    `void` | `load()` Load the file
    `void` | `load(Document document)`
    `protected void` | `load(Element root)` Load data from the given XML root
    `protected Config` | `loadConfig(Element configEl, Offering offering, Map<Long,Subpart> subpartTable, Map<Long,Section> sectionTable, Map<Long,Placement> timetable)` Load config
    `protected Course` | `loadCourse(Element courseEl, Offering offering)` Load course
    `CourseRequest` | `loadCourseRequest(Element requestEl, Student student, Map<Long,Offering> offeringTable, Map<Long,Course> courseTable)` Load course request
    `protected Enrollment` | `loadEnrollment(Element enrollmentEl, Request request)` Load enrollment
    `FreeTimeRequest` | `loadFreeTime(Element requestEl, Student student)` Load free time request
    `protected void` | `loadLinkedSections(Element constraintsEl, Map<Long,Offering> offeringTable)` Load linked sections
    `protected void` | `loadOfferings(Element offeringsEl, Map<Long,Offering> offeringTable, Map<Long,Course> courseTable, Map<Long,Placement> timetable)` Load offerings
    `protected Request` | `loadRequest(Element requestEl, Student student, Map<Long,Offering> offeringTable, Map<Long,Course> courseTable)` Load request
    `protected Reservation` | `loadReservation(Element reservationEl, Offering offering, HashMap<Long,Config> configTable, HashMap<Long,Section> sectionTable)` Load reservation
    `protected Restriction` | `loadRestriction(Element restrictionEl, Offering offering, HashMap<Long,Config> configTable, HashMap<Long,Section> sectionTable)` Load restriction
    `protected Section` | `loadSection(Element sectionEl, Subpart subpart, Map<Long,Section> sectionTable, Map<Long,Placement> timetable)` Load section
    `protected Student` | `loadStudent(Element studentEl, Map<Long,Offering> offeringTable)` Load student
    `protected void` | `loadStudents(Element studentsEl, Map<Long,Offering> offeringTable, Map<Long,Course> courseTable, List<Enrollment> bestEnrollments, List<Enrollment> currentEnrollments)` Load students
    `protected Subpart` | `loadSubpart(Element subpartEl, Config config, Map<Long,Subpart> subpartTable, Map<Long,Section> sectionTable, Map<Long,Placement> timetable)` Load subpart
    `protected Map<Long,Placement>` | `loadTimetable(Element timetableRoot)` Load given timetable
    `protected void` | `loadTravelTimes(Element travelTimesEl, DistanceMetric metric)` Load travel times
    `protected void` | `moveCriticalRequestsUp()`
    `void` | `setInputFile(File inputFile)` Set input file (e.g., if it is not set by General.Input property)
    `void` | `setLoadOfferings(boolean loadOfferings)` Set whether to load offerings
    `void` | `setLoadStudents(boolean loadStudents)` Set whether to load students
    `void` | `setStudentFilter(StudentFilter filter)` Set student filter

    - ### Methods inherited from class org.cpsolver.ifs.util.ProblemLoader

      `getAssignment, getModel, getTerminationCondition, run, setCallback, setTerminationCondition`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StudentSectioningXMLLoader

          public StudentSectioningXMLLoader(StudentSectioningModel model,
                                            Assignment<Request,Enrollment> assignment)

      Constructor
      Parameters:
        `model` - student sectioning model
        `assignment` - current assignment

  - ### Method Detail

    - #### setInputFile

          public void setInputFile(File inputFile)

      Set input file (e.g., if it is not set by General.Input property)
      Parameters:
        `inputFile` - input file

    - #### setStudentFilter

          public void setStudentFilter(StudentFilter filter)

      Set student filter
      Parameters:
        `filter` - student filter

    - #### setLoadStudents

          public void setLoadStudents(boolean loadStudents)

      Set whether to load students
      Parameters:
        `loadStudents` - true if students are to be loaded

    - #### setLoadOfferings

          public void setLoadOfferings(boolean loadOfferings)

      Set whether to load offerings
      Parameters:
        `loadOfferings` - true if instructional offerings are to be loaded

    - #### load

          public void load()
                    throws Exception

      Load the file
      Specified by:
        `load` in class `ProblemLoader<Request,Enrollment,StudentSectioningModel>`
      Throws:
        `Exception` - thrown when the load fails

    - #### load

          public void load(Document document)

    - #### load

          protected void load(Element root)
                       throws DocumentException

      Load data from the given XML root
      Parameters:
        `root` - document root
      Throws:
        `DocumentException`

    - #### loadOfferings

          protected void loadOfferings(Element offeringsEl,
                                       Map<Long,Offering> offeringTable,
                                       Map<Long,Course> courseTable,
                                       Map<Long,Placement> timetable)

      Load offerings
      Parameters:
        `offeringsEl` - offerings element
        `offeringTable` - offering table
        `courseTable` - course table
        `timetable` - provided timetable (null if to be loaded from the given document)

    - #### loadCourse

          protected Course loadCourse(Element courseEl,
                                      Offering offering)

      Load course
      Parameters:
        `courseEl` - course element
        `offering` - parent offering
      Returns:
        loaded course

    - #### loadConfig

          protected Config loadConfig(Element configEl,
                                      Offering offering,
                                      Map<Long,Subpart> subpartTable,
                                      Map<Long,Section> sectionTable,
                                      Map<Long,Placement> timetable)

      Load config
      Parameters:
        `configEl` - config element
        `offering` - parent offering
        `subpartTable` - subpart table (of the offering)
        `sectionTable` - section table (of the offering)
        `timetable` - provided timetable
      Returns:
        loaded config

    - #### loadSubpart

          protected Subpart loadSubpart(Element subpartEl,
                                        Config config,
                                        Map<Long,Subpart> subpartTable,
                                        Map<Long,Section> sectionTable,
                                        Map<Long,Placement> timetable)

      Load subpart
      Parameters:
        `subpartEl` - supart element
        `config` - parent config
        `subpartTable` - subpart table (of the offering)
        `sectionTable` - section table (of the offering)
        `timetable` - provided timetable
      Returns:
        loaded subpart

    - #### loadSection

          protected Section loadSection(Element sectionEl,
                                        Subpart subpart,
                                        Map<Long,Section> sectionTable,
                                        Map<Long,Placement> timetable)

      Load section
      Parameters:
        `sectionEl` - section element
        `subpart` - parent subpart
        `sectionTable` - section table (of the offering)
        `timetable` - provided timetable
      Returns:
        loaded section

    - #### loadReservation

          protected Reservation loadReservation(Element reservationEl,
                                                Offering offering,
                                                HashMap<Long,Config> configTable,
                                                HashMap<Long,Section> sectionTable)

      Load reservation
      Parameters:
        `reservationEl` - reservation element
        `offering` - parent offering
        `configTable` - config table (of the offering)
        `sectionTable` - section table (of the offering)
      Returns:
        loaded reservation

    - #### loadRestriction

          protected Restriction loadRestriction(Element restrictionEl,
                                                Offering offering,
                                                HashMap<Long,Config> configTable,
                                                HashMap<Long,Section> sectionTable)

      Load restriction
      Parameters:
        `restrictionEl` - restriction element
        `offering` - parent offering
        `configTable` - config table (of the offering)
        `sectionTable` - section table (of the offering)
      Returns:
        loaded restriction

    - #### loadTimetable

          protected Map<Long,Placement> loadTimetable(Element timetableRoot)

      Load given timetable
      Parameters:
        `timetableRoot` - document root in the course timetabling XML format
      Returns:
        loaded timetable (map class id: assigned placement)

    - #### loadTravelTimes

          protected void loadTravelTimes(Element travelTimesEl,
                                         DistanceMetric metric)

      Load travel times
      Parameters:
        `travelTimesEl` - travel-time element
        `metric` - distance metric to be populated

    - #### loadLinkedSections

          protected void loadLinkedSections(Element constraintsEl,
                                            Map<Long,Offering> offeringTable)

      Load linked sections
      Parameters:
        `constraintsEl` - constraints element
        `offeringTable` - offering table

    - #### loadStudents

          protected void loadStudents(Element studentsEl,
                                      Map<Long,Offering> offeringTable,
                                      Map<Long,Course> courseTable,
                                      List<Enrollment> bestEnrollments,
                                      List<Enrollment> currentEnrollments)

      Load students
      Parameters:
        `studentsEl` - students element
        `offeringTable` - offering table
        `courseTable` - course table

    - #### assignBest

          protected void assignBest(List<Enrollment> bestEnrollments)

      Save best enrollments
      Parameters:
        `bestEnrollments` - best enrollments

    - #### assignCurrent

          protected void assignCurrent(List<Enrollment> currentEnrollments)

      Assign current enrollments
      Parameters:
        `currentEnrollments` - current enrollments

    - #### loadStudent

          protected Student loadStudent(Element studentEl,
                                        Map<Long,Offering> offeringTable)

      Load student
      Parameters:
        `studentEl` - student element
        `offeringTable` - offering table
      Returns:
        loaded student

    - #### loadRequest

          protected Request loadRequest(Element requestEl,
                                        Student student,
                                        Map<Long,Offering> offeringTable,
                                        Map<Long,Course> courseTable)

      Load request
      Parameters:
        `requestEl` - request element
        `student` - parent student
        `offeringTable` - offering table
        `courseTable` - course table
      Returns:
        loaded request

    - #### loadFreeTime

          public FreeTimeRequest loadFreeTime(Element requestEl,
                                              Student student)

      Load free time request
      Parameters:
        `requestEl` - request element
        `student` - parent student
      Returns:
        loaded free time request

    - #### loadCourseRequest

          public CourseRequest loadCourseRequest(Element requestEl,
                                                 Student student,
                                                 Map<Long,Offering> offeringTable,
                                                 Map<Long,Course> courseTable)

      Load course request
      Parameters:
        `requestEl` - request element
        `student` - parent student
        `offeringTable` - offering table
        `courseTable` - course table
      Returns:
        loaded course request

    - #### loadEnrollment

          protected Enrollment loadEnrollment(Element enrollmentEl,
                                              Request request)

      Load enrollment
      Parameters:
        `enrollmentEl` - enrollment element (current, best, or initial)
        `request` - parent request
      Returns:
        loaded enrollment

    - #### moveCriticalRequestsUp

          protected void moveCriticalRequestsUp()