org.cpsolver.studentsct

## Class StudentSectioningModel

- java.lang.Object
- - org.cpsolver.ifs.model.Model<V,T>
  - - org.cpsolver.ifs.assignment.context.ModelWithContext<Request,Enrollment,StudentSectioningModel.StudentSectioningModelContext>
    - - org.cpsolver.studentsct.StudentSectioningModel

- All Implemented Interfaces:
    CanHoldContext, CanInheritContext<Request,Enrollment,StudentSectioningModel.StudentSectioningModelContext>, HasAssignmentContext<Request,Enrollment,StudentSectioningModel.StudentSectioningModelContext>
  Direct Known Subclasses:
    OnlineSectioningModel

      public class StudentSectioningModel
      extends ModelWithContext<Request,Enrollment,StudentSectioningModel.StudentSectioningModelContext>
      implements CanInheritContext<Request,Enrollment,StudentSectioningModel.StudentSectioningModelContext>

  Student sectioning model.
  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/.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `StudentSectioningModel.StudentSectioningModelContext`

    - ### Nested classes/interfaces inherited from class org.cpsolver.ifs.assignment.context.ModelWithContext

      `ModelWithContext.ContextUpdateType`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double` | `iProjectedStudentWeight`
    `protected static DecimalFormat` | `sDecimalFormat`

    - ### Fields inherited from class org.cpsolver.ifs.model.Model

      `sDoubleFormat, sPercentageFormat, sTimeFormat`

    - ### Fields inherited from interface org.cpsolver.ifs.assignment.context.CanHoldContext

      `sMaxSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StudentSectioningModel(DataProperties properties)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addLinkedSections(boolean mustBeUsed, Collection<Section> sections)` Link sections using `LinkedSections`
    `void` | `addLinkedSections(boolean mustBeUsed, Section... sections)` Link sections using `LinkedSections`
    `void` | `addLinkedSections(Collection<Section> sections)` Deprecated.
    `void` | `addLinkedSections(Section... sections)` Deprecated.
    `void` | `addOffering(Offering offering)` Add an offering into the model
    `void` | `addStudent(Student student)` Add a student into the model
    `void` | `addVariable(Request request)` Adds a variable to the model
    `double` | `avg(double w1, double w2)` Quadratic average of two weights.
    `double` | `avgNrRequests()` Average number of requests per student (see `Student.getRequests()` )
    `double` | `avgUnassignPriority(Assignment<Request,Enrollment> assignment)` Average priority of unassigned requests (see `Request.getPriority()`)
    `void` | `clearOnlineSectioningInfos()` Empty online student sectioning infos for all sections (see `Section.getSpaceExpected()` and `Section.getSpaceHeld()`).
    `void` | `computeOnlineSectioningInfos(Assignment<Request,Enrollment> assignment)` Compute online student sectioning infos for all sections (see `Section.getSpaceExpected()` and `Section.getSpaceHeld()`).
    `StudentSectioningModel.StudentSectioningModelContext` | `createAssignmentContext(Assignment<Request,Enrollment> assignment)` Create a new assignment context for the given assignment.
    `InheritedAssignment<Request,Enrollment>` | `createInheritedAssignment(Solution<Request,Enrollment> solution, int index)` Create a new inherited assignment from the given solution
    `double` | `getBestAssignedCourseRequestWeight()`
    `DistanceConflict` | `getDistanceConflict()` Return distance conflict extension
    `DistanceMetric` | `getDistanceMetric()`
    `Map<String,String>` | `getExtendedInfo(Assignment<Request,Enrollment> assignment)` Model extended info.
    `Map<String,String>` | `getInfo(Assignment<Request,Enrollment> assignment)` Model info
    `boolean` | `getKeepInitialAssignments()` Return true if the inital assignments are to be kept unchanged
    `List<LinkedSections>` | `getLinkedSections()` List of linked sections
    `int` | `getMaxDomainSize()` Maximal domain size (i.e., number of enrollments of a course request), -1 if there is no limit.
    `int` | `getNbrStudents(Student.StudentPriority priority)`
    `int` | `getNrAssignedLastLikeRequests(Assignment<Request,Enrollment> assignment, boolean precise)` Number of requests from projected (`Student.isDummy()` equals true) students that are assigned.
    `int` | `getNrAssignedRealRequests(Assignment<Request,Enrollment> assignment, boolean precise)` Number of requests from real (`Student.isDummy()` equals false) students that are assigned.
    `int` | `getNrCompleteLastLikeStudents(Assignment<Request,Enrollment> assignment, boolean precise)` Number of last like (`Student.isDummy()` equals true) students with a complete schedule (`Student.isComplete(Assignment)` equals true).
    `int` | `getNrCompleteRealStudents(Assignment<Request,Enrollment> assignment, boolean precise)` Number of real (`Student.isDummy()` equals false) students with a complete schedule (`Student.isComplete(Assignment)` equals true).
    `int` | `getNrLastLikeRequests(boolean precise)` Number of requests from projected (`Student.isDummy()` equals true) students.
    `int` | `getNrLastLikeStudents(boolean precise)` Number of last like (`Student.isDummy()` equals true) students.
    `int` | `getNrRealRequests(boolean precise)` Number of requests from real (`Student.isDummy()` equals false) students.
    `int` | `getNrRealStudents(boolean precise)` Number of real (`Student.isDummy()` equals false) students.
    `List<Offering>` | `getOfferings()` List of offerings
    `DataProperties` | `getProperties()` Configuration
    `boolean` | `getReservationCanAssignOverTheLimit()` Return true if reservation that has `Reservation.canAssignOverLimit()` can assign enrollments over the limit
    `StudentQuality` | `getStudentQuality()`
    `List<Student>` | `getStudents()` Students
    `int` | `getStudentsWithAccommodation(String acc)` Count students with given accommodation
    `StudentWeights` | `getStudentWeights()` Return student weighting model
    `TimeOverlapsCounter` | `getTimeOverlaps()` Return time overlaps extension
    `double` | `getTotalRequestWeight()` Sum of weights of all requests (see `Request.getWeight()`).
    `double` | `getTotalValue(Assignment<Request,Enrollment> assignment)` Overall solution value
    `double` | `getTotalValue(Assignment<Request,Enrollment> assignment, boolean precise)` Overall solution value
    `double` | `getUnassignedRequestWeight(Assignment<Request,Enrollment> assignment)` Sum of weights of all requests that are not assigned (see `Request.getWeight()`).
    `StudentSectioningModel.StudentSectioningModelContext` | `inheritAssignmentContext(Assignment<Request,Enrollment> assignment, StudentSectioningModel.StudentSectioningModelContext parentContext)` Create a new assignment context for the given assignment.
    `boolean` | `isMPP()` Return true if the problem is minimal perturbation problem
    `void` | `recomputeTotalValue(Assignment<Request,Enrollment> assignment)`
    `void` | `removeStudent(Student student)` Remove a student from the model
    `void` | `removeVariable(Request request)` Removes a variable from the model
    `void` | `requestWeightsChanged(Assignment<Request,Enrollment> assignment)` Recompute cached request weights
    `void` | `restoreBest(Assignment<Request,Enrollment> assignment)` Restore the best ever found assignment into the current assignment
    `void` | `saveBest(Assignment<Request,Enrollment> assignment)` Save the current assignment as the best ever found assignment
    `void` | `setDistanceConflict(DistanceConflict dc)` Set distance conflict extension
    `void` | `setMaxDomainSize(int maxDomainSize)` Maximal domain size (i.e., number of enrollments of a course request), -1 if there is no limit.
    `void` | `setStudentQuality(StudentQuality q)`
    `void` | `setStudentQuality(StudentQuality q, boolean register)`
    `void` | `setStudentWeights(StudentWeights weights)` Set student weighting model
    `void` | `setTimeOverlaps(TimeOverlapsCounter toc)` Set time overlaps extension
    `String` | `toString(Assignment<Request,Enrollment> assignment)` String representation -- returns a list of values of objective criteria

    - ### Methods inherited from class org.cpsolver.ifs.assignment.context.ModelWithContext

      `afterAssigned, afterUnassigned, beforeAssigned, beforeUnassigned, getAssignmentContextReference, getContext, getContext, getContextUpdateType, setAssignmentContextReference, setContextUpdateType`

    - ### Methods inherited from class org.cpsolver.ifs.model.Model

      `addConstraint, addCriterion, addGlobalConstraint, addModelListener, afterAssigned, afterUnassigned, assignedVariables, assignedVariables, beforeAssigned, beforeUnassigned, bestUnassignedVariables, bestUnassignedVariables, clearAssignmentContexts, clearBest, conflictConstraints, conflictValues, conflictValues, constraints, countConstraints, countGlobalConstraints, countVariables, createAssignmentContexts, createReference, getBestPerturbations, getBestUnassignedVariables, getBestValue, getCriteria, getCriterion, getDefaultAssignment, getEmptyAssignment, getExtendedInfo, getInfo, getInfo, getInfo, getInfoProviders, getModelListeners, getPerc, getPercRev, getTotalValue, getTotalValue, getTotalValue, globalConstraints, inConflict, inConflict, init, invalidateVariablesWithInitialValueCache, modelListenerOfType, nrAssignedVariables, nrAssignedVariables, nrUnassignedVariables, nrUnassignedVariables, perturbVariables, perturbVariables, perturbVariables, perturbVariables, removeConstraint, removeCriterion, removeCriterion, removeGlobalConstraint, removeModelListener, removeReference, restoreBest, restoreBest, saveBest, setBestValue, setDefaultAssignment, toString, unassignedHardConstraints, unassignedVariables, unassignedVariables, variables, variablesWithInitialValue, weaken`

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

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

- - ### Field Detail

    - #### sDecimalFormat

          protected static DecimalFormat sDecimalFormat

    - #### iProjectedStudentWeight

          protected double iProjectedStudentWeight

  - ### Constructor Detail

    - #### StudentSectioningModel

          public StudentSectioningModel(DataProperties properties)

      Constructor
      Parameters:
        `properties` - configuration

  - ### Method Detail

    - #### getReservationCanAssignOverTheLimit

          public boolean getReservationCanAssignOverTheLimit()

      Return true if reservation that has `Reservation.canAssignOverLimit()` can assign enrollments over the limit
      Returns:
        true if reservation that has `Reservation.canAssignOverLimit()` can assign enrollments over the limit

    - #### isMPP

          public boolean isMPP()

      Return true if the problem is minimal perturbation problem
      Returns:
        true if MPP is enabled

    - #### getKeepInitialAssignments

          public boolean getKeepInitialAssignments()

      Return true if the inital assignments are to be kept unchanged
      Returns:
        true if the initial assignments are to be kept at all cost

    - #### getStudentWeights

          public StudentWeights getStudentWeights()

      Return student weighting model
      Returns:
        student weighting model

    - #### setStudentWeights

          public void setStudentWeights(StudentWeights weights)

      Set student weighting model
      Parameters:
        `weights` - student weighting model

    - #### getStudents

          public List<Student> getStudents()

      Students
      Returns:
        all students in the problem

    - #### addStudent

          public void addStudent(Student student)

      Add a student into the model
      Parameters:
        `student` - a student to be added into the problem

    - #### getNbrStudents

          public int getNbrStudents(Student.StudentPriority priority)

    - #### addVariable

          public void addVariable(Request request)

      Description copied from class: `Model`
      Adds a variable to the model
      Overrides:
        `addVariable` in class `Model<Request,Enrollment>`
      Parameters:
        `request` - a variable

    - #### requestWeightsChanged

          public void requestWeightsChanged(Assignment<Request,Enrollment> assignment)

      Recompute cached request weights
      Parameters:
        `assignment` - current assignment

    - #### removeStudent

          public void removeStudent(Student student)

      Remove a student from the model
      Parameters:
        `student` - a student to be removed from the problem

    - #### removeVariable

          public void removeVariable(Request request)

      Description copied from class: `Model`
      Removes a variable from the model
      Overrides:
        `removeVariable` in class `Model<Request,Enrollment>`
      Parameters:
        `request` - a variable

    - #### getOfferings

          public List<Offering> getOfferings()

      List of offerings
      Returns:
        all instructional offerings of the problem

    - #### addOffering

          public void addOffering(Offering offering)

      Add an offering into the model
      Parameters:
        `offering` - an instructional offering to be added into the problem

    - #### addLinkedSections

          public void addLinkedSections(boolean mustBeUsed,
                                        Section... sections)

      Link sections using `LinkedSections`
      Parameters:
        `mustBeUsed` - if true, a pair of linked sections must be used when a student requests both courses
        `sections` - a linked section constraint to be added into the problem

    - #### addLinkedSections

          @Deprecated
          public void addLinkedSections(Section... sections)

      Deprecated.
      Link sections using `LinkedSections`
      Parameters:
        `sections` - a linked section constraint to be added into the problem

    - #### addLinkedSections

          public void addLinkedSections(boolean mustBeUsed,
                                        Collection<Section> sections)

      Link sections using `LinkedSections`
      Parameters:
        `mustBeUsed` - if true, a pair of linked sections must be used when a student requests both courses
        `sections` - a linked section constraint to be added into the problem

    - #### addLinkedSections

          @Deprecated
          public void addLinkedSections(Collection<Section> sections)

      Deprecated.
      Link sections using `LinkedSections`
      Parameters:
        `sections` - a linked section constraint to be added into the problem

    - #### getLinkedSections

          public List<LinkedSections> getLinkedSections()

      List of linked sections
      Returns:
        all linked section constraints of the problem

    - #### getInfo

          public Map<String,String> getInfo(Assignment<Request,Enrollment> assignment)

      Model info
      Overrides:
        `getInfo` in class `Model<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment
      Returns:
        info table

    - #### getTotalValue

          public double getTotalValue(Assignment<Request,Enrollment> assignment,
                                      boolean precise)

      Overall solution value
      Parameters:
        `assignment` - current assignment
        `precise` - true if should be computed
      Returns:
        solution value

    - #### getTotalValue

          public double getTotalValue(Assignment<Request,Enrollment> assignment)

      Overall solution value
      Overrides:
        `getTotalValue` in class `Model<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment
      Returns:
        solution value

    - #### getProperties

          public DataProperties getProperties()

      Configuration
      Returns:
        solver configuration

    - #### clearOnlineSectioningInfos

          public void clearOnlineSectioningInfos()

      Empty online student sectioning infos for all sections (see `Section.getSpaceExpected()` and `Section.getSpaceHeld()`).

    - #### computeOnlineSectioningInfos

          public void computeOnlineSectioningInfos(Assignment<Request,Enrollment> assignment)

      Compute online student sectioning infos for all sections (see `Section.getSpaceExpected()` and `Section.getSpaceHeld()`).
      Parameters:
        `assignment` - current assignment

    - #### getUnassignedRequestWeight

          public double getUnassignedRequestWeight(Assignment<Request,Enrollment> assignment)

      Sum of weights of all requests that are not assigned (see `Request.getWeight()`).
      Parameters:
        `assignment` - current assignment
      Returns:
        unassigned request weight

    - #### getTotalRequestWeight

          public double getTotalRequestWeight()

      Sum of weights of all requests (see `Request.getWeight()`).
      Returns:
        total request weight

    - #### setDistanceConflict

          public void setDistanceConflict(DistanceConflict dc)

      Set distance conflict extension
      Parameters:
        `dc` - distance conflicts extension

    - #### getDistanceConflict

          public DistanceConflict getDistanceConflict()

      Return distance conflict extension
      Returns:
        distance conflicts extension

    - #### setTimeOverlaps

          public void setTimeOverlaps(TimeOverlapsCounter toc)

      Set time overlaps extension
      Parameters:
        `toc` - time overlapping conflicts extension

    - #### getTimeOverlaps

          public TimeOverlapsCounter getTimeOverlaps()

      Return time overlaps extension
      Returns:
        time overlapping conflicts extension

    - #### getStudentQuality

          public StudentQuality getStudentQuality()

    - #### setStudentQuality

          public void setStudentQuality(StudentQuality q,
                                        boolean register)

    - #### setStudentQuality

          public void setStudentQuality(StudentQuality q)

    - #### avgUnassignPriority

          public double avgUnassignPriority(Assignment<Request,Enrollment> assignment)

      Average priority of unassigned requests (see `Request.getPriority()`)
      Parameters:
        `assignment` - current assignment
      Returns:
        average priority of unassigned requests

    - #### avgNrRequests

          public double avgNrRequests()

      Average number of requests per student (see `Student.getRequests()` )
      Returns:
        average number of requests per student

    - #### getNrLastLikeStudents

          public int getNrLastLikeStudents(boolean precise)

      Number of last like (`Student.isDummy()` equals true) students.
      Parameters:
        `precise` - true if to be computed
      Returns:
        number of last like (projected) students

    - #### getNrRealStudents

          public int getNrRealStudents(boolean precise)

      Number of real (`Student.isDummy()` equals false) students.
      Parameters:
        `precise` - true if to be computed
      Returns:
        number of real students

    - #### getStudentsWithAccommodation

          public int getStudentsWithAccommodation(String acc)

      Count students with given accommodation

    - #### getNrCompleteLastLikeStudents

          public int getNrCompleteLastLikeStudents(Assignment<Request,Enrollment> assignment,
                                                   boolean precise)

      Number of last like (`Student.isDummy()` equals true) students with a complete schedule (`Student.isComplete(Assignment)` equals true).
      Parameters:
        `assignment` - current assignment
        `precise` - true if to be computed
      Returns:
        number of last like (projected) students with a complete schedule

    - #### getNrCompleteRealStudents

          public int getNrCompleteRealStudents(Assignment<Request,Enrollment> assignment,
                                               boolean precise)

      Number of real (`Student.isDummy()` equals false) students with a complete schedule (`Student.isComplete(Assignment)` equals true).
      Parameters:
        `assignment` - current assignment
        `precise` - true if to be computed
      Returns:
        number of real students with a complete schedule

    - #### getNrLastLikeRequests

          public int getNrLastLikeRequests(boolean precise)

      Number of requests from projected (`Student.isDummy()` equals true) students.
      Parameters:
        `precise` - true if to be computed
      Returns:
        number of requests from projected students

    - #### getNrRealRequests

          public int getNrRealRequests(boolean precise)

      Number of requests from real (`Student.isDummy()` equals false) students.
      Parameters:
        `precise` - true if to be computed
      Returns:
        number of requests from real students

    - #### getNrAssignedLastLikeRequests

          public int getNrAssignedLastLikeRequests(Assignment<Request,Enrollment> assignment,
                                                   boolean precise)

      Number of requests from projected (`Student.isDummy()` equals true) students that are assigned.
      Parameters:
        `assignment` - current assignment
        `precise` - true if to be computed
      Returns:
        number of requests from projected students that are assigned

    - #### getNrAssignedRealRequests

          public int getNrAssignedRealRequests(Assignment<Request,Enrollment> assignment,
                                               boolean precise)

      Number of requests from real (`Student.isDummy()` equals false) students that are assigned.
      Parameters:
        `assignment` - current assignment
        `precise` - true if to be computed
      Returns:
        number of requests from real students that are assigned

    - #### getExtendedInfo

          public Map<String,String> getExtendedInfo(Assignment<Request,Enrollment> assignment)

      Model extended info. Some more information (that is more expensive to compute) is added to an ordinary `Model.getInfo(Assignment)`.
      Overrides:
        `getExtendedInfo` in class `Model<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment
      Returns:
        extended info table

    - #### restoreBest

          public void restoreBest(Assignment<Request,Enrollment> assignment)

      Description copied from class: `Model`
      Restore the best ever found assignment into the current assignment
      Overrides:
        `restoreBest` in class `Model<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment

    - #### recomputeTotalValue

          public void recomputeTotalValue(Assignment<Request,Enrollment> assignment)

    - #### saveBest

          public void saveBest(Assignment<Request,Enrollment> assignment)

      Description copied from class: `Model`
      Save the current assignment as the best ever found assignment
      Overrides:
        `saveBest` in class `Model<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment

    - #### getBestAssignedCourseRequestWeight

          public double getBestAssignedCourseRequestWeight()

    - #### toString

          public String toString(Assignment<Request,Enrollment> assignment)

      Description copied from class: `Model`
      String representation -- returns a list of values of objective criteria
      Overrides:
        `toString` in class `Model<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment
      Returns:
        comma separated string of `AbstractCriterion.toString(Assignment)`

    - #### avg

          public double avg(double w1,
                            double w2)

      Quadratic average of two weights.
      Parameters:
        `w1` - first weight
        `w2` - second weight
      Returns:
        average of the two weights

    - #### getMaxDomainSize

          public int getMaxDomainSize()

      Maximal domain size (i.e., number of enrollments of a course request), -1 if there is no limit.
      Returns:
        maximal domain size, -1 if unlimited

    - #### setMaxDomainSize

          public void setMaxDomainSize(int maxDomainSize)

      Maximal domain size (i.e., number of enrollments of a course request), -1 if there is no limit.
      Parameters:
        `maxDomainSize` - maximal domain size, -1 if unlimited

    - #### createAssignmentContext

          public StudentSectioningModel.StudentSectioningModelContext createAssignmentContext(Assignment<Request,Enrollment> assignment)

      Description copied from interface: `HasAssignmentContext`
      Create a new assignment context for the given assignment. If there are already some variables assigned in the value, the method should make sure that the context is appropriately initialized.
      Specified by:
        `createAssignmentContext` in interface `HasAssignmentContext<Request,Enrollment,StudentSectioningModel.StudentSectioningModelContext>`
      Parameters:
        `assignment` - an assignment for which there needs to be an assignment context
      Returns:
        a new instance of the assignment context, filled according to the given assignment

    - #### createInheritedAssignment

          public InheritedAssignment<Request,Enrollment> createInheritedAssignment(Solution<Request,Enrollment> solution,
                                                                                   int index)

      Description copied from class: `Model`
      Create a new inherited assignment from the given solution
      Overrides:
        `createInheritedAssignment` in class `Model<Request,Enrollment>`
      Parameters:
        `solution` - a solution that is using this model
        `index` - thread index of the new assignment
      Returns:
        a new inherited assignment

    - #### getDistanceMetric

          public DistanceMetric getDistanceMetric()

    - #### inheritAssignmentContext

          public StudentSectioningModel.StudentSectioningModelContext inheritAssignmentContext(Assignment<Request,Enrollment> assignment,
                                                                                               StudentSectioningModel.StudentSectioningModelContext parentContext)

      Description copied from interface: `CanInheritContext`
      Create a new assignment context for the given assignment. This method can be used to clone the parent context if desired.
      Specified by:
        `inheritAssignmentContext` in interface `CanInheritContext<Request,Enrollment,StudentSectioningModel.StudentSectioningModelContext>`
      Parameters:
        `assignment` - an assignment for which there needs to be an assignment context
        `parentContext` - context of the parent assignment
      Returns:
        a new instance of the assignment context, filled according to the given assignment