org.cpsolver.studentsct.model

## Class Request

- 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

- All Implemented Interfaces:
    Comparable<Request>, CanHoldContext, HasAssignmentContext<Request,Enrollment,Request.RequestContext>
  Direct Known Subclasses:
    CourseRequest, FreeTimeRequest

      public abstract class Request
      extends VariableWithContext<Request,Enrollment,Request.RequestContext>

  Representation of a request of a student for a course(s) or a free time. This can be either `CourseRequest` or `FreeTimeRequest`. Each request contains id, priority, weight, and a student. A request can be also marked as alternative.
  For each student, all non-alternative requests should be satisfied (an enrollment is assigned to a request). If not, an alternative request can be assigned instead of a non-alternative course request. In the case when only one of two requests can be assigned, the one with the lowest priority is preferred.
  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` | `Request.RequestContext`
    `static class` | `Request.RequestPriority` Importance of the request for the student to progress towards his/her degree.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Request.RequestPriority` | `iRequestPriority`
    `static boolean` | `sCacheValues` True means that method `Variable.values()` will cache its results.

    - ### 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
    `Request(long id, int priority, boolean alternative, Student student)` Constructor

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(Request r)` Compare to requests, non-alternative requests go first, otherwise use priority (a request with lower priority goes first)
    `abstract List<Enrollment>` | `computeEnrollments(Assignment<Request,Enrollment> assignment)` Compute available enrollments
    `Request.RequestContext` | `createAssignmentContext(Assignment<Request,Enrollment> assignment)` Create a new assignment context for the given assignment.
    `boolean` | `equals(Object o)`
    `abstract double` | `getBound()` Get bound, i.e., the value of the best possible enrollment
    `long` | `getId()` Request id
    `abstract float` | `getMinCredit()` Smallest credit provided by this request
    `int` | `getPriority()` Request priority -- if there is a choice, request with lower priority is more preferred to be assigned
    `Request.RequestPriority` | `getRequestPriority()` Importance of the request.
    `Student` | `getStudent()` Student to which this request belongs
    `double` | `getWeight()` Request weight, set by default to 1.0, defines the amount of space which will be taken in the section by this request.
    `boolean` | `hasChildren()` Check if this request is `CourseRequest` and a parent of some other course
    `boolean` | `hasCourse(Course course)` Check if this request is `CourseRequest` and contains the given course.
    `int` | `hashCode()`
    `boolean` | `hasSelection()` Return true if this request has any selection
    `boolean` | `isAlternative()` True, if the request is alternative (alternative request can be assigned instead of a non-alternative course requests, if it is left unassigned)
    `boolean` | `isAssigned(Assignment<Request,Enrollment> assignment)` Return true if request is assigned.
    `boolean` | `isCritical()` Deprecated.
    `boolean` | `isMPP()` Return true if this request can track MPP
    `void` | `setPriority(int priority)` Set request priority
    `void` | `setRequestPriority(Request.RequestPriority priority)` Importance of the request.
    `void` | `setWeight(double weight)` Set request weight.
    `List<Enrollment>` | `values(Assignment<Request,Enrollment> assignment)` Domain of this variable -- list of available enrollments.
    `void` | `variableAssigned(Assignment<Request,Enrollment> assignment, long iteration, Enrollment enrollment)` Assign given enrollment to this request.
    `void` | `variableUnassigned(Assignment<Request,Enrollment> assignment, long iteration, Enrollment enrollment)` Unassign currently assigned enrollment from this request.

    - ### 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, getName, getVariableListeners, hardConstraints, hasAssignment, hasAssignment, hasInitialAssignment, hasValues, removeContstraint, removeInitialValue, removeValue, removeVariableListener, setAssignment, setBestAssignment, setExtra, setIndex, setInitialAssignment, setLastIteration, setValues, softConstraints, toString, unassign, values`

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

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

- - ### Field Detail

    - #### iRequestPriority

          protected Request.RequestPriority iRequestPriority

    - #### sCacheValues

          public static boolean sCacheValues

      True means that method `Variable.values()` will cache its results.

  - ### Constructor Detail

    - #### Request

          public Request(long id,
                         int priority,
                         boolean alternative,
                         Student student)

      Constructor
      Parameters:
        `id` - course/free time request unique id
        `priority` - request priority -- if there is a choice, request with lower priority is more preferred to be assigned
        `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` - student to which this request belongs

  - ### Method Detail

    - #### getId

          public long getId()

      Request id
      Overrides:
        `getId` in class `Variable<Request,Enrollment>`
      Returns:
        variable id

    - #### getPriority

          public int getPriority()

      Request priority -- if there is a choice, request with lower priority is more preferred to be assigned
      Returns:
        request priority

    - #### setPriority

          public void setPriority(int priority)

      Set request priority
      Parameters:
        `priority` - request priority

    - #### isAlternative

          public boolean isAlternative()

      True, if the request is alternative (alternative request can be assigned instead of a non-alternative course requests, if it is left unassigned)
      Returns:
        is alternative request

    - #### getStudent

          public Student getStudent()

      Student to which this request belongs
      Returns:
        student

    - #### compareTo

          public int compareTo(Request r)

      Compare to requests, non-alternative requests go first, otherwise use priority (a request with lower priority goes first)
      Specified by:
        `compareTo` in interface `Comparable<Request>`
      Overrides:
        `compareTo` in class `Variable<Request,Enrollment>`

    - #### computeEnrollments

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

      Compute available enrollments
      Parameters:
        `assignment` - current assignment
      Returns:
        list of all enrollments

    - #### values

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

      Domain of this variable -- list of available enrollments. Method `computeEnrollments(Assignment)` is used.
      Overrides:
        `values` in class `Variable<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment (if the domain is dependent on the current assignment)
      Returns:
        all possible values of this variable

    - #### variableAssigned

          public void variableAssigned(Assignment<Request,Enrollment> assignment,
                                       long iteration,
                                       Enrollment enrollment)

      Assign given enrollment to this request. This method also calls `SctAssignment.assigned(Assignment, Enrollment)` on for all the assignments of the enrollment.
      Overrides:
        `variableAssigned` in class `Variable<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `enrollment` - assigned value

    - #### variableUnassigned

          public void variableUnassigned(Assignment<Request,Enrollment> assignment,
                                         long iteration,
                                         Enrollment enrollment)

      Unassign currently assigned enrollment from this request. This method also calls `SctAssignment.unassigned(Assignment, Enrollment)` on for all the assignments of the current enrollment.
      Overrides:
        `variableUnassigned` in class `Variable<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `enrollment` - unassigned value

    - #### getBound

          public abstract double getBound()

      Get bound, i.e., the value of the best possible enrollment
      Returns:
        uppper bound

    - #### getWeight

          public double getWeight()

      Request weight, set by default to 1.0, defines the amount of space which will be taken in the section by this request.
      Returns:
        request weight

    - #### setWeight

          public void setWeight(double weight)

      Set request weight. It defines the amount of space which will be taken in the section by this request.
      Parameters:
        `weight` - request weight

    - #### isAssigned

          public boolean isAssigned(Assignment<Request,Enrollment> assignment)

      Return true if request is assigned.
      Parameters:
        `assignment` - current assignment
      Returns:
        true if this request is assigned

    - #### hashCode

          public int hashCode()

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

    - #### equals

          public boolean equals(Object o)

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

    - #### 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.
      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

    - #### isMPP

          public boolean isMPP()

      Return true if this request can track MPP
      Returns:
        true if the request is course request and it either has an initial enrollment or some selected choices.

    - #### hasSelection

          public boolean hasSelection()

      Return true if this request has any selection
      Returns:
        true if the request is course request and has some selected choices.

    - #### getMinCredit

          public abstract float getMinCredit()

      Smallest credit provided by this request

    - #### isCritical

          @Deprecated
          public boolean isCritical()

      Deprecated.
      Is this request critical for the student to progress towards his/her degree

    - #### hasCourse

          public boolean hasCourse(Course course)

      Check if this request is `CourseRequest` and contains the given course.

    - #### hasChildren

          public boolean hasChildren()

      Check if this request is `CourseRequest` and a parent of some other course

    - #### setRequestPriority

          public void setRequestPriority(Request.RequestPriority priority)

      Importance of the request. Higher priority requests are assigned before lower priority requests.

    - #### getRequestPriority

          public Request.RequestPriority getRequestPriority()

      Importance of the request. Higher priority requests are assigned before lower priority requests.