org.cpsolver.instructor.model

## Class TeachingRequest

- java.lang.Object
- - org.cpsolver.instructor.model.TeachingRequest

-     public class TeachingRequest
      extends Object

  Teaching request. A set of sections of a course to be assigned to an instructor. Each teaching request has a teaching load. The maximal teaching load of an instructor cannot be breached.
  Version:
    IFS 1.3 (Instructor Sectioning)
    Copyright (C) 2016 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` | `TeachingRequest.Variable` Single instructor assignment to this teaching request

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TeachingRequest(long requestId, int nrVariables, Course course, float load, Collection<Section> sections, int sameCoursePreference, int sameCommonPreference)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAttributePreference(Preference<Attribute> pref)` Add attribute preference
    `void` | `addInstructorPreference(Preference<Instructor> pref)` Add instructor preference
    `double` | `countBackToBacks(TeachingRequest request, double diffRoomWeight, double diffTypeWeight)` Average value of the back-to-backs between this request and the given one
    `double` | `countSameDays(TeachingRequest request, double diffRoomWeight, double diffTypeWeight)` Average value of the same days between this request and the given one
    `double` | `countSameRooms(TeachingRequest request, double diffTypeWeight)` Average value of the same rooms between this request and the given one
    `boolean` | `equals(Object o)`
    `PreferenceCombination` | `getAttributePreference(Instructor instructor)` Compute attribute preference for the given instructor
    `int` | `getAttributePreference(Instructor instructor, Attribute.Type type)` Compute attribute preference for the given instructor and attribute type
    `List<Preference<Attribute>>` | `getAttributePreferences()` Return attribute preferences for this request
    `Course` | `getCourse()` Course of the request that was provided in the constructor
    `Preference<Instructor>` | `getInstructorPreference(Instructor instructor)` Return instructor preference for the given instructor
    `List<Preference<Instructor>>` | `getInstructorPreferences()` Return instructor preferences for this request
    `float` | `getLoad()` Return teaching load of the request
    `int` | `getNrInstructors()` Get number of instructors needed
    `long` | `getRequestId()` Teaching request id that was provided in the constructor
    `double` | `getSameCommonPenalty(TeachingRequest request)` Return same common penalty of this request and the given request being assigned to the same instructor
    `int` | `getSameCommonPreference()` Whether to ensure that multiple assignments given to the same instructor share the common part.
    `double` | `getSameCoursePenalty(TeachingRequest request)` Return same course penalty of this request and the given request being assigned to the same instructor
    `int` | `getSameCoursePreference()` Preference of an instructor taking this request together with some other request of the same / different course.
    `List<Section>` | `getSections()` Sections of the request that was provided in the constructor
    `TeachingRequest.Variable` | `getVariable(int index)` Get single instructor assignment variable
    `TeachingRequest.Variable[]` | `getVariables()` Get single instructor assignment variables
    `int` | `hashCode()`
    `boolean` | `isSameCommonProhibited()` Is same common prohibited?
    `boolean` | `isSameCommonRequired()` Is same common required?
    `boolean` | `isSameCommonViolated(TeachingRequest request)` Check if this request and the given one can be assigned to the same instructor without violating the same common constraint
    `boolean` | `isSameCourseProhibited()` Is same course prohibited?
    `boolean` | `isSameCourseRequired()` Is same course required?
    `boolean` | `isSameCourseViolated(TeachingRequest request)` Check if this request and the given one can be assigned to the same instructor without violating the same course constraint
    `double` | `nrSameLectures(TeachingRequest request)` Count the number of common sections that the given request share with this request
    `boolean` | `overlaps(TeachingRequest request)` Check if this request overlaps with the given one
    `boolean` | `sameCommon(TeachingRequest request)` Check if the given request fully share the common sections with this request
    `boolean` | `sameCourse(TeachingRequest request)` Check if this request and the given request are of the same course
    `void` | `setLoad(float load)` Set teaching load of the request
    `int` | `share(TeachingRequest request)` Count the number of (allowed) overlapping time slots between this request and the given one
    `int` | `share(TimeLocation time)` Count the number of overlapping time slots between this request and the given time
    `boolean` | `shareCommon(TeachingRequest request)` Check if the given request (partially) share the common sections with this request
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### TeachingRequest

          public TeachingRequest(long requestId,
                                 int nrVariables,
                                 Course course,
                                 float load,
                                 Collection<Section> sections,
                                 int sameCoursePreference,
                                 int sameCommonPreference)

      Constructor
      Parameters:
        `requestId` - teaching request id
        `nrVariables` - number of instructors for this teaching request
        `course` - course
        `load` - teaching load
        `sections` - list of sections
        `sameCoursePreference` - same course preference
        `sameCommonPreference` - same common preference (two requests of the same course share the common part)

  - ### Method Detail

    - #### getRequestId

          public long getRequestId()

      Teaching request id that was provided in the constructor
      Returns:
        request id

    - #### getSameCoursePreference

          public int getSameCoursePreference()

      Preference of an instructor taking this request together with some other request of the same / different course.
      Returns:
        same course preference

    - #### isSameCourseRequired

          public boolean isSameCourseRequired()

      Is same course required?
      Returns:
        same course preference is required

    - #### isSameCourseProhibited

          public boolean isSameCourseProhibited()

      Is same course prohibited?
      Returns:
        same course preference is prohibited

    - #### getSameCommonPreference

          public int getSameCommonPreference()

      Whether to ensure that multiple assignments given to the same instructor share the common part. If required, all assignments of this course that are given to the same student must share the sections that are marked as common (see `Section.isCommon()`).
      Returns:
        same common preference

    - #### isSameCommonRequired

          public boolean isSameCommonRequired()

      Is same common required?
      Returns:
        same common preference is required

    - #### isSameCommonProhibited

          public boolean isSameCommonProhibited()

      Is same common prohibited?
      Returns:
        same common preference is prohibited

    - #### getVariables

          public TeachingRequest.Variable[] getVariables()

      Get single instructor assignment variables
      Returns:
        variables for this request

    - #### getVariable

          public TeachingRequest.Variable getVariable(int index)

      Get single instructor assignment variable
      Parameters:
        `index` - index of the variable
      Returns:
        variable for the index-th instructor assignment

    - #### getNrInstructors

          public int getNrInstructors()

      Get number of instructors needed
      Returns:
        number of variables for this request

    - #### getAttributePreferences

          public List<Preference<Attribute>> getAttributePreferences()

      Return attribute preferences for this request
      Returns:
        attribute preferences

    - #### addAttributePreference

          public void addAttributePreference(Preference<Attribute> pref)

      Add attribute preference
      Parameters:
        `pref` - attribute preference

    - #### getAttributePreference

          public int getAttributePreference(Instructor instructor,
                                            Attribute.Type type)

      Compute attribute preference for the given instructor and attribute type
      Parameters:
        `instructor` - an instructor
        `type` - an attribute type
      Returns:
        combined preference using `Attribute.Type.isConjunctive()` and `Attribute.Type.isRequired()` properties

    - #### getAttributePreference

          public PreferenceCombination getAttributePreference(Instructor instructor)

      Compute attribute preference for the given instructor
      Parameters:
        `instructor` - an instructor
      Returns:
        using `SumPreferenceCombination` for the preferences of each attribute type (using `getAttributePreference(Instructor, org.cpsolver.instructor.model.Attribute.Type)`)

    - #### getInstructorPreferences

          public List<Preference<Instructor>> getInstructorPreferences()

      Return instructor preferences for this request
      Returns:
        instructor preferences

    - #### addInstructorPreference

          public void addInstructorPreference(Preference<Instructor> pref)

      Add instructor preference
      Parameters:
        `pref` - instructor preference

    - #### getInstructorPreference

          public Preference<Instructor> getInstructorPreference(Instructor instructor)

      Return instructor preference for the given instructor
      Parameters:
        `instructor` - an instructor
      Returns:
        instructor preference for the given instructor

    - #### getCourse

          public Course getCourse()

      Course of the request that was provided in the constructor
      Returns:
        course of the request

    - #### getSections

          public List<Section> getSections()

      Sections of the request that was provided in the constructor
      Returns:
        sections of the request

    - #### getLoad

          public float getLoad()

      Return teaching load of the request
      Returns:
        teaching load

    - #### setLoad

          public void setLoad(float load)

      Set teaching load of the request
      Parameters:
        `load` - teaching load

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### sameCommon

          public boolean sameCommon(TeachingRequest request)

      Check if the given request fully share the common sections with this request
      Parameters:
        `request` - the other teaching request
      Returns:
        true, if all common sections of this request are also present in the other request

    - #### shareCommon

          public boolean shareCommon(TeachingRequest request)

      Check if the given request (partially) share the common sections with this request
      Parameters:
        `request` - the other teaching request
      Returns:
        true, if there is at least one common section of this request that is also present in the other request

    - #### isSameCommonViolated

          public boolean isSameCommonViolated(TeachingRequest request)

      Check if this request and the given one can be assigned to the same instructor without violating the same common constraint
      Parameters:
        `request` - the other teaching request
      Returns:
        same common constraint is violated

    - #### getSameCommonPenalty

          public double getSameCommonPenalty(TeachingRequest request)

      Return same common penalty of this request and the given request being assigned to the same instructor
      Parameters:
        `request` - the other teaching request
      Returns:
        same common penalty between the two teaching requests

    - #### nrSameLectures

          public double nrSameLectures(TeachingRequest request)

      Count the number of common sections that the given request share with this request
      Parameters:
        `request` - the other teaching request
      Returns:
        the number of shared common sections

    - #### sameCourse

          public boolean sameCourse(TeachingRequest request)

      Check if this request and the given request are of the same course
      Parameters:
        `request` - the other teaching request
      Returns:
        true, if the course of the given request is the same as the course of this request

    - #### isSameCourseViolated

          public boolean isSameCourseViolated(TeachingRequest request)

      Check if this request and the given one can be assigned to the same instructor without violating the same course constraint
      Parameters:
        `request` - the other teaching request
      Returns:
        same course constraint is violated

    - #### getSameCoursePenalty

          public double getSameCoursePenalty(TeachingRequest request)

      Return same course penalty of this request and the given request being assigned to the same instructor
      Parameters:
        `request` - the other teaching request
      Returns:
        same course penalty between the two teaching requests

    - #### overlaps

          public boolean overlaps(TeachingRequest request)

      Check if this request overlaps with the given one
      Parameters:
        `request` - the other teaching request
      Returns:
        true, if there are two sections that are overlapping in time (that are not allowed to overlap)

    - #### share

          public int share(TeachingRequest request)

      Count the number of (allowed) overlapping time slots between this request and the given one
      Parameters:
        `request` - the other teaching request
      Returns:
        the number of overlapping time slots

    - #### share

          public int share(TimeLocation time)

      Count the number of overlapping time slots between this request and the given time
      Parameters:
        `time` - a time
      Returns:
        the number of overlapping time slots

    - #### countBackToBacks

          public double countBackToBacks(TeachingRequest request,
                                         double diffRoomWeight,
                                         double diffTypeWeight)

      Average value of the back-to-backs between this request and the given one
      Parameters:
        `request` - the other teaching request
        `diffRoomWeight` - different room penalty
        `diffTypeWeight` - different instructional type penalty
      Returns:
        average value of `Section.countBackToBacks(Collection, double, double)` between the two, common sections are ignored

    - #### countSameDays

          public double countSameDays(TeachingRequest request,
                                      double diffRoomWeight,
                                      double diffTypeWeight)

      Average value of the same days between this request and the given one
      Parameters:
        `request` - the other teaching request
        `diffRoomWeight` - different room penalty
        `diffTypeWeight` - different instructional type penalty
      Returns:
        average value of `Section.countSameDays(Collection, double, double)` between the two, common sections are ignored

    - #### countSameRooms

          public double countSameRooms(TeachingRequest request,
                                       double diffTypeWeight)

      Average value of the same rooms between this request and the given one
      Parameters:
        `request` - the other teaching request
        `diffTypeWeight` - different instructional type penalty
      Returns:
        average value of `Section.countSameRooms(Collection, double)` between the two, common sections are ignored

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`