org.cpsolver.coursett.model

## Class TimetableModel

- java.lang.Object
- - org.cpsolver.ifs.model.Model<V,T>
  - - org.cpsolver.ifs.constant.ConstantModel<Lecture,Placement>
    - - org.cpsolver.coursett.model.TimetableModel

-     public class TimetableModel
      extends ConstantModel<Lecture,Placement>

  Timetable model.
  Version:
    CourseTT 1.3 (University Course Timetabling)
    Copyright (C) 2006 - 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/.
  Author:
    Tomáš Müller

- - ### Field Summary

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

      `sPercentageFormat, sTimeFormat`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimetableModel(DataProperties properties)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addConstraint(Constraint<Lecture,Placement> constraint)` Adds a constraint to the model
    `void` | `addCriterion(Criterion<Lecture,Placement> criterion)` Register a new criterion
    `void` | `addStudent(Student student)`
    `void` | `addStudentGroup(StudentGroup group)`
    `Set<Placement>` | `conflictValuesSkipWeakeningConstraints(Assignment<Lecture,Placement> assignment, Placement value)` Returns the set of conflicting variables with this value, if it is assigned to its variable.
    `protected void` | `decJenrl(Assignment<Lecture,Placement> assignment, Student student, Lecture l1, Lecture l2)` Decrement `JenrlConstraint` between the given two classes by the given student
    `Set<Student>` | `getAllStudents()`
    `Map<String,String>` | `getBounds(Assignment<Lecture,Placement> assignment)`
    `List<ClassLimitConstraint>` | `getClassLimitConstraints()`
    `List<DepartmentSpreadConstraint>` | `getDepartmentSpreadConstraints()` The list of all departmental spread constraints
    `DistanceMetric` | `getDistanceMetric()`
    `List<FlexibleConstraint>` | `getFlexibleConstraints()`
    `List<GroupConstraint>` | `getGroupConstraints()` The list of all group constraints
    `Map<String,String>` | `getInfo(Assignment<Lecture,Placement> assignment)` Global info
    `Map<String,String>` | `getInfo(Assignment<Lecture,Placement> assignment, Collection<Lecture> variables)` Returns information about the current solution.
    `List<InstructorConstraint>` | `getInstructorConstraints()` The list of all instructor constraints
    `List<JenrlConstraint>` | `getJenrlConstraints()` The list of all jenrl constraints
    `static String` | `getMem()` Returns amount of allocated memory.
    `DataProperties` | `getProperties()`
    `List<RoomConstraint>` | `getRoomConstraints()` The list of all room constraints
    `List<SpreadConstraint>` | `getSpreadConstraints()`
    `List<StudentConflict>` | `getStudentConflictCriteria()` List of student conflict criteria
    `List<StudentGroup>` | `getStudentGroups()`
    `StudentSectioning` | `getStudentSectioning()` Returns interface to the student sectioning functions needed during course timetabling.
    `int` | `getStudentWorkDayLimit()`
    `double` | `getTotalValue(Assignment<Lecture,Placement> assignment)` Value of the current solution.
    `double` | `getTotalValue(Assignment<Lecture,Placement> assignment, Collection<Lecture> variables)` Value of the current solution.
    `List<BitSet>` | `getWeeks()` The method creates date patterns (bitsets) which represent the weeks of a semester.
    `int` | `getYear()`
    `protected void` | `incJenrl(Assignment<Lecture,Placement> assignment, Student student, Lecture l1, Lecture l2)` Increment `JenrlConstraint` between the given two classes by the given student
    `boolean` | `isAllowBreakHard()`
    `boolean` | `isOnFlySectioningEnabled()`
    `void` | `removeConstraint(Constraint<Lecture,Placement> constraint)` Removes a constraint from the model
    `void` | `removeCriterion(Criterion<Lecture,Placement> criterion)` Unregister an existing criterion
    `void` | `removeStudent(Student student)`
    `void` | `restoreBest(Assignment<Lecture,Placement> assignment)` Restore the best ever found assignment into the current assignment
    `void` | `saveBest(Assignment<Lecture,Placement> assignment)` Save the current assignment as the best ever found assignment
    `void` | `setOnFlySectioningEnabled(boolean onFlySectioning)`
    `void` | `setYear(int year)`
    `void` | `switchStudents(Assignment<Lecture,Placement> assignment)` Student final sectioning (switching students between sections of the same class in order to minimize overall number of student conflicts)
    `void` | `switchStudents(Assignment<Lecture,Placement> assignment, TerminationCondition<Lecture,Placement> termination)` Student final sectioning (switching students between sections of the same class in order to minimize overall number of student conflicts)

    - ### Methods inherited from class org.cpsolver.ifs.constant.ConstantModel

      `addVariable, afterAssigned, afterUnassigned, beforeAssigned, beforeUnassigned, constantVariables, hasConstantVariables, isConstant, removeVariable`

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

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

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

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

- - ### Constructor Detail

    - #### TimetableModel

          public TimetableModel(DataProperties properties)

  - ### Method Detail

    - #### getDistanceMetric

          public DistanceMetric getDistanceMetric()

    - #### getStudentWorkDayLimit

          public int getStudentWorkDayLimit()

    - #### getStudentSectioning

          public StudentSectioning getStudentSectioning()

      Returns interface to the student sectioning functions needed during course timetabling. Defaults to an instance of `DefaultStudentSectioning`, can be changed using the StudentSectioning.Class parameter.
      Returns:
        student sectioning

    - #### getProperties

          public DataProperties getProperties()

    - #### switchStudents

          public void switchStudents(Assignment<Lecture,Placement> assignment,
                                     TerminationCondition<Lecture,Placement> termination)

      Student final sectioning (switching students between sections of the same class in order to minimize overall number of student conflicts)
      Parameters:
        `assignment` - current assignment
        `termination` - optional termination condition

    - #### switchStudents

          public void switchStudents(Assignment<Lecture,Placement> assignment)

      Student final sectioning (switching students between sections of the same class in order to minimize overall number of student conflicts)
      Parameters:
        `assignment` - current assignment

    - #### getBounds

          public Map<String,String> getBounds(Assignment<Lecture,Placement> assignment)

    - #### getInfo

          public Map<String,String> getInfo(Assignment<Lecture,Placement> assignment)

      Global info
      Overrides:
        `getInfo` in class `Model<Lecture,Placement>`
      Parameters:
        `assignment` - current assignment
      Returns:
        info table

    - #### getInfo

          public Map<String,String> getInfo(Assignment<Lecture,Placement> assignment,
                                            Collection<Lecture> variables)

      Description copied from class: `Model`
      Returns information about the current solution. Information from all model listeners and constraints is also included. Only variables from the given set are considered.
      Overrides:
        `getInfo` in class `Model<Lecture,Placement>`
      Parameters:
        `assignment` - current assignment
        `variables` - sub-problem
      Returns:
        info table

    - #### addConstraint

          public void addConstraint(Constraint<Lecture,Placement> constraint)

      Description copied from class: `Model`
      Adds a constraint to the model
      Overrides:
        `addConstraint` in class `Model<Lecture,Placement>`
      Parameters:
        `constraint` - a constraint

    - #### removeConstraint

          public void removeConstraint(Constraint<Lecture,Placement> constraint)

      Description copied from class: `Model`
      Removes a constraint from the model
      Overrides:
        `removeConstraint` in class `Model<Lecture,Placement>`
      Parameters:
        `constraint` - a constraint

    - #### getInstructorConstraints

          public List<InstructorConstraint> getInstructorConstraints()

      The list of all instructor constraints
      Returns:
        list of instructor constraints

    - #### getGroupConstraints

          public List<GroupConstraint> getGroupConstraints()

      The list of all group constraints
      Returns:
        list of group (distribution) constraints

    - #### getJenrlConstraints

          public List<JenrlConstraint> getJenrlConstraints()

      The list of all jenrl constraints
      Returns:
        list of join enrollment constraints

    - #### getRoomConstraints

          public List<RoomConstraint> getRoomConstraints()

      The list of all room constraints
      Returns:
        list of room constraints

    - #### getDepartmentSpreadConstraints

          public List<DepartmentSpreadConstraint> getDepartmentSpreadConstraints()

      The list of all departmental spread constraints
      Returns:
        list of department spread constraints

    - #### getSpreadConstraints

          public List<SpreadConstraint> getSpreadConstraints()

    - #### getClassLimitConstraints

          public List<ClassLimitConstraint> getClassLimitConstraints()

    - #### getFlexibleConstraints

          public List<FlexibleConstraint> getFlexibleConstraints()

    - #### getTotalValue

          public double getTotalValue(Assignment<Lecture,Placement> assignment)

      Description copied from class: `Model`
      Value of the current solution. It is the sum of all assigned values, i.e., `Value.toDouble(Assignment)`.
      Overrides:
        `getTotalValue` in class `Model<Lecture,Placement>`
      Parameters:
        `assignment` - current assignment
      Returns:
        solution value

    - #### getTotalValue

          public double getTotalValue(Assignment<Lecture,Placement> assignment,
                                      Collection<Lecture> variables)

      Description copied from class: `Model`
      Value of the current solution. It is the sum of all assigned values, i.e., `Value.toDouble(Assignment)`. Only variables from the given set are considered.
      Overrides:
        `getTotalValue` in class `Model<Lecture,Placement>`
      Parameters:
        `assignment` - current assignment
        `variables` - sub-problem
      Returns:
        solution value

    - #### getYear

          public int getYear()

    - #### setYear

          public void setYear(int year)

    - #### getAllStudents

          public Set<Student> getAllStudents()

    - #### addStudent

          public void addStudent(Student student)

    - #### removeStudent

          public void removeStudent(Student student)

    - #### getMem

          public static String getMem()

      Returns amount of allocated memory.
      Returns:
        amount of allocated memory to be written in the log

    - #### conflictValuesSkipWeakeningConstraints

          public Set<Placement> conflictValuesSkipWeakeningConstraints(Assignment<Lecture,Placement> assignment,
                                                                       Placement value)

      Returns the set of conflicting variables with this value, if it is assigned to its variable. Conflicts with constraints that implement `WeakeningConstraint` are ignored.
      Parameters:
        `assignment` - current assignment
        `value` - placement that is being considered
      Returns:
        computed conflicting assignments

    - #### getWeeks

          public List<BitSet> getWeeks()

      The method creates date patterns (bitsets) which represent the weeks of a semester.
      Returns:
        a list of BitSets which represents the weeks of a semester.

    - #### getStudentGroups

          public List<StudentGroup> getStudentGroups()

    - #### addStudentGroup

          public void addStudentGroup(StudentGroup group)

    - #### saveBest

          public void saveBest(Assignment<Lecture,Placement> assignment)

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

    - #### incJenrl

          protected void incJenrl(Assignment<Lecture,Placement> assignment,
                                  Student student,
                                  Lecture l1,
                                  Lecture l2)

      Increment `JenrlConstraint` between the given two classes by the given student

    - #### decJenrl

          protected void decJenrl(Assignment<Lecture,Placement> assignment,
                                  Student student,
                                  Lecture l1,
                                  Lecture l2)

      Decrement `JenrlConstraint` between the given two classes by the given student

    - #### restoreBest

          public void restoreBest(Assignment<Lecture,Placement> assignment)

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

    - #### isAllowBreakHard

          public boolean isAllowBreakHard()

    - #### isOnFlySectioningEnabled

          public boolean isOnFlySectioningEnabled()

    - #### setOnFlySectioningEnabled

          public void setOnFlySectioningEnabled(boolean onFlySectioning)

    - #### addCriterion

          public void addCriterion(Criterion<Lecture,Placement> criterion)

      Description copied from class: `Model`
      Register a new criterion
      Overrides:
        `addCriterion` in class `Model<Lecture,Placement>`
      Parameters:
        `criterion` - a criterion

    - #### removeCriterion

          public void removeCriterion(Criterion<Lecture,Placement> criterion)

      Description copied from class: `Model`
      Unregister an existing criterion
      Overrides:
        `removeCriterion` in class `Model<Lecture,Placement>`
      Parameters:
        `criterion` - a criterion

    - #### getStudentConflictCriteria

          public List<StudentConflict> getStudentConflictCriteria()

      List of student conflict criteria