org.cpsolver.instructor.model

## Class Section

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

-     public class Section
      extends Object

  Section. A section (part of a teaching request that needs an instructor) has an id, a name, a time, a room. A section may be allowed to overlap in time (in which case the overlapping time is to be minimized) and/or marked as common. This is, for instance, to be able to ensure that all assignments of a course that are given to a single instructor share the same lecture.
  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/.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Section(long id, String externalId, String type, String name, TimeLocation time, String room, boolean allowOverlap, boolean common)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `countBackToBacks(Collection<Section> sections, double diffRoomWeight, double diffTypeWeight)` Check if this section is back-to-back with some other section in the list
    `double` | `countSameDays(Collection<Section> sections, double diffRoomWeight, double diffTypeWeight)` Check if this section has the same days with some other section in the list
    `double` | `countSameRooms(Collection<Section> sections, double diffTypeWeight)` Check if this section has the same room with some other section in the list
    `boolean` | `equals(Object o)`
    `String` | `getExternalId()` Section external unique id that was provided in the constructor
    `String` | `getRoom()` Section room (or rooms)
    `Long` | `getSectionId()` Section unique id that was provided in the constructor
    `String` | `getSectionName()` Section name that was provided in the constructor
    `String` | `getSectionType()` Section instructional type (e.g., Lecture) that was provided in the constructor
    `TimeLocation` | `getTime()` Section time that was provided in the constructor
    `String` | `getTimeName(boolean useAmPm)` Format the time statement
    `int` | `hashCode()`
    `boolean` | `hasRoom()` Has section room filled in?
    `boolean` | `hasSectionType()` Has section type filled in?
    `boolean` | `hasTime()` Has section time filled in?
    `boolean` | `isAllowOverlap()` Are time overlaps with other sections and with prohibited time preferences allowed?
    `boolean` | `isBackToBack(Section section)` Check if this section is back to back with some other section
    `boolean` | `isCommon()` Is common part of the course (e.g., a lecture)?
    `boolean` | `isOverlapping(Collection<Section> sections)` Check if this section overlaps in time with at least one of the given sections
    `boolean` | `isOverlapping(Section section)` Check if this section overlaps in time with some other section
    `boolean` | `isSameRoom(Section section)` Check if this section is placed in the same room as the other section
    `boolean` | `isSameSectionType(Section section)` Check if this section has the same instructional type as the other section
    `double` | `percSameDays(Section section)` Check if this section has the same days as some other section
    `int` | `share(Collection<Section> sections)` If this section can overlap in time with any of the given section, compute the number of overlapping time slots
    `int` | `share(Section section)` If this section can overlap in time with the other section, compute the number of overlapping time slots
    `int` | `share(TimeLocation time)` Compute the number of overlapping time slots between this section and the given time
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### Section

          public Section(long id,
                         String externalId,
                         String type,
                         String name,
                         TimeLocation time,
                         String room,
                         boolean allowOverlap,
                         boolean common)

      Constructor
      Parameters:
        `id` - section unique id
        `externalId` - section external id
        `type` - instructional type
        `name` - section name
        `time` - section time assignment
        `room` - section room assignment
        `allowOverlap` - can this section overlap with some other section
        `common` - is this a common part of the course

  - ### Method Detail

    - #### getSectionId

          public Long getSectionId()

      Section unique id that was provided in the constructor
      Returns:
        section unique id

    - #### getExternalId

          public String getExternalId()

      Section external unique id that was provided in the constructor
      Returns:
        section external id

    - #### getSectionType

          public String getSectionType()

      Section instructional type (e.g., Lecture) that was provided in the constructor
      Returns:
        section instructional type

    - #### hasSectionType

          public boolean hasSectionType()

      Has section type filled in?
      Returns:
        true, if there is a section instructional type filled in

    - #### getSectionName

          public String getSectionName()

      Section name that was provided in the constructor
      Returns:
        section name

    - #### getTime

          public TimeLocation getTime()

      Section time that was provided in the constructor
      Returns:
        section time

    - #### hasTime

          public boolean hasTime()

      Has section time filled in?
      Returns:
        true if section is assigned in time

    - #### getRoom

          public String getRoom()

      Section room (or rooms)
      Returns:
        section room

    - #### hasRoom

          public boolean hasRoom()

      Has section room filled in?
      Returns:
        true if section is assigned in space

    - #### isAllowOverlap

          public boolean isAllowOverlap()

      Are time overlaps with other sections and with prohibited time preferences allowed? If true, the number of overlapping time slots should be minimized instead.
      Returns:
        true if other sections can overlap with this section or if the student can teach this section even when he/she is unavailable

    - #### isCommon

          public boolean isCommon()

      Is common part of the course (e.g., a lecture)? It is possible to either require all assignments of a course that are given to the same instructor to have to share the common part (when `TeachingRequest.getSameCommonPreference()` is true) or to minimize the different sections that are not shared among all the assignments (using `DifferentLecture` criterion and `TeachingRequest.nrSameLectures(TeachingRequest)`).
      Returns:
        true if this section forms a common part of the course

    - #### isOverlapping

          public boolean isOverlapping(Section section)

      Check if this section overlaps in time with some other section
      Parameters:
        `section` - the other section
      Returns:
        true, if neither of the two sections allow for overlap and they are assigned in overlapping times (see `TimeLocation.hasIntersection(TimeLocation)`)

    - #### isOverlapping

          public boolean isOverlapping(Collection<Section> sections)

      Check if this section overlaps in time with at least one of the given sections
      Parameters:
        `sections` - the other sections
      Returns:
        true, if there is a section among the sections that overlaps in time with this section (see `isOverlapping(Section)`)

    - #### isBackToBack

          public boolean isBackToBack(Section section)

      Check if this section is back to back with some other section
      Parameters:
        `section` - the other section
      Returns:
        true, if this section is back-to-back with the other section

    - #### percSameDays

          public double percSameDays(Section section)

      Check if this section has the same days as some other section
      Parameters:
        `section` - the other section
      Returns:
        0 if all the days are different, 1 if all the days are the same

    - #### isSameRoom

          public boolean isSameRoom(Section section)

      Check if this section is placed in the same room as the other section
      Parameters:
        `section` - the other section
      Returns:
        true, if both sections have no room or if they have the same room

    - #### isSameSectionType

          public boolean isSameSectionType(Section section)

      Check if this section has the same instructional type as the other section
      Parameters:
        `section` - the other section
      Returns:
        true, if both sections have no instructional type or if they have the same instructional type

    - #### countBackToBacks

          public double countBackToBacks(Collection<Section> sections,
                                         double diffRoomWeight,
                                         double diffTypeWeight)

      Check if this section is back-to-back with some other section in the list
      Parameters:
        `sections` - the other sections
        `diffRoomWeight` - different room penalty (should be between 1 and 0)
        `diffTypeWeight` - different instructional type penalty (should be between 1 and 0)
      Returns:
        1.0 if there is a section in the list that is back-to-back and in the same room and with the same type, 0.0 if there is no back-to-back section in the list, etc. If there are multiple back-to-back sections, the best back-to-back value is returned.

    - #### countSameDays

          public double countSameDays(Collection<Section> sections,
                                      double diffRoomWeight,
                                      double diffTypeWeight)

      Check if this section has the same days with some other section in the list
      Parameters:
        `sections` - the other sections
        `diffRoomWeight` - different room penalty (should be between 1 and 0)
        `diffTypeWeight` - different instructional type penalty (should be between 1 and 0)
      Returns:
        1.0 if there is a section in the list that has the same days and in the same room and with the same type, 0.0 if there is no same days section in the list, etc. If there are multiple same days sections, the best same days value is returned.

    - #### countSameRooms

          public double countSameRooms(Collection<Section> sections,
                                       double diffTypeWeight)

      Check if this section has the same room with some other section in the list
      Parameters:
        `sections` - the other sections
        `diffTypeWeight` - different instructional type penalty (should be between 1 and 0)
      Returns:
        1.0 if there is a section in the list that has the same room and with the same type, 0.0 if there is no same room section in the list, etc. If there are multiple same room sections, the best same room value is returned.

    - #### share

          public int share(Section section)

      If this section can overlap in time with the other section, compute the number of overlapping time slots
      Parameters:
        `section` - the other section
      Returns:
        number of shared days times number of shared slots (a day)

    - #### share

          public int share(TimeLocation time)

      Compute the number of overlapping time slots between this section and the given time
      Parameters:
        `time` - the given time
      Returns:
        number of shared days times number of shared slots (a day)

    - #### share

          public int share(Collection<Section> sections)

      If this section can overlap in time with any of the given section, compute the number of overlapping time slots
      Parameters:
        `sections` - the other sections
      Returns:
        number of shared days times number of shared slots (a day)

    - #### getTimeName

          public String getTimeName(boolean useAmPm)

      Format the time statement
      Parameters:
        `useAmPm` - use 12-hours or 24-hours format
      Returns:
        -

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`