net.sf.cpsolver.coursett.constraint

## Class InstructorConstraint

- java.lang.Object
- - net.sf.cpsolver.ifs.model.Constraint<Lecture,Placement>
  - - net.sf.cpsolver.coursett.constraint.InstructorConstraint

- All Implemented Interfaces:
    Comparable<Constraint<Lecture,Placement>>

      public class InstructorConstraint
      extends Constraint<Lecture,Placement>

  Instructor constraint.
  Classes with this instructor can not overlap in time. Also, for back-to-back classes, there is the following reasoning:
  - if the distance is equal or below `DistanceMetric.getInstructorNoPreferenceLimit()` .. no preference
  - if the distance is above `DistanceMetric.getInstructorNoPreferenceLimit()` and below `DistanceMetric.getInstructorDiscouragedLimit()` .. constraint is discouraged (soft, preference = 1)
  - if the distance is above `DistanceMetric.getInstructorDiscouragedLimit()` and below `DistanceMetric.getInstructorProhibitedLimit()` .. constraint is strongly discouraged (soft, preference = 2)
  - if the distance is above `DistanceMetric.getInstructorProhibitedLimit()` .. constraint is prohibited (hard)
  When `isIgnoreDistances()` is set to true, the constraint never prohibits two back-to-back classes (but it still tries to minimize the above back-to-back preferences).
  Version:
    CourseTT 1.2 (University Course Timetabling)
    Copyright (C) 2006 - 2010 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/.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `iPreference`
    `protected List<Placement>[]` | `iResource` table iResource[slot] = lecture using this resource placed in the given time slot (null if empty)

    - ### Fields inherited from class net.sf.cpsolver.ifs.model.Constraint

      `iAssignedVariables, iConstraintListeners, iId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InstructorConstraint(Long id, String puid, String name, boolean ignDist)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assigned(long iteration, Placement placement)` Given value is to be assigned to its varable.
    `void` | `computeConflicts(Placement placement, Set<Placement> conflicts)` The only method which has to be implemented by any constraint.
    `int` | `countPreference()`
    `int` | `countUselessSlots()` Number of useless slots for this resource
    `List<Placement>[]` | `getAvailableArray()` Deprecated.
    `int` | `getDistancePreference(Placement p1, Placement p2)` Back-to-back preference of two placements (3 means prohibited)
    `String` | `getName()` Resource name
    `Placement` | `getPlacement(int slot, int day)`
    `List<Placement>` | `getPlacements(int slot, BitSet weekCode)`
    `List<Placement>` | `getPlacements(int slot, Placement placement)`
    `int` | `getPreference()` Overall back-to-back preference of this instructor
    `int` | `getPreference(Placement value)` Back-to-back preference of the given placement
    `int` | `getPreferenceCombination(Placement value)`
    `String` | `getPuid()`
    `List<Placement>` | `getResource(int slot)` Lookup table getResource()[slot] -> lecture using this resource placed in the given time slot (null if empty)
    `Long` | `getResourceId()` Resource id
    `Placement[]` | `getResourceOfWeek(int startDay)`
    `Long` | `getType()`
    `List<Placement>` | `getUnavailabilities()`
    `int` | `getWorstPreference()` Worst back-to-back preference of this instructor
    `boolean` | `inConflict(Placement placement)` Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint.
    `boolean` | `isAvailable(Lecture lecture, Placement placement)`
    `boolean` | `isAvailable(Lecture lecture, TimeLocation time)`
    `boolean` | `isConsistent(Placement p1, Placement p2)` Returns true if the given assignments are consistent respecting this constraint.
    `boolean` | `isIgnoreDistances()`
    `protected void` | `printUsage(StringBuffer sb)` Resource usage usage
    `void` | `setIgnoreDistances(boolean ignDist)`
    `void` | `setNotAvailable(Placement placement)`
    `void` | `setType(Long type)`
    `String` | `toString()`
    `void` | `unassigned(long iteration, Placement placement)` Given value is unassigned from its variable.

    - ### Methods inherited from class net.sf.cpsolver.ifs.model.Constraint

      `addConstraintListener, addVariable, assignedVariables, compareTo, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, isHard, removeConstraintListener, removeVariable, setModel, variables`

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

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

- - ### Field Detail

    - #### iPreference

          public int iPreference

    - #### iResource

          protected List<Placement>[] iResource

      table iResource[slot] = lecture using this resource placed in the given time slot (null if empty)

  - ### Constructor Detail

    - #### InstructorConstraint

          public InstructorConstraint(Long id,
                                      String puid,
                                      String name,
                                      boolean ignDist)

      Constructor
      Parameters:
        `id` - instructor id
        `name` - instructor name

  - ### Method Detail

    - #### getPlacements

          public List<Placement> getPlacements(int slot,
                                               Placement placement)

    - #### getPlacements

          public List<Placement> getPlacements(int slot,
                                               BitSet weekCode)

    - #### getPlacement

          public Placement getPlacement(int slot,
                                        int day)

    - #### setNotAvailable

          public void setNotAvailable(Placement placement)

    - #### isAvailable

          public boolean isAvailable(Lecture lecture,
                                     TimeLocation time)

    - #### isAvailable

          public boolean isAvailable(Lecture lecture,
                                     Placement placement)

    - #### getUnavailabilities

          public List<Placement> getUnavailabilities()

    - #### getAvailableArray

          @Deprecated
          public List<Placement>[] getAvailableArray()

      Deprecated.

    - #### getDistancePreference

          public int getDistancePreference(Placement p1,
                                           Placement p2)

      Back-to-back preference of two placements (3 means prohibited)

    - #### getResourceId

          public Long getResourceId()

      Resource id

    - #### getName

          public String getName()

      Resource name
      Overrides:
        `getName` in class `Constraint<Lecture,Placement>`

    - #### computeConflicts

          public void computeConflicts(Placement placement,
                                       Set<Placement> conflicts)

      Description copied from class: `Constraint`
      The only method which has to be implemented by any constraint. It returns the values which needs to be unassigned in order to make this constraint consistent with the given value if it is assigned to its variable. The computed list of conflicting values is added to the given set of conflicts.
      Specified by:
        `computeConflicts` in class `Constraint<Lecture,Placement>`
      Parameters:
        `placement` - value to be assigned to its varaible
        `conflicts` - resultant set of conflicting values

    - #### inConflict

          public boolean inConflict(Placement placement)

      Description copied from class: `Constraint`
      Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint. This method is used by MAC (see `MacPropagation`).
      Overrides:
        `inConflict` in class `Constraint<Lecture,Placement>`

    - #### isConsistent

          public boolean isConsistent(Placement p1,
                                      Placement p2)

      Description copied from class: `Constraint`
      Returns true if the given assignments are consistent respecting this constraint. This method is used by MAC (see `MacPropagation`).
      Overrides:
        `isConsistent` in class `Constraint<Lecture,Placement>`

    - #### assigned

          public void assigned(long iteration,
                               Placement placement)

      Description copied from class: `Constraint`
      Given value is to be assigned to its varable. In this method, the constraint should unassigns all varaibles which are in conflict with the given assignment because of this constraint.
      Overrides:
        `assigned` in class `Constraint<Lecture,Placement>`

    - #### unassigned

          public void unassigned(long iteration,
                                 Placement placement)

      Description copied from class: `Constraint`
      Given value is unassigned from its variable.
      Overrides:
        `unassigned` in class `Constraint<Lecture,Placement>`

    - #### getResource

          public List<Placement> getResource(int slot)

      Lookup table getResource()[slot] -> lecture using this resource placed in the given time slot (null if empty)

    - #### getResourceOfWeek

          public Placement[] getResourceOfWeek(int startDay)

    - #### countUselessSlots

          public int countUselessSlots()

      Number of useless slots for this resource

    - #### printUsage

          protected void printUsage(StringBuffer sb)

      Resource usage usage

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getPreference

          public int getPreference(Placement value)

      Back-to-back preference of the given placement

    - #### getPreferenceCombination

          public int getPreferenceCombination(Placement value)

    - #### getPreference

          public int getPreference()

      Overall back-to-back preference of this instructor

    - #### countPreference

          public int countPreference()

    - #### getWorstPreference

          public int getWorstPreference()

      Worst back-to-back preference of this instructor

    - #### getPuid

          public String getPuid()

    - #### isIgnoreDistances

          public boolean isIgnoreDistances()

    - #### setIgnoreDistances

          public void setIgnoreDistances(boolean ignDist)

    - #### getType

          public Long getType()

    - #### setType

          public void setType(Long type)