net.sf.cpsolver.studentsct.constraint

## Class LinkedSections

- java.lang.Object
- - net.sf.cpsolver.studentsct.constraint.LinkedSections

-     public class LinkedSections
      extends Object

  Linked sections are sections (of different courses) that should be attended by the same students. If there are multiple sections of the same subpart, one or can be chosen randomly. For instance, if section A1 (of a course A) and section B1 (of a course B) are linked, a student requesting both courses must attend A1 if and only if he also attends B1.
  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/.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `LinkedSections.Assignment` Interface to be able to provide a custom assignment to `computeConflicts(Enrollment, Assignment, ConflictHandler)`
    `static interface` | `LinkedSections.ConflictHandler` Helper interface to process conflicts in `computeConflicts(Enrollment, Assignment, ConflictHandler)`
    `static class` | `LinkedSections.CurrentAssignment` Current assignment -- default for `computeConflicts(Enrollment, Assignment, ConflictHandler)`
    `class` | `LinkedSections.LinkedSectionsConstraint` Linked sections constraint -- to be created for each student that requests two or more offerings of this link

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LinkedSections(Collection<Section> sections)` Constructor
    `LinkedSections(Section... sections)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `computeConflicts(Enrollment enrollment, LinkedSections.Assignment assignment, LinkedSections.ConflictHandler conflicts)` Compute conflicting enrollments.
    `void` | `computeConflicts(Enrollment enrollment, LinkedSections.ConflictHandler conflicts)` Compute conflicting enrollments.
    `void` | `createConstraints()` Create linked-section constraints for this link.
    `Set<Offering>` | `getOfferings()` Return offerings of this link
    `Set<Section>` | `getSections(Subpart subpart)` Return section (or sections) of a subpart of this link
    `Set<Subpart>` | `getSubparts(Offering offering)` Return subpart (or subparts) of an offering of this link
    `Enrollment` | `inConflict(Enrollment enrollment)` Check for conflicts.
    `Enrollment` | `inConflict(Enrollment enrollment, LinkedSections.Assignment assignment)` Check for conflicts.
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### LinkedSections

          public LinkedSections(Section... sections)

      Constructor
      Parameters:
        `sections` - sections that are to be linked

    - #### LinkedSections

          public LinkedSections(Collection<Section> sections)

      Constructor
      Parameters:
        `sections` - sections that are to be linked

  - ### Method Detail

    - #### getOfferings

          public Set<Offering> getOfferings()

      Return offerings of this link

    - #### getSubparts

          public Set<Subpart> getSubparts(Offering offering)

      Return subpart (or subparts) of an offering of this link

    - #### getSections

          public Set<Section> getSections(Subpart subpart)

      Return section (or sections) of a subpart of this link

    - #### createConstraints

          public void createConstraints()

      Create linked-section constraints for this link. A constraint is created for each student that has two or more offerings of this link.

    - #### computeConflicts

          public void computeConflicts(Enrollment enrollment,
                                       LinkedSections.ConflictHandler conflicts)

      Compute conflicting enrollments. If the given enrollment contains sections of this link (one for each subpart in `getSubparts(Offering)`), another assignment of this student is in a conflict, if it does not contain the appropriate sections from `getSubparts(Offering)` and `getSections(Subpart)`.
      Parameters:
        `enrollment` - given enrollment
        `conflicts` - found conflicts are given to this interface, see `LinkedSections.ConflictHandler.onConflict(Enrollment)`

    - #### computeConflicts

          public void computeConflicts(Enrollment enrollment,
                                       LinkedSections.Assignment assignment,
                                       LinkedSections.ConflictHandler conflicts)

      Compute conflicting enrollments. If the given enrollment contains sections of this link (one for each subpart in `getSubparts(Offering)`), another assignment of this student is in a conflict, if it does not contain the appropriate sections from `getSubparts(Offering)` and `getSections(Subpart)`.
      Parameters:
        `enrollment` - given enrollment
        `assignment` - custom assignment
        `conflicts` - found conflicts are given to this interface, see `LinkedSections.ConflictHandler.onConflict(Enrollment)`

    - #### inConflict

          public Enrollment inConflict(Enrollment enrollment)

      Check for conflicts. If the given enrollment contains sections of this link (one for each subpart in `getSubparts(Offering)`), another assignment of this student is in a conflict, if it does not contain the appropriate sections from `getSubparts(Offering)` and `getSections(Subpart)`.
      Parameters:
        `enrollment` - given enrollment
      Returns:
        conflicting enrollment

    - #### inConflict

          public Enrollment inConflict(Enrollment enrollment,
                                       LinkedSections.Assignment assignment)

      Check for conflicts. If the given enrollment contains sections of this link (one for each subpart in `getSubparts(Offering)`), another assignment of this student is in a conflict, if it does not contain the appropriate sections from `getSubparts(Offering)` and `getSections(Subpart)`.
      Parameters:
        `enrollment` - given enrollment
        `assignment` - custom assignment
      Returns:
        conflicting enrollment

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`