org.cpsolver.coursett.sectioning

## Class RandomStudentSwap

- java.lang.Object
- - org.cpsolver.coursett.sectioning.StudentSwapGenerator
  - - org.cpsolver.coursett.sectioning.RandomStudentSwap

- All Implemented Interfaces:
    HillClimberSelection, NeighbourSelection<Lecture,Placement>

      public class RandomStudentSwap
      extends StudentSwapGenerator
      implements HillClimberSelection

  A neihbourhood selection that attempts to swap a student between alternative sections of a course. To be used with the Hill Climber (HC), Great Deluge (GD), or Simulated Annealing (SA) algorithms by adding this class in the AdditionalNeighbours property. Based on `StudentSwapGenerator`, but making a random selection of a lecture and of a student. The selection is only available/enabled when the solver is using a single thread (`Solver.hasSingleSolution()` is true) as student class assignments are not included in the solution.
  Version:
    CourseTT 1.4 (University Course Timetabling)
    Copyright (C) 2024 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
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `iEnabled`
    `protected boolean` | `iHC`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RandomStudentSwap(DataProperties config)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `init(Solver<Lecture,Placement> solver)` Criterion initialization
    `Neighbour<Lecture,Placement>` | `selectNeighbour(Solution<Lecture,Placement> solution)` select a neighbour of a given solution
    `void` | `setHcMode(boolean hcMode)` True if employed by a hill climber, e.g., worsening moves may be skipped.

    - ### Methods inherited from class org.cpsolver.coursett.sectioning.StudentSwapGenerator

      `generateSwap, selectNeighbour`

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

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

- - ### Field Detail

    - #### iHC

          protected boolean iHC

    - #### iEnabled

          protected boolean iEnabled

  - ### Constructor Detail

    - #### RandomStudentSwap

          public RandomStudentSwap(DataProperties config)

  - ### Method Detail

    - #### init

          public void init(Solver<Lecture,Placement> solver)

      Description copied from interface: `NeighbourSelection`
      Criterion initialization
      Specified by:
        `init` in interface `NeighbourSelection<Lecture,Placement>`
      Overrides:
        `init` in class `StudentSwapGenerator`
      Parameters:
        `solver` - current solver

    - #### selectNeighbour

          public Neighbour<Lecture,Placement> selectNeighbour(Solution<Lecture,Placement> solution)

      Description copied from interface: `NeighbourSelection`
      select a neighbour of a given solution
      Specified by:
        `selectNeighbour` in interface `NeighbourSelection<Lecture,Placement>`
      Overrides:
        `selectNeighbour` in class `StudentSwapGenerator`
      Parameters:
        `solution` - given solution
      Returns:
        a neighbour assignment

    - #### setHcMode

          public void setHcMode(boolean hcMode)

      Description copied from interface: `HillClimberSelection`
      True if employed by a hill climber, e.g., worsening moves may be skipped.
      Specified by:
        `setHcMode` in interface `HillClimberSelection`
      Parameters:
        `hcMode` - true if used by a hill climber (worsening moves are automatically discarded)