org.cpsolver.exam.model

## Class ExamInstructor

- java.lang.Object
- - org.cpsolver.ifs.model.Constraint<Exam,ExamPlacement>
  - - org.cpsolver.exam.model.ExamInstructor

- All Implemented Interfaces:
    Comparable<Constraint<Exam,ExamPlacement>>

      public class ExamInstructor
      extends Constraint<Exam,ExamPlacement>

  An instructor.
  Version:
    ExamTT 1.3 (Examination Timetabling)
    Copyright (C) 2008 - 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.Constraint

      `iConstraintListeners, iId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExamInstructor(ExamModel model, long id, String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canConflict(Exam ex1, Exam ex2)` True if the given two exams can have a direct instructor conflict with this instructor, i.e., they can be placed at the same period.
    `int` | `compareTo(ExamInstructor o)` Compare two instructors (by instructor ids)
    `void` | `computeConflicts(Assignment<Exam,ExamPlacement> assignment, ExamPlacement p, Set<ExamPlacement> conflicts)` Compute conflicts between the given assignment of an exam and all the current assignments (of this instructor).
    `boolean` | `equals(Object o)` Compare two instructors for equality
    `Set<Exam>` | `getExams(Assignment<Exam,ExamPlacement> assignment, ExamPeriod period)` Exam(s) enrolled by the instructor that are scheduled in the given period
    `Set<Exam>` | `getExamsADay(Assignment<Exam,ExamPlacement> assignment, ExamPeriod period)` Exam(s) enrolled by the instructor that are scheduled in the given day
    `Set<Exam>` | `getExamsADay(Assignment<Exam,ExamPlacement> assignment, int day)` Exam(s) enrolled by the instructor that are scheduled in the given day
    `String` | `getName()` Instructor name
    `List<ExamOwner>` | `getOwners()` Courses and/or sections that this instructor is enrolled to
    `int` | `hashCode()` Hash code
    `boolean` | `hasName()` Instructor name
    `boolean` | `inConflict(Assignment<Exam,ExamPlacement> assignment, ExamPlacement p)` Check whether there is a conflict between the given assignment of an exam and all the current assignments (of this instructor).
    `boolean` | `isAllowDirectConflicts()` True when direct instructor conflicts are not allowed.
    `boolean` | `isAvailable(ExamPeriod period)` True if the student is available (for examination timetabling) during the given period
    `boolean` | `isConsistent(ExamPlacement p1, ExamPlacement p2)` True if the given exams can conflict (see `isAllowDirectConflicts()`), or if they are placed at different periods.
    `boolean` | `isHard()` Returns true if the constraint is hard.
    `void` | `setAllowDirectConflicts(boolean allowDirectConflicts)` Set to true when direct instructor conflicts are not allowed.
    `void` | `setAvailable(int period, boolean available)` Set whether the student is available (for examination timetabling) during the given period
    `String` | `toString()` Instructor name

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

      `addConstraintListener, addVariable, assigned, assignedVariables, compareTo, computeConflictsNoForwardCheck, constraintListeners, countAssignedVariables, countVariables, getDescription, getId, getModel, removeConstraintListener, removeVariable, setModel, unassigned, variables`

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

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

- - ### Constructor Detail

    - #### ExamInstructor

          public ExamInstructor(ExamModel model,
                                long id,
                                String name)

  - ### Method Detail

    - #### isAllowDirectConflicts

          public boolean isAllowDirectConflicts()

      True when direct instructor conflicts are not allowed.
      Returns:
        true if direct conflicts are allowed

    - #### setAllowDirectConflicts

          public void setAllowDirectConflicts(boolean allowDirectConflicts)

      Set to true when direct instructor conflicts are not allowed.
      Parameters:
        `allowDirectConflicts` - true if direct conflicts are allowed

    - #### getExams

          public Set<Exam> getExams(Assignment<Exam,ExamPlacement> assignment,
                                    ExamPeriod period)

      Exam(s) enrolled by the instructor that are scheduled in the given period
      Parameters:
        `assignment` - current assignment
        `period` - given period
      Returns:
        exams that are associated with this instructor and placed in the given period

    - #### getExamsADay

          public Set<Exam> getExamsADay(Assignment<Exam,ExamPlacement> assignment,
                                        ExamPeriod period)

      Exam(s) enrolled by the instructor that are scheduled in the given day
      Parameters:
        `assignment` - current assignment
        `period` - given period
      Returns:
        exams that are associated with this instructor and placed in the day of the given period

    - #### getExamsADay

          public Set<Exam> getExamsADay(Assignment<Exam,ExamPlacement> assignment,
                                        int day)

      Exam(s) enrolled by the instructor that are scheduled in the given day
      Parameters:
        `assignment` - current assignment
        `day` - given day
      Returns:
        exams that are associated with this instructor and placed in the given day

    - #### computeConflicts

          public void computeConflicts(Assignment<Exam,ExamPlacement> assignment,
                                       ExamPlacement p,
                                       Set<ExamPlacement> conflicts)

      Compute conflicts between the given assignment of an exam and all the current assignments (of this instructor). Only not-allowed conflicts (see `isAllowDirectConflicts()`) are considered.
      Specified by:
        `computeConflicts` in class `Constraint<Exam,ExamPlacement>`
      Parameters:
        `assignment` - current assignment
        `p` - value to be assigned to its variable
        `conflicts` - resultant set of conflicting values

    - #### inConflict

          public boolean inConflict(Assignment<Exam,ExamPlacement> assignment,
                                    ExamPlacement p)

      Check whether there is a conflict between the given assignment of an exam and all the current assignments (of this instructor). Only not-allowed conflicts (see `isAllowDirectConflicts()`) are considered.
      Overrides:
        `inConflict` in class `Constraint<Exam,ExamPlacement>`
      Parameters:
        `assignment` - current assignment
        `p` - given value
      Returns:
        true if there is a conflict with other assigned variables of the constraint

    - #### isConsistent

          public boolean isConsistent(ExamPlacement p1,
                                      ExamPlacement p2)

      True if the given exams can conflict (see `isAllowDirectConflicts()`), or if they are placed at different periods.
      Overrides:
        `isConsistent` in class `Constraint<Exam,ExamPlacement>`
      Parameters:
        `p1` - a value
        `p2` - a value
      Returns:
        true if the constraint is ok with the assignment

    - #### equals

          public boolean equals(Object o)

      Compare two instructors for equality
      Overrides:
        `equals` in class `Constraint<Exam,ExamPlacement>`

    - #### hashCode

          public int hashCode()

      Hash code
      Overrides:
        `hashCode` in class `Constraint<Exam,ExamPlacement>`

    - #### getName

          public String getName()

      Instructor name
      Overrides:
        `getName` in class `Constraint<Exam,ExamPlacement>`
      Returns:
        constraint name

    - #### hasName

          public boolean hasName()

      Instructor name
      Returns:
        true if instructor name is set and not empty

    - #### toString

          public String toString()

      Instructor name
      Overrides:
        `toString` in class `Object`

    - #### compareTo

          public int compareTo(ExamInstructor o)

      Compare two instructors (by instructor ids)
      Parameters:
        `o` - another instructor
      Returns:
        comparison

    - #### getOwners

          public List<ExamOwner> getOwners()

      Courses and/or sections that this instructor is enrolled to
      Returns:
        list of `ExamOwner`

    - #### isHard

          public boolean isHard()

      Description copied from class: `Constraint`
      Returns true if the constraint is hard. Only hard constraints are allowed to unassign a variable when there is a conflict with a value that is being assigned
      Overrides:
        `isHard` in class `Constraint<Exam,ExamPlacement>`
      Returns:
        true if the constraint is hard

    - #### isAvailable

          public boolean isAvailable(ExamPeriod period)

      True if the student is available (for examination timetabling) during the given period
      Parameters:
        `period` - a period
      Returns:
        true if a student can attend an exam at the given period, false if otherwise

    - #### setAvailable

          public void setAvailable(int period,
                                   boolean available)

      Set whether the student is available (for examination timetabling) during the given period
      Parameters:
        `period` - a period
        `available` - true if a student can attend an exam at the given period, false if otherwise

    - #### canConflict

          public boolean canConflict(Exam ex1,
                                     Exam ex2)

      True if the given two exams can have a direct instructor conflict with this instructor, i.e., they can be placed at the same period.
      Parameters:
        `ex1` - an exam
        `ex2` - an exam
      Returns:
        `ExamStudent.isAllowDirectConflicts()` and `Exam.isAllowDirectConflicts()` for both exams