org.cpsolver.coursett.neighbourhoods

## Class RoomSwap

- java.lang.Object
- - org.cpsolver.ifs.algorithms.neighbourhoods.RandomSwapMove<Lecture,Placement>
  - - org.cpsolver.coursett.neighbourhoods.RoomSwap

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

      public class RoomSwap
      extends RandomSwapMove<Lecture,Placement>

  Try to assign a class with a new room. A class is selected randomly, a different room is randomly selected for the class -- the class is assigned into the new room. If the room is used or there is some other conflict, it tries to resolve these conflicts by assigning conflicting classes to other rooms as well.
  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 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/interfaces inherited from class org.cpsolver.ifs.algorithms.neighbourhoods.RandomSwapMove

      `RandomSwapMove.SwapNeighbour`

  - ### Field Summary

    - ### Fields inherited from class org.cpsolver.ifs.algorithms.neighbourhoods.RandomSwapMove

      `iHC, iMaxAttempts, iTimeLimit`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RoomSwap(DataProperties config)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `init(Solver<Lecture,Placement> solver)` Criterion initialization
    `Double` | `resolve(Solution<Lecture,Placement> solution, double total, long startTime, Map<Lecture,Placement> assignments, List<Placement> conflicts, int index)` Try to resolve given conflicts.
    `Neighbour<Lecture,Placement>` | `selectNeighbour(Solution<Lecture,Placement> solution)` select a neighbour of a given solution

    - ### Methods inherited from class org.cpsolver.ifs.algorithms.neighbourhoods.RandomSwapMove

      `isTimeLimitReached, setHcMode`

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

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

- - ### Constructor Detail

    - #### RoomSwap

          public RoomSwap(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 `RandomSwapMove<Lecture,Placement>`
      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 `RandomSwapMove<Lecture,Placement>`
      Parameters:
        `solution` - given solution
      Returns:
        a neighbour assignment

    - #### resolve

          public Double resolve(Solution<Lecture,Placement> solution,
                                double total,
                                long startTime,
                                Map<Lecture,Placement> assignments,
                                List<Placement> conflicts,
                                int index)

      Description copied from class: `RandomSwapMove`
      Try to resolve given conflicts. For each conflicting variable it tries to find a value with no conflict that is compatible with some other assignment of the other conflicting variables.
      Overrides:
        `resolve` in class `RandomSwapMove<Lecture,Placement>`
      Parameters:
        `solution` - current solution
        `total` - original value of the current solution
        `startTime` - starting time
        `assignments` - re-assignments to be made
        `conflicts` - list of conflicts to resolve
        `index` - index in the list of conflicts
      Returns:
        value of the modified solution, null if cannot be resolved