org.cpsolver.ifs.assignment

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

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

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

      public class DefaultParallelAssignment<V extends Variable<V,T>,T extends Value<V,T>>
      extends AssignmentAbstract<V,T>

  An assignment using the `Variable.getAssignments()` to store values of all the variables of the model. Besides of that, a set of assigned variables is kept in memory. Each extra contains an array of values, indexed by `Assignment.getIndex()`. Useful for a small, fixed number of assignments. Used by the `ParallelSolver`, where there is one assignment for each thread.
  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.
  See Also:
    `Assignment`, `ParallelSolver`

- - ### Field Summary

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

      `iContexts, iHasInitialzedContext`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultParallelAssignment()`
    `DefaultParallelAssignment(AssignmentContextHolder<V,T> contexts, int threadIndex, Solution<V,T> solution)`
    `DefaultParallelAssignment(int threadIndex)`
    `DefaultParallelAssignment(int threadIndex, Model<V,T> model, Assignment<V,T> assignment)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<V>` | `assignedVariables()` The list of assigned variables in the assignment.
    `int` | `getIndex()` Assignment index.
    `long` | `getIteration(V variable)` Returns iteration of the last assignment.
    `protected T` | `getValueInternal(V variable)` Returns assignment of a variable, null if not assigned.
    `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, assignedValues, clearContext, ensureInitializedContext, getAssignmentContext, getValue, nrAssignedVariables, nrUnassignedVariables, unassign, unassign, unassignedVariables`

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

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

- - ### Constructor Detail

    - #### DefaultParallelAssignment

          public DefaultParallelAssignment(int threadIndex)

    - #### DefaultParallelAssignment

          public DefaultParallelAssignment()

    - #### DefaultParallelAssignment

          public DefaultParallelAssignment(int threadIndex,
                                           Model<V,T> model,
                                           Assignment<V,T> assignment)

    - #### DefaultParallelAssignment

          public DefaultParallelAssignment(AssignmentContextHolder<V,T> contexts,
                                           int threadIndex,
                                           Solution<V,T> solution)

  - ### Method Detail

    - #### getIteration

          public long getIteration(V variable)

      Description copied from interface: `Assignment`
      Returns iteration of the last assignment. Replacement for `Variable.getLastIteration()`.
      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()`.
      Returns:
        a collection of assigned variable 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

    - #### getIndex

          public int getIndex()

      Description copied from interface: `Assignment`
      Assignment index. Unique identification of the assignment, starting with zero. This can be used to increase the speed of the search by storing individual values on the variables and an array (indexed by this number).
      Specified by:
        `getIndex` in interface `Assignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Overrides:
        `getIndex` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        assignment index, -1 if not to be used