org.cpsolver.ifs.model

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

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

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    Comparable<T>, AssignmentComparable<T,V,T>
  Direct Known Subclasses:
    CSPValue, Enrollment, ExamPlacement, Location, Location, Location, Placement, TeachingAssignment

      public class Value<V extends Variable<V,T>,T extends Value<V,T>>
      extends Object
      implements Comparable<T>, AssignmentComparable<T,V,T>

  Generic value.
  Every value has a notion about the variable it belongs to. It has also a unique id. By default, every Value has an integer value which is used in general heuristics, the task is than to minimimize the total value of assigned values in the solution.
  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/.
  Author:
    Tomáš Müller
  See Also:
    `Variable`, `Model`, `Solver`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Double` | `iValue` Integer value

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Value(V variable)` Constructor
    `Value(V variable, Double value)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(Assignment<V,T> assignment, T value)` Compare two values by their value
    `int` | `compareTo(T value)` Deprecated.
    `Set<T>` | `conflicts()` Deprecated.
    `Set<T>` | `conflicts(Assignment<V,T> assignment)` Returns a set of conflicting values with this value.
    `boolean` | `equals(Object o)` By default, comparison is made on unique ids
    `String` | `getDescription()` Values description -- for printing purposes
    `Object` | `getExtra()` Deprecated.
    `long` | `getId()` Unique id
    `String` | `getName()` Values name -- for printing purposes (E.g., Monday 7:30)
    `int` | `hashCode()`
    `boolean` | `isConsistent(T value)` True, if the value is consistent with the given value
    `void` | `setExtra(Object object)` Deprecated.
    `void` | `setVariable(Variable variable)` Sets the variable which this value belongs to
    `double` | `toDouble()` Deprecated.
    `double` | `toDouble(Assignment<V,T> assignment)` Double representation.
    `String` | `toString()`
    `boolean` | `valueEquals(Assignment<V,T> assignment, T value)` Comparison of two values which is based only on the value (not appropriate variable etc.).
    `boolean` | `valueEquals(T value)` Deprecated.
    `V` | `variable()` Returns the variable which this value belongs to

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

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

- - ### Field Detail

    - #### iValue

          protected Double iValue

      Integer value

  - ### Constructor Detail

    - #### Value

          public Value(V variable)

      Constructor
      Parameters:
        `variable` - variable which the value belongs to

    - #### Value

          public Value(V variable,
                       Double value)

      Constructor
      Parameters:
        `variable` - variable which the value belongs to
        `value` - integer value

  - ### Method Detail

    - #### variable

          public V variable()

      Returns the variable which this value belongs to
      Returns:
        variable of this value

    - #### setVariable

          public void setVariable(Variable variable)

      Sets the variable which this value belongs to
      Parameters:
        `variable` - variable of this value

    - #### getId

          public long getId()

      Unique id
      Returns:
        value id

    - #### getName

          public String getName()

      Values name -- for printing purposes (E.g., Monday 7:30)
      Returns:
        value name

    - #### getDescription

          public String getDescription()

      Values description -- for printing purposes
      Returns:
        value description

    - #### toDouble

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

      Double representation. This allows us to have generic optimization criteria. The task is than to minimize total value of assigned variables of a solution.
      Parameters:
        `assignment` - current assignment
      Returns:
        this value's contribution to the solution value

    - #### toDouble

          @Deprecated
          public double toDouble()

      Deprecated.
      Double representation. This allows us to have generic optimization criteria. The task is than to minimize total value of assigned variables of a solution. If the value may depend on other values of the assignment, use `toDouble(Assignment)` instead.
      Returns:
        this value's contribution to the solution value

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### valueEquals

          public boolean valueEquals(Assignment<V,T> assignment,
                                     T value)

      Comparison of two values which is based only on the value (not appropriate variable etc.). `toDouble(Assignment)` is compared by default.
      Parameters:
        `assignment` - current assignment
        `value` - a value
      Returns:
        true if the two values have the same impact on the solution value

    - #### valueEquals

          @Deprecated
          public boolean valueEquals(T value)

      Deprecated.
      Comparison of two values which is based only on the value (not appropriate variable etc.). `toDouble(Assignment)` is compared by default. Use `valueEquals(Assignment, Value)` instead.
      Parameters:
        `value` - a value
      Returns:
        true if the two values have the same impact on the solution value

    - #### compareTo

          public int compareTo(Assignment<V,T> assignment,
                               T value)

      Compare two values by their value
      Specified by:
        `compareTo` in interface `AssignmentComparable<T extends Value<V,T>,V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `value` - other instance
      Returns:
        comparison of this instance and the given one

    - #### compareTo

          @Deprecated
          public int compareTo(T value)

      Deprecated.
      Compare two values by their value. Use `compareTo(Assignment, Value)` and `ValueComparator` instead.
      Specified by:
        `compareTo` in interface `Comparable<T extends Value<V,T>>`
      Specified by:
        `compareTo` in interface `AssignmentComparable<T extends Value<V,T>,V extends Variable<V,T>,T extends Value<V,T>>`

    - #### equals

          public boolean equals(Object o)

      By default, comparison is made on unique ids
      Overrides:
        `equals` in class `Object`

    - #### getExtra

          @Deprecated
          public Object getExtra()

      Deprecated.
      Extra information to which can be used by an extension (see `Extension`). Use `ExtensionWithContext` instead.
      Returns:
        extra object

    - #### setExtra

          @Deprecated
          public void setExtra(Object object)

      Deprecated.
      Extra information to which can be used by an extension (see `Extension`). Use `ExtensionWithContext` instead.
      Parameters:
        `object` - extra object

    - #### isConsistent

          public boolean isConsistent(T value)

      True, if the value is consistent with the given value
      Parameters:
        `value` - another value (of a different variable)
      Returns:
        true if the other value is consistent with this value (there is no hard constraint which would return `Constraint.isConsistent(Value, Value)` false)

    - #### conflicts

          public Set<T> conflicts(Assignment<V,T> assignment)

      Returns a set of conflicting values with this value. When empty, the value is consistent with the existing assignment.
      Parameters:
        `assignment` - current assignment
      Returns:
        set of conflicting values

    - #### conflicts

          @Deprecated
          public Set<T> conflicts()

      Deprecated.
      Returns a set of conflicting values with this value. When empty, the value is consistent with the existing assignment. Use `conflicts(Assignment)` instead.
      Returns:
        set of conflicting values