org.cpsolver.coursett.sectioning

## Class StudentSwap

- java.lang.Object
- - org.cpsolver.coursett.sectioning.StudentSwap

- All Implemented Interfaces:
    StudentMove, Neighbour<Lecture,Placement>

      public class StudentSwap
      extends Object
      implements StudentMove

  Student swap move. Two students of the same offering are swapped between each other or a student is given some other (alternative) enrollment into the given offering.
  Version:
    CourseTT 1.3 (University Course Timetabling)
    Copyright (C) 2017 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

- - ### Field Summary

    - ### Fields inherited from interface org.cpsolver.coursett.sectioning.StudentMove

      `sEps`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StudentSwap(TimetableModel model, Assignment<Lecture,Placement> assignment, Student student, Collection<Lecture> lectures)` Move a student into some other lectures of the offering.
    `StudentSwap(TimetableModel model, Assignment<Lecture,Placement> assignment, Student firstStudent, Student secondStudent, Long offeringId)` Create a swap of two students of an offering.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assign(Assignment<Lecture,Placement> assignment, long iteration)` Perform assignment
    `Map<Lecture,Placement>` | `assignments()` Return assignments to be done.
    `protected void` | `decJenrl(Assignment<Lecture,Placement> assignment, Student student, Lecture l1, Lecture l2)` Decrement `JenrlConstraint` between the given two classes by the given student
    `double` | `getJenrConflictWeight(List<StudentConflict> criteria, Student student, Placement p1, Placement p2)` Compute student conflict weigth between two classes.
    `double` | `group(List<StudentConflict> criteria, Assignment<Lecture,Placement> assignment)` Student group weight change
    `protected void` | `incJenrl(Assignment<Lecture,Placement> assignment, Student student, Lecture l1, Lecture l2)` Increment `JenrlConstraint` between the given two classes by the given student
    `protected boolean` | `initSwap(Assignment<Lecture,Placement> assignment, Long offeringId)` Compute student swap and its validity
    `boolean` | `isAllowed()` Is the change valid / allowed?
    `String` | `toString()`
    `double` | `value(Assignment<Lecture,Placement> assignment)` Difference in the evaluation function, if this neighnour is assigned.
    `double` | `value(List<StudentConflict> criteria, Assignment<Lecture,Placement> assignment)` Student conflict weight change

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

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

- - ### Constructor Detail

    - #### StudentSwap

          public StudentSwap(TimetableModel model,
                             Assignment<Lecture,Placement> assignment,
                             Student firstStudent,
                             Student secondStudent,
                             Long offeringId)

      Create a swap of two students of an offering.

    - #### StudentSwap

          public StudentSwap(TimetableModel model,
                             Assignment<Lecture,Placement> assignment,
                             Student student,
                             Collection<Lecture> lectures)

      Move a student into some other lectures of the offering.

  - ### Method Detail

    - #### initSwap

          protected boolean initSwap(Assignment<Lecture,Placement> assignment,
                                     Long offeringId)

      Compute student swap and its validity

    - #### decJenrl

          protected void decJenrl(Assignment<Lecture,Placement> assignment,
                                  Student student,
                                  Lecture l1,
                                  Lecture l2)

      Decrement `JenrlConstraint` between the given two classes by the given student

    - #### incJenrl

          protected void incJenrl(Assignment<Lecture,Placement> assignment,
                                  Student student,
                                  Lecture l1,
                                  Lecture l2)

      Increment `JenrlConstraint` between the given two classes by the given student

    - #### getJenrConflictWeight

          public double getJenrConflictWeight(List<StudentConflict> criteria,
                                              Student student,
                                              Placement p1,
                                              Placement p2)

      Compute student conflict weigth between two classes.

    - #### value

          public double value(Assignment<Lecture,Placement> assignment)

      Description copied from interface: `Neighbour`
      Difference in the evaluation function, if this neighnour is assigned.
      Specified by:
        `value` in interface `Neighbour<Lecture,Placement>`
      Parameters:
        `assignment` - current assignment
      Returns:
        difference in the solution value when assigned

    - #### value

          public double value(List<StudentConflict> criteria,
                              Assignment<Lecture,Placement> assignment)

      Description copied from interface: `StudentMove`
      Student conflict weight change
      Specified by:
        `value` in interface `StudentMove`

    - #### assign

          public void assign(Assignment<Lecture,Placement> assignment,
                             long iteration)

      Description copied from interface: `Neighbour`
      Perform assignment
      Specified by:
        `assign` in interface `Neighbour<Lecture,Placement>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration

    - #### isAllowed

          public boolean isAllowed()

      Description copied from interface: `StudentMove`
      Is the change valid / allowed?
      Specified by:
        `isAllowed` in interface `StudentMove`

    - #### assignments

          public Map<Lecture,Placement> assignments()

      Description copied from interface: `Neighbour`
      Return assignments to be done.
      Specified by:
        `assignments` in interface `Neighbour<Lecture,Placement>`
      Returns:
        list of assignments (including unassignments) of this neighbour

    - #### group

          public double group(List<StudentConflict> criteria,
                              Assignment<Lecture,Placement> assignment)

      Description copied from interface: `StudentMove`
      Student group weight change
      Specified by:
        `group` in interface `StudentMove`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`