net.sf.cpsolver.ifs.model

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

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

- All Implemented Interfaces:
    Comparable<T>
  Direct Known Subclasses:
    CSPValue, Enrollment, ExamPlacement, Location, Location, Location, Placement

      public class Value<V extends Variable<V,T>,T extends Value<V,T>>
      extends Object
      implements Comparable<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.2 (Iterative Forward Search)
    Copyright (C) 2006 - 2010 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:
    `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
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assigned(long iteration)` Notification (called by variable) that this value is assigned
    `int` | `compareTo(T value)`
    `Set<T>` | `conflicts()` Returns a set of conflicting values with this value.
    `long` | `countAssignments()` Returns the number of assignments of this value to its variable.
    `boolean` | `equals(Object o)` By default, comparison is made on unique ids
    `String` | `getDescription()` Values description -- for printing purposes
    `Object` | `getExtra()` Extra information to which can be used by an extension (see `Extension`).
    `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
    `long` | `lastAssignmentIteration()` Returns the iteration when the value was assigned at last (-1 if never).
    `long` | `lastUnassignmentIteration()` Returns the iteration when the value was unassigned at last (-1 if never).
    `void` | `setExtra(Object object)` Extra information to which can be used by an extension (see `Extension`).
    `void` | `setVariable(Variable variable)` Sets the variable which this value belongs to
    `double` | `toDouble()` Dobouble representaion.
    `String` | `toString()`
    `void` | `unassigned(long iteration)` Notification (called by variable) that this value is unassigned
    `boolean` | `valueEquals(T value)` Comparison of two values which is based only on the value (not appropriate variable etc.). toDouble() is compared by default.
    `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

    - #### setVariable

          public void setVariable(Variable variable)

      Sets the variable which this value belongs to

    - #### assigned

          public void assigned(long iteration)

      Notification (called by variable) that this value is assigned
      Parameters:
        `iteration` - current iteration

    - #### unassigned

          public void unassigned(long iteration)

      Notification (called by variable) that this value is unassigned
      Parameters:
        `iteration` - current iteration

    - #### lastAssignmentIteration

          public long lastAssignmentIteration()

      Returns the iteration when the value was assigned at last (-1 if never).

    - #### lastUnassignmentIteration

          public long lastUnassignmentIteration()

      Returns the iteration when the value was unassigned at last (-1 if never).

    - #### countAssignments

          public long countAssignments()

      Returns the number of assignments of this value to its variable.

    - #### getId

          public long getId()

      Unique id

    - #### getName

          public String getName()

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

    - #### getDescription

          public String getDescription()

      Values description -- for printing purposes

    - #### toDouble

          public double toDouble()

      Dobouble representaion. This allows us to have generic optimization criteria. The task is than to minimize total value of assigned variables of a solution.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### valueEquals

          public boolean valueEquals(T value)

      Comparison of two values which is based only on the value (not appropriate variable etc.). toDouble() is compared by default.

    - #### compareTo

          public int compareTo(T value)

      Specified by:
        `compareTo` in interface `Comparable<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

          public Object getExtra()

      Extra information to which can be used by an extension (see `Extension`).

    - #### setExtra

          public void setExtra(Object object)

      Extra information to which can be used by an extension (see `Extension`).

    - #### isConsistent

          public boolean isConsistent(T value)

      True, if the value is consistent with the given value

    - #### conflicts

          public Set<T> conflicts()

      Returns a set of conflicting values with this value. When empty, the value is consistent with the existing assignment.