java.lang.Object
org.cicirello.search.ss.PartialIntegerVector
 All Implemented Interfaces:
Partial<IntegerVector>
A PartialIntegerVector represents a vector of integers that is being iteratively constructed as a
solution to an optimization problem over the space of integer vectors. This class supports the
implementation of constructive heuristics for optimization problems where solutions are
represented as a vector of integers, as well as for stochastic sampling algorithms that rely on
constructive heuristics.

Constructor Summary
ConstructorDescriptionPartialIntegerVector
(int n, int min, int max) Constructs a PartialIntegerVector of a specified length with specified min and max values for the integers it contains.PartialIntegerVector
(int n, int min, int max, boolean enforceBounds) Constructs a PartialIntegerVector. 
Method Summary
Modifier and TypeMethodDescriptionvoid
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
getLast()
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
size()
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.

Constructor Details

PartialIntegerVector
public PartialIntegerVector(int n, int min, int max) Constructs a PartialIntegerVector of a specified length with specified min and max values for the integers it contains. The default behavior is for the final IntegerVector that is generated by this PartialIntegerVector to continue to enforce those bounds. Parameters:
n
 The desired length of the final IntegerVector, which must be nonnegative.min
 The minimum value for any individual integer in the vector.max
 The maximum value for any individual integer in the vector. Throws:
IllegalArgumentException
 if n is less than 0IllegalArgumentException
 if min is greater than max

PartialIntegerVector
public PartialIntegerVector(int n, int min, int max, boolean enforceBounds) Constructs a PartialIntegerVector. Parameters:
n
 The desired length of the final IntegerVector, which must be nonnegative.min
 The minimum value for any individual integer in the vector.max
 The maximum value for any individual integer in the vector.enforceBounds
 If true, then the final IntegerVector generated by this PartialIntegerVector will continue to enforce the min and max bounds during subsequent changes. Throws:
IllegalArgumentException
 if n is less than 0IllegalArgumentException
 if min is greater than max


Method Details

toComplete
Description copied from interface:Partial
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. Specified by:
toComplete
in interfacePartial<IntegerVector>
 Returns:
 a valid object of type T consistent with the current state of this Partial

isComplete
public boolean isComplete()Description copied from interface:Partial
Checks if the Partial is actually a complete T. Specified by:
isComplete
in interfacePartial<IntegerVector>
 Returns:
 true if the Partial is a complete T.

get
public int get(int index) Description copied from interface:Partial
Gets the element in the Partial at position index. Specified by:
get
in interfacePartial<IntegerVector>
 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.

getLast
public int getLast()Description copied from interface:Partial
Gets the element in the current last position of the Partial, i.e., the element at index: size()1. Specified by:
getLast
in interfacePartial<IntegerVector>
 Returns:
 The element in the current last position of the Partial.

size
public int size()Description copied from interface:Partial
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. Specified by:
size
in interfacePartial<IntegerVector>
 Returns:
 size The size of the Partial.

numExtensions
public int numExtensions()Description copied from interface:Partial
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. Specified by:
numExtensions
in interfacePartial<IntegerVector>
 Returns:
 the number of elements not yet added to the Partial

getExtension
public int getExtension(int extensionIndex) Description copied from interface:Partial
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 timePartial.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. Specified by:
getExtension
in interfacePartial<IntegerVector>
 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.

extend
public void extend(int extensionIndex) Description copied from interface:Partial
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. Specified by:
extend
in interfacePartial<IntegerVector>
 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)].
