org.cpsolver.studentsct.model

## Class FreeTimeRequest

- java.lang.Object
- - org.cpsolver.ifs.model.Variable<V,T>
  - - org.cpsolver.ifs.assignment.context.VariableWithContext<Request,Enrollment,Request.RequestContext>
    - - org.cpsolver.studentsct.model.Request
      - - org.cpsolver.studentsct.model.FreeTimeRequest

- All Implemented Interfaces:
    Comparable<Request>, CanHoldContext, HasAssignmentContext<Request,Enrollment,Request.RequestContext>, SctAssignment

      public class FreeTimeRequest
      extends Request
      implements SctAssignment

  Representation of a request of a student for free time. This class directly implements `SctAssignment` API, with the appropriate free time.
  Version:
    StudentSct 1.3 (Student Sectioning)
    Copyright (C) 2007 - 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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `FreeTimeRequest.FreeTimeRequestContext`

    - ### Nested classes/interfaces inherited from class org.cpsolver.studentsct.model.Request

      `Request.RequestContext, Request.RequestPriority`

  - ### Field Summary

    - ### Fields inherited from class org.cpsolver.studentsct.model.Request

      `sCacheValues`

    - ### Fields inherited from class org.cpsolver.ifs.model.Variable

      `iIndex, iValue`

    - ### Fields inherited from interface org.cpsolver.ifs.assignment.context.CanHoldContext

      `sMaxSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FreeTimeRequest(long id, int priority, boolean alternative, Student student, TimeLocation time)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assigned(Assignment<Request,Enrollment> assignment, Enrollment enrollment)` Enrollment with this assignment was assigned to a `Request`.
    `int` | `compareById(SctAssignment a)` Sections first, then by `Request.getId()`
    `List<Enrollment>` | `computeEnrollments(Assignment<Request,Enrollment> assignment)` Create all possible enrollments of this request -- there is only one possible enrollment: `createEnrollment()`
    `Request.RequestContext` | `createAssignmentContext(Assignment<Request,Enrollment> assignment)` Create a new assignment context for the given assignment.
    `Enrollment` | `createEnrollment()` Create enrollment of this request
    `boolean` | `equals(Object o)`
    `double` | `getBound()` Estimated bound for this request
    `Set<Enrollment>` | `getEnrollments(Assignment<Request,Enrollment> assignment)` Return the list of assigned enrollments that contains this assignment.
    `float` | `getMinCredit()` Smallest credit provided by this request
    `String` | `getName()` Request name: A for alternative, 1 + priority, Free Time, long name of requested time
    `int` | `getNrRooms()` Assignment API: free time request has no rooms
    `Request.RequestPriority` | `getRequestPriority()` Importance of the request.
    `List<RoomLocation>` | `getRooms()` Assignment API: free time request has no rooms
    `TimeLocation` | `getTime()` Return requested time to be free
    `int` | `hashCode()`
    `boolean` | `isAllowOverlap()` Free time request generally allow overlaps.
    `boolean` | `isOverlapping(SctAssignment assignment)` True, if this assignment is overlapping in time and space with the given assignment.
    `boolean` | `isOverlapping(Set<? extends SctAssignment> assignments)` True, if this assignment is overlapping in time and space with the given set of assignments.
    `String` | `toString()`
    `void` | `unassigned(Assignment<Request,Enrollment> assignment, Enrollment enrollment)` Enrollment with this assignment was unassigned from a `Request`.

    - ### Methods inherited from class org.cpsolver.studentsct.model.Request

      `compareTo, getId, getPriority, getStudent, getWeight, hasChildren, hasCourse, hasSelection, isAlternative, isAssigned, isCritical, isMPP, setPriority, setWeight, values, variableAssigned, variableUnassigned`

    - ### Methods inherited from class org.cpsolver.ifs.assignment.context.VariableWithContext

      `getAssignmentContextReference, getContext, getContext, setAssignmentContextReference, setModel`

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

      `addContstraint, addVariableListener, assign, constraints, constraintVariables, getAssignment, getAssignment, getAssignments, getBestAssignment, getBestAssignmentIteration, getDescription, getExtra, getIndex, getInitialAssignment, getLastIteration, getModel, getVariableListeners, hardConstraints, hasAssignment, hasAssignment, hasInitialAssignment, hasValues, removeContstraint, removeInitialValue, removeValue, removeVariableListener, setAssignment, setBestAssignment, setExtra, setIndex, setInitialAssignment, setLastIteration, setValues, softConstraints, unassign, values`

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

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

    - ### Methods inherited from interface org.cpsolver.studentsct.model.SctAssignment

      `getId`

- - ### Constructor Detail

    - #### FreeTimeRequest

          public FreeTimeRequest(long id,
                                 int priority,
                                 boolean alternative,
                                 Student student,
                                 TimeLocation time)

      Constructor
      Parameters:
        `id` - request unique id
        `priority` - request priority
        `alternative` - true if the request is alternative (alternative request can be assigned instead of a non-alternative course requests, if it is left unassigned)
        `student` - appropriate student
        `time` - appropriate time location that is requested to be free

  - ### Method Detail

    - #### getTime

          public TimeLocation getTime()

      Return requested time to be free
      Specified by:
        `getTime` in interface `SctAssignment`
      Returns:
        time assignment

    - #### getNrRooms

          public int getNrRooms()

      Assignment API: free time request has no rooms
      Specified by:
        `getNrRooms` in interface `SctAssignment`
      Returns:
        number of rooms in which a section meets

    - #### getRooms

          public List<RoomLocation> getRooms()

      Assignment API: free time request has no rooms
      Specified by:
        `getRooms` in interface `SctAssignment`
      Returns:
        list of `RoomLocation`

    - #### isOverlapping

          public boolean isOverlapping(SctAssignment assignment)

      True, if this assignment is overlapping in time and space with the given assignment.
      Specified by:
        `isOverlapping` in interface `SctAssignment`
      Parameters:
        `assignment` - another assignment
      Returns:
        true if there is an overlap

    - #### isOverlapping

          public boolean isOverlapping(Set<? extends SctAssignment> assignments)

      True, if this assignment is overlapping in time and space with the given set of assignments.
      Specified by:
        `isOverlapping` in interface `SctAssignment`
      Parameters:
        `assignments` - a set of assignments
      Returns:
        true if one of them overlaps

    - #### createEnrollment

          public Enrollment createEnrollment()

      Create enrollment of this request
      Returns:
        created enrollment

    - #### computeEnrollments

          public List<Enrollment> computeEnrollments(Assignment<Request,Enrollment> assignment)

      Create all possible enrollments of this request -- there is only one possible enrollment: `createEnrollment()`
      Specified by:
        `computeEnrollments` in class `Request`
      Parameters:
        `assignment` - current assignment
      Returns:
        list of all enrollments

    - #### assigned

          public void assigned(Assignment<Request,Enrollment> assignment,
                               Enrollment enrollment)

      Enrollment with this assignment was assigned to a `Request`.
      Specified by:
        `assigned` in interface `SctAssignment`
      Parameters:
        `assignment` - current assignment
        `enrollment` - an enrollment that was just assigned

    - #### unassigned

          public void unassigned(Assignment<Request,Enrollment> assignment,
                                 Enrollment enrollment)

      Enrollment with this assignment was unassigned from a `Request`.
      Specified by:
        `unassigned` in interface `SctAssignment`
      Parameters:
        `assignment` - current assignment
        `enrollment` - an enrollment that was just unassigned

    - #### getEnrollments

          public Set<Enrollment> getEnrollments(Assignment<Request,Enrollment> assignment)

      Return the list of assigned enrollments that contains this assignment.
      Specified by:
        `getEnrollments` in interface `SctAssignment`
      Parameters:
        `assignment` - current assignments
      Returns:
        a list of assigned enrollments (of this request) that contains this assignment

    - #### getName

          public String getName()

      Request name: A for alternative, 1 + priority, Free Time, long name of requested time
      Overrides:
        `getName` in class `Variable<Request,Enrollment>`
      Returns:
        variable name

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Variable<Request,Enrollment>`

    - #### getBound

          public double getBound()

      Estimated bound for this request
      Specified by:
        `getBound` in class `Request`
      Returns:
        uppper bound

    - #### isAllowOverlap

          public boolean isAllowOverlap()

      Free time request generally allow overlaps.
      Specified by:
        `isAllowOverlap` in interface `SctAssignment`
      Returns:
        true, if overlaps are allowed

    - #### compareById

          public int compareById(SctAssignment a)

      Sections first, then by `Request.getId()`
      Specified by:
        `compareById` in interface `SctAssignment`
      Parameters:
        `a` - another section assignment
      Returns:
        comparison

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Request`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Request`

    - #### createAssignmentContext

          public Request.RequestContext createAssignmentContext(Assignment<Request,Enrollment> assignment)

      Description copied from interface: `HasAssignmentContext`
      Create a new assignment context for the given assignment. If there are already some variables assigned in the value, the method should make sure that the context is appropriately initialized.
      Specified by:
        `createAssignmentContext` in interface `HasAssignmentContext<Request,Enrollment,Request.RequestContext>`
      Overrides:
        `createAssignmentContext` in class `Request`
      Parameters:
        `assignment` - an assignment for which there needs to be an assignment context
      Returns:
        a new instance of the assignment context, filled according to the given assignment

    - #### getMinCredit

          public float getMinCredit()

      Description copied from class: `Request`
      Smallest credit provided by this request
      Specified by:
        `getMinCredit` in class `Request`

    - #### getRequestPriority

          public Request.RequestPriority getRequestPriority()

      Description copied from class: `Request`
      Importance of the request. Higher priority requests are assigned before lower priority requests.
      Specified by:
        `getRequestPriority` in class `Request`