Interface Partial<T extends Copyable<T>>

Type Parameters:
T - The type of object that this Partial can become, which is assumed to be an object that is a sequence of integers (e.g., vector of integers, permutation, or some other indexable type that stores integers).
All Known Implementing Classes:
PartialIntegerVector, PartialPermutation

public interface Partial<T extends Copyable<T>>
A Partial represents a partial solution to a problem (e.g., a partial permutation or a partial integer vector) that is being iteratively constructed as a solution to an optimization problem. This class supports the implementation of constructive heuristics for optimization problems, as well as for stochastic sampling algorithms that rely on constructive heuristics.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    extend(int extensionIndex)
    Extends the Partial by adding an element to the end of the Partial.
    int
    get(int index)
    Gets the element in the Partial at position index.
    int
    getExtension(int extensionIndex)
    Gets the element in position index of the list of possible extensions.
    int
    Gets the element in the current last position of the Partial, i.e., the element at index: size()-1.
    boolean
    Checks if the Partial is actually a complete T.
    int
    Gets the number of elements not yet added to the Partial.
    int
    Gets the size of the Partial, which is the number of elements that have already been added to it.
    Generates a complete instance that is consistent with this Partial.
  • Method Details

    • toComplete

      T toComplete()
      Generates a complete instance that is consistent with this Partial. That is, elements already added to the Partial will retain their positions, while elements not already in the Partial will be added in an undefined order such that the result is a valid complete object of type T.
      Returns:
      a valid object of type T consistent with the current state of this Partial
    • isComplete

      boolean isComplete()
      Checks if the Partial is actually a complete T.
      Returns:
      true if the Partial is a complete T.
    • get

      int get(int index)
      Gets the element in the Partial at position index.
      Parameters:
      index - The position, which must be less than size(). The valid index values are [0, 1, ..., (size()-1)].
      Returns:
      the element in position index.
      Throws:
      ArrayIndexOutOfBoundsException - if index is greater than or equal to size(), or if index is less than 0
    • getLast

      int getLast()
      Gets the element in the current last position of the Partial, i.e., the element at index: size()-1.
      Returns:
      The element in the current last position of the Partial.
      Throws:
      ArrayIndexOutOfBoundsException - if size() is 0
    • size

      int size()
      Gets the size of the Partial, which is the number of elements that have already been added to it. Note that this is NOT the size of the final complete T. Rather, it is the current size of the Partial.
      Returns:
      size The size of the Partial.
    • numExtensions

      int numExtensions()
      Gets the number of elements not yet added to the Partial. We refer to these as extensions since adding an element will extend the size of the Partial.
      Returns:
      the number of elements not yet added to the Partial
    • getExtension

      int getExtension(int extensionIndex)
      Gets the element in position index of the list of possible extensions. This method gets the element at position index from the list of those elements that can be added next to the Partial. For example, if this is a partial permutation, then this would get one of the elements not yet added to the permutation. Or for example, if this is a partial vector of integers, then this would get one of the values that is allowed to be added to the next position of the vector. Note that each time extend(int) is called that the remaining elements may be reordered, so you cannot assume that the extensions remain in the same positions once you call extend.
      Parameters:
      extensionIndex - An index into the list of elements that can be added to the Partial next. The valid extensionIndex values are [0, 1, ..., (numExtensions()-1)].
      Returns:
      the element at the designated index in the list of elements that can be added to the Partial.
      Throws:
      ArrayIndexOutOfBoundsException - if extensionIndex is greater than or equal to numExtensions(), or if extensionIndex is less than 0
    • extend

      void extend(int extensionIndex)
      Extends the Partial by adding an element to the end of the Partial. If size() is the size of the Partial before the extension, then the new element is added to position size() and the size() is increased by 1.
      Parameters:
      extensionIndex - An index into the list of elements that can be added to the Partial. The valid extensionIndex values are [0, 1, ..., (numExtensions()-1)].
      Throws:
      ArrayIndexOutOfBoundsException - if extensionIndex is greater than or equal to numExtensions(), or if extensionIndex is less than 0