org.cpsolver.ifs.model

## Class SimpleNeighbour<V extends Variable<V,T>,T extends Value<V,T>>

- java.lang.Object
- - org.cpsolver.ifs.model.SimpleNeighbour<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    Neighbour<V,T>
  Direct Known Subclasses:
    ExamSimpleNeighbour

      public class SimpleNeighbour<V extends Variable<V,T>,T extends Value<V,T>>
      extends Object
      implements Neighbour<V,T>

  A neighbour consisting of a change (either assignment or unassignment) of a single variable.
  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 2006 - 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/.
  See Also:
    `NeighbourSelection`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleNeighbour(V variable, T value)` Model
    `SimpleNeighbour(V variable, T value, Set<T> conflicts)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assign(Assignment<V,T> assignment, long iteration)` Perform assignment
    `Map<V,T>` | `assignments()` Return assignments to be done.
    `T` | `getValue()` Selected value
    `V` | `getVariable()` Selected variable
    `String` | `toString()`
    `double` | `value(Assignment<V,T> assignment)` Improvement in the solution value if this neighbour is accepted.

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

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

- - ### Constructor Detail

    - #### SimpleNeighbour

          public SimpleNeighbour(V variable,
                                 T value)

      Model
      Parameters:
        `variable` - variable to be assigned
        `value` - value to be assigned to the given variable, null if the variable should be unassigned

    - #### SimpleNeighbour

          public SimpleNeighbour(V variable,
                                 T value,
                                 Set<T> conflicts)

  - ### Method Detail

    - #### getVariable

          public V getVariable()

      Selected variable
      Returns:
        a variable

    - #### getValue

          public T getValue()

      Selected value
      Returns:
        a value, null if the variable is to be unassigned

    - #### assign

          public void assign(Assignment<V,T> assignment,
                             long iteration)

      Perform assignment
      Specified by:
        `assign` in interface `Neighbour<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration

    - #### value

          public double value(Assignment<V,T> assignment)

      Improvement in the solution value if this neighbour is accepted.
      Specified by:
        `value` in interface `Neighbour<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
      Returns:
        difference in the solution value when assigned

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### assignments

          public Map<V,T> assignments()

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