org.cpsolver.ifs.assignment

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

- java.lang.Object
- - org.cpsolver.ifs.assignment.AssignmentAbstract<V,T>
  - - org.cpsolver.ifs.assignment.OptimisticInheritedAssignment<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    Assignment<V,T>, InheritedAssignment<V,T>

      public class OptimisticInheritedAssignment<V extends Variable<V,T>,T extends Value<V,T>>
      extends AssignmentAbstract<V,T>
      implements InheritedAssignment<V,T>

  Optimistic inherited assignment. This assignment does not expect the parent assignment to change much and it only remembers local changes made in this assignment. Use with caution.
  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
  See Also:
    `InheritedAssignment`

- - ### Field Summary

    - ### Fields inherited from class org.cpsolver.ifs.assignment.AssignmentAbstract

      `iContexts, iHasInitialzedContext`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OptimisticInheritedAssignment(Solution<V,T> parent, int index)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<T>` | `assignedValues()` The list of assigned values in the assignment.
    `Collection<V>` | `assignedVariables()` The list of assigned variables in the assignment.
    `long` | `getIteration(V variable)` Returns iteration of the last assignment.
    `Assignment<V,T>` | `getParentAssignment()` Return parent assignment.
    `protected T` | `getValueInternal(V variable)` Returns assignment of a variable, null if not assigned.
    `long` | `getVersion()` Version of the assignment (usually the iteration of the parent assignment at the time of creation)
    `int` | `nrAssignedVariables()` Number of assigned variables in this assignment.
    `protected void` | `setValueInternal(long iteration, V variable, T value)` Sets an assignment to a variable (unassigns a variable if the given value is null).

    - ### Methods inherited from class org.cpsolver.ifs.assignment.AssignmentAbstract

      `assign, assign, clearContext, ensureInitializedContext, getAssignmentContext, getIndex, getValue, nrUnassignedVariables, unassign, unassign, unassignedVariables`

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

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

    - ### Methods inherited from interface org.cpsolver.ifs.assignment.Assignment

      `assign, clearContext, getAssignmentContext, getIndex, getValue, nrUnassignedVariables, unassign, unassign, unassignedVariables`

- - ### Constructor Detail

    - #### OptimisticInheritedAssignment

          public OptimisticInheritedAssignment(Solution<V,T> parent,
                                               int index)

  - ### Method Detail

    - #### getIteration

          public long getIteration(V variable)

      Description copied from interface: `Assignment`
      Returns iteration of the last assignment. Replacement for `Variable.getLastIteration()`.
      Specified by:
        `getIteration` in interface `Assignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `variable` - problem variable
      Returns:
        iteration of the last assignment

    - #### assignedVariables

          public Collection<V> assignedVariables()

      Description copied from interface: `Assignment`
      The list of assigned variables in the assignment. That is all the variables that `Assignment.getValue(Variable)` is not null in this assignment. Replacement for `Model.assignedVariables()`.
      Specified by:
        `assignedVariables` in interface `Assignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        a collection of assigned variable in this assignment

    - #### assignedValues

          public Collection<T> assignedValues()

      Description copied from interface: `Assignment`
      The list of assigned values in the assignment. That is a collection of `Assignment.getValue(Variable)` for all assigned variables in this assignment.
      Specified by:
        `assignedValues` in interface `Assignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Overrides:
        `assignedValues` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        a collection of assigned values in this assignment

    - #### nrAssignedVariables

          public int nrAssignedVariables()

      Description copied from interface: `Assignment`
      Number of assigned variables in this assignment. Replacement for `Model.nrAssignedVariables()`.
      Specified by:
        `nrAssignedVariables` in interface `Assignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Overrides:
        `nrAssignedVariables` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        number of assigned variables in this assignment

    - #### getValueInternal

          protected T getValueInternal(V variable)

      Description copied from class: `AssignmentAbstract`
      Returns assignment of a variable, null if not assigned. To be implemented.
      Specified by:
        `getValueInternal` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `variable` - a variable in question
      Returns:
        assigned value

    - #### setValueInternal

          protected void setValueInternal(long iteration,
                                          V variable,
                                          T value)

      Description copied from class: `AssignmentAbstract`
      Sets an assignment to a variable (unassigns a variable if the given value is null). To be implemented.
      Specified by:
        `setValueInternal` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `iteration` - current iteration
        `variable` - a variable to be assigned
        `value` - new assignment, null if to be unassigned

    - #### getParentAssignment

          public Assignment<V,T> getParentAssignment()

      Description copied from interface: `InheritedAssignment`
      Return parent assignment.
      Specified by:
        `getParentAssignment` in interface `InheritedAssignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        parent assignment

    - #### getVersion

          public long getVersion()

      Description copied from interface: `InheritedAssignment`
      Version of the assignment (usually the iteration of the parent assignment at the time of creation)
      Specified by:
        `getVersion` in interface `InheritedAssignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        version of the inherited assignment