org.cpsolver.studentsct.model

## Class RequestGroup

- java.lang.Object
- - org.cpsolver.ifs.assignment.context.AbstractClassWithContext<Request,Enrollment,RequestGroup.RequestGroupContext>
  - - org.cpsolver.studentsct.model.RequestGroup

- All Implemented Interfaces:
    CanHoldContext, CanInheritContext<Request,Enrollment,RequestGroup.RequestGroupContext>, HasAssignmentContext<Request,Enrollment,RequestGroup.RequestGroupContext>

      public class RequestGroup
      extends AbstractClassWithContext<Request,Enrollment,RequestGroup.RequestGroupContext>
      implements CanInheritContext<Request,Enrollment,RequestGroup.RequestGroupContext>

  Representation of a group of students requesting the same course that should be scheduled in the same set of sections.
  Version:
    StudentSct 1.3 (Student Sectioning)
    Copyright (C) 2015 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` | `RequestGroup.RequestGroupContext`

  - ### Field Summary

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

      `sMaxSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestGroup(long id, String name, Course course)` Creates request group.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRequest(CourseRequest request)` Add course request to the group.
    `void` | `assigned(Assignment<Request,Enrollment> assignment, Enrollment enrollment)` Called when an enrollment is assigned to a request of this request group
    `RequestGroup.RequestGroupContext` | `createAssignmentContext(Assignment<Request,Enrollment> assignment)` Create a new assignment context for the given assignment.
    `boolean` | `equals(Object o)`
    `double` | `getAverageSpread(Assignment<Request,Enrollment> assignment)` Return average section spread of this group.
    `Course` | `getCourse()` Course associated with this group.
    `double` | `getEnrollmentSpread(Assignment<Request,Enrollment> assignment, Enrollment enrollment, double bestRatio, double fillRatio)` Return how much is the given enrollment similar to other enrollments of this group.
    `double` | `getEnrollmentWeight(Assignment<Request,Enrollment> assignment, Request excludeRequest)` Enrollment weight -- weight of all requests which have an enrollment that is of this request group, excluding the given one.
    `long` | `getId()` Request group id
    `Model<Request,Enrollment>` | `getModel()` Get the model.
    `String` | `getName()` Request group name
    `Set<CourseRequest>` | `getRequests()` Return the set of course requests that are associated with this group.
    `double` | `getSectionSpread(Assignment<Request,Enrollment> assignment, Section section)` Return section spread of this group.
    `double` | `getSectionWeight(Assignment<Request,Enrollment> assignment, Section section, Request excludeRequest)` Section weight -- weight of all requests which have an enrollment that is of this request group and that includes the given section, excluding the given one.
    `double` | `getTotalWeight()` Total weight (using `Request.getWeight()`) of the course requests of this group
    `int` | `hashCode()`
    `RequestGroup.RequestGroupContext` | `inheritAssignmentContext(Assignment<Request,Enrollment> assignment, RequestGroup.RequestGroupContext parentContext)` Create a new assignment context for the given assignment.
    `void` | `removeRequest(CourseRequest request)` Remove course request from the group.
    `void` | `unassigned(Assignment<Request,Enrollment> assignment, Enrollment enrollment)` Called when an enrollment is unassigned from a request of this request group

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

      `getAssignmentContextReference, getContext, getContext, setAssignmentContextReference`

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

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

- - ### Constructor Detail

    - #### RequestGroup

          public RequestGroup(long id,
                              String name,
                              Course course)

      Creates request group. Pair (id, course) must be unique.
      Parameters:
        `id` - identification of the group
        `name` - group name
        `course` - course for which the group is created (only course requests for this course can be of this group)

  - ### Method Detail

    - #### addRequest

          public void addRequest(CourseRequest request)

      Add course request to the group. It has to contain the course of this group `getCourse()`. This is done automatically by `CourseRequest.addRequestGroup(RequestGroup)`.
      Parameters:
        `request` - course request to be added to this group

    - #### removeRequest

          public void removeRequest(CourseRequest request)

      Remove course request from the group. This is done automatically by `CourseRequest.removeRequestGroup(RequestGroup)`.
      Parameters:
        `request` - course request to be removed from this group

    - #### getRequests

          public Set<CourseRequest> getRequests()

      Return the set of course requests that are associated with this group.
      Returns:
        course requests of this group

    - #### getTotalWeight

          public double getTotalWeight()

      Total weight (using `Request.getWeight()`) of the course requests of this group
      Returns:
        total weight of course requests in this group

    - #### getId

          public long getId()

      Request group id
      Returns:
        request group id

    - #### getName

          public String getName()

      Request group name
      Returns:
        request group name

    - #### getCourse

          public Course getCourse()

      Course associated with this group. Only course requests for this course can be of this group.
      Returns:
        course of this request group

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### assigned

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

      Called when an enrollment is assigned to a request of this request group

    - #### unassigned

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

      Called when an enrollment is unassigned from a request of this request group

    - #### getEnrollmentWeight

          public double getEnrollmentWeight(Assignment<Request,Enrollment> assignment,
                                            Request excludeRequest)

      Enrollment weight -- weight of all requests which have an enrollment that is of this request group, excluding the given one. See `Request.getWeight()`.
      Parameters:
        `assignment` - current assignment
        `excludeRequest` - course request to ignore, if any
      Returns:
        enrollment weight

    - #### getSectionWeight

          public double getSectionWeight(Assignment<Request,Enrollment> assignment,
                                         Section section,
                                         Request excludeRequest)

      Section weight -- weight of all requests which have an enrollment that is of this request group and that includes the given section, excluding the given one. See `Request.getWeight()`.
      Parameters:
        `assignment` - current assignment
        `section` - section in question
        `excludeRequest` - course request to ignore, if any
      Returns:
        enrollment weight

    - #### getEnrollmentSpread

          public double getEnrollmentSpread(Assignment<Request,Enrollment> assignment,
                                            Enrollment enrollment,
                                            double bestRatio,
                                            double fillRatio)

      Return how much is the given enrollment similar to other enrollments of this group.
      Parameters:
        `assignment` - current assignment
        `enrollment` - enrollment in question
        `bestRatio` - how much of the weight should be used on estimation of the enrollment potential (considering that students of this group that are not yet enrolled can take the same enrollment)
        `fillRatio` - how much of the weight should be used in estimation how well are the sections of this enrollments going to be filled (bestRatio + fillRatio <= 1.0)
      Returns:
        1.0 if all enrollments have the same sections as the given one, 0.0 if there is no match at all

    - #### getAverageSpread

          public double getAverageSpread(Assignment<Request,Enrollment> assignment)

      Return average section spread of this group. It reflects the probability of two students of this group being enrolled in the same section.
      Parameters:
        `assignment` - current assignment
      Returns:
        1.0 if all enrollments have the same sections as the given one, 0.0 if there is no match at all

    - #### getSectionSpread

          public double getSectionSpread(Assignment<Request,Enrollment> assignment,
                                         Section section)

      Return section spread of this group. It reflects the probability of two students of this group being enrolled in this section.
      Parameters:
        `assignment` - current assignment
        `section` - given section
      Returns:
        1.0 if all enrollments have the same sections as the given one, 0.0 if there is no match at all

    - #### createAssignmentContext

          public RequestGroup.RequestGroupContext 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,RequestGroup.RequestGroupContext>`
      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

    - #### inheritAssignmentContext

          public RequestGroup.RequestGroupContext inheritAssignmentContext(Assignment<Request,Enrollment> assignment,
                                                                           RequestGroup.RequestGroupContext parentContext)

      Description copied from interface: `CanInheritContext`
      Create a new assignment context for the given assignment. This method can be used to clone the parent context if desired.
      Specified by:
        `inheritAssignmentContext` in interface `CanInheritContext<Request,Enrollment,RequestGroup.RequestGroupContext>`
      Parameters:
        `assignment` - an assignment for which there needs to be an assignment context
        `parentContext` - context of the parent assignment
      Returns:
        a new instance of the assignment context, filled according to the given assignment

    - #### getModel

          public Model<Request,Enrollment> getModel()

      Description copied from class: `AbstractClassWithContext`
      Get the model. This is used to create an assignment context if needed.
      Specified by:
        `getModel` in class `AbstractClassWithContext<Request,Enrollment,RequestGroup.RequestGroupContext>`
      Returns:
        model