net.sf.cpsolver.studentsct.reservation

## Class Reservation

- java.lang.Object
- - net.sf.cpsolver.studentsct.reservation.Reservation

- All Implemented Interfaces:
    Comparable<Reservation>
  Direct Known Subclasses:
    CourseReservation, CurriculumReservation, DummyReservation, IndividualReservation

      public abstract class Reservation
      extends Object
      implements Comparable<Reservation>

  Abstract reservation. This abstract class allow some section, courses, and other parts to be reserved to particular group of students. A reservation can be unlimited (any number of students of that particular group can attend a course, section, etc.) or with a limit (only given number of seats is reserved to the students of the particular group).
  Version:
    StudentSct 1.2 (Student Sectioning)
    Copyright (C) 2007 - 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/.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Reservation(long id, Offering offering)` Constructor

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addConfig(Config config)` Add a configuration (of the offering `getOffering()`) to this reservation
    `void` | `addSection(Section section)` Add a section (of the offering `getOffering()`) to this reservation.
    `void` | `assigned(Enrollment enrollment)` Notify reservation about an unassignment
    `abstract boolean` | `canAssignOverLimit()` True if can go over the course / config / section limit.
    `boolean` | `canEnroll(Enrollment enrollment)` True if the enrollment can be done using this configuration
    `int` | `compareTo(Reservation r)` Priority first, than restrictivity (more restrictive first), than availability (more available first), than id
    `Set<Config>` | `getConfigs()` One or more configurations on which the reservation is set (optional).
    `Set<Enrollment>` | `getEnrollments()` Enrollments assigned using this reservation
    `long` | `getId()` Reservation id
    `double` | `getLimit()` Reservation limit capped the limit cap (see `getLimitCap()`)
    `double` | `getLimitCap()` Compute limit cap (maximum number of students that can get into the offering using this reservation)
    `Offering` | `getOffering()` Instructional offering on which the reservation is set.
    `abstract int` | `getPriority()` Reservation priority (e.g., individual reservations first)
    `abstract double` | `getReservationLimit()` Reservation limit
    `double` | `getReservedAvailableSpace(Request excludeRequest)` Available reserved space
    `double` | `getRestrictivity()` Reservation restrictivity (estimated percentage of enrollments that include this reservation, 1.0 reservation on the whole offering)
    `Map<Subpart,Set<Section>>` | `getSections()` One or more sections on which the reservation is set (optional).
    `Set<Section>` | `getSections(Subpart subpart)` One or more sections on which the reservation is set (optional).
    `double` | `getUsedSpace()` Used space
    `boolean` | `isAllowOverlap()` True if holding this reservation allows a student to have attend overlapping class.
    `abstract boolean` | `isApplicable(Student student)` Returns true if the student is applicable for the reservation
    `boolean` | `isExpired()` True if the reservation is expired.
    `boolean` | `isIncluded(Enrollment enrollment)` Return true if the given enrollment meets the reservation.
    `abstract boolean` | `mustBeUsed()` If true, student must use the reservation (if applicable)
    `void` | `setExpired(boolean expired)` Set reservation expiration.
    `void` | `unassigned(Enrollment enrollment)` Notify reservation about an assignment

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

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

- - ### Constructor Detail

    - #### Reservation

          public Reservation(long id,
                             Offering offering)

      Constructor
      Parameters:
        `id` - reservation unique id
        `offering` - instructional offering on which the reservation is set

  - ### Method Detail

    - #### getId

          public long getId()

      Reservation id

    - #### getReservationLimit

          public abstract double getReservationLimit()

      Reservation limit

    - #### getPriority

          public abstract int getPriority()

      Reservation priority (e.g., individual reservations first)

    - #### isApplicable

          public abstract boolean isApplicable(Student student)

      Returns true if the student is applicable for the reservation
      Parameters:
        `student` - a student
      Returns:
        true if student can use the reservation to get into the course / configuration / section

    - #### getOffering

          public Offering getOffering()

      Instructional offering on which the reservation is set.

    - #### getConfigs

          public Set<Config> getConfigs()

      One or more configurations on which the reservation is set (optional).

    - #### addConfig

          public void addConfig(Config config)

      Add a configuration (of the offering `getOffering()`) to this reservation

    - #### getSections

          public Map<Subpart,Set<Section>> getSections()

      One or more sections on which the reservation is set (optional).

    - #### getSections

          public Set<Section> getSections(Subpart subpart)

      One or more sections on which the reservation is set (optional).

    - #### addSection

          public void addSection(Section section)

      Add a section (of the offering `getOffering()`) to this reservation. This will also add all parent sections and the appropriate configuration to the offering.

    - #### isIncluded

          public boolean isIncluded(Enrollment enrollment)

      Return true if the given enrollment meets the reservation.

    - #### canEnroll

          public boolean canEnroll(Enrollment enrollment)

      True if the enrollment can be done using this configuration

    - #### assigned

          public void assigned(Enrollment enrollment)

      Notify reservation about an unassignment

    - #### unassigned

          public void unassigned(Enrollment enrollment)

      Notify reservation about an assignment

    - #### getEnrollments

          public Set<Enrollment> getEnrollments()

      Enrollments assigned using this reservation

    - #### getUsedSpace

          public double getUsedSpace()

      Used space

    - #### getReservedAvailableSpace

          public double getReservedAvailableSpace(Request excludeRequest)

      Available reserved space
      Parameters:
        `excludeRequest` - excluding given request (if not null)

    - #### canAssignOverLimit

          public abstract boolean canAssignOverLimit()

      True if can go over the course / config / section limit. Only to be used in the online sectioning.

    - #### mustBeUsed

          public abstract boolean mustBeUsed()

      If true, student must use the reservation (if applicable)

    - #### getRestrictivity

          public double getRestrictivity()

      Reservation restrictivity (estimated percentage of enrollments that include this reservation, 1.0 reservation on the whole offering)

    - #### compareTo

          public int compareTo(Reservation r)

      Priority first, than restrictivity (more restrictive first), than availability (more available first), than id
      Specified by:
        `compareTo` in interface `Comparable<Reservation>`

    - #### getLimitCap

          public double getLimitCap()

      Compute limit cap (maximum number of students that can get into the offering using this reservation)

    - #### getLimit

          public double getLimit()

      Reservation limit capped the limit cap (see `getLimitCap()`)

    - #### isAllowOverlap

          public boolean isAllowOverlap()

      True if holding this reservation allows a student to have attend overlapping class.

    - #### setExpired

          public void setExpired(boolean expired)

      Set reservation expiration. If a reservation is expired, it works as ordinary reservation (especially the flags mutBeUsed and isAllowOverlap), except it does not block other students of getting into the offering / config / section.

    - #### isExpired

          public boolean isExpired()

      True if the reservation is expired. If a reservation is expired, it works as ordinary reservation (especially the flags mutBeUsed and isAllowOverlap), except it does not block other students of getting into the offering / config / section.