XPRMArray
- java.lang.Object
-
- com.dashoptimization.XPRMValue
-
- com.dashoptimization.XPRMArray
-
-
Field Summary
-
Fields inherited from interface com.dashoptimization.XPRMTyped
GRP_DYN, GRP_GEN, MSK_FIX, MSK_GRP, MSK_STR, MSK_TYP, STR_ARRAY, STR_CONST, STR_CSREF, STR_LIST, STR_MEM, STR_NTYP, STR_PROB, STR_PROC, STR_REC, STR_REF, STR_SET, STR_UTYP, TYP_BOOL, TYP_EXTN, TYP_INT, TYP_LINCTR, TYP_MPVAR, TYP_NOT, TYP_REAL, TYP_STRING
-
-
Method Summary
Modifier and Type Method and Description XPRMArrayasArray()An array.XPRMValueget(int ndx)Get the cell content associated to the given index (1 dim.XPRMValueget(int[] ndx)Get the cell content associated to the given index.XPRMValueget(int ndx1, int ndx2)Get the cell content associated to the given index (2 dim.XPRMValueget(int ndx1, int ndx2, int ndx3)Get the cell content associated to the given index (3 dim.booleangetAsBoolean(int ndx)Get the cell content associated to the given index (1 dim.booleangetAsBoolean(int[] ndx)Get the cell content associated to the given index (array of Booleans).booleangetAsBoolean(int n1, int n2)Get the cell content associated to the given index (2 dim.booleangetAsBoolean(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim.intgetAsInteger(int ndx)Get the cell content associated to the given index (1 dim.intgetAsInteger(int[] ndx)Get the cell content associated to the given index (array of integers).intgetAsInteger(int n1, int n2)Get the cell content associated to the given index (2 dim.intgetAsInteger(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim.doublegetAsReal(int ndx)Get the cell content associated to the given index (1 dim.doublegetAsReal(int[] ndx)Get the cell content associated to the given index (array of reals).doublegetAsReal(int n1, int n2)Get the cell content associated to the given index (2 dim.doublegetAsReal(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim.java.lang.StringgetAsString(int ndx)Get the cell content associated to the given index (1 dim.java.lang.StringgetAsString(int[] ndx)Get the cell content associated to the given index (array of strings).java.lang.StringgetAsString(int n1, int n2)Get the cell content associated to the given index (2 dim.java.lang.StringgetAsString(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim.intgetDimension()Get array dimension.int[]getFirstIndex()Get the index of the first cell of the array.int[]getFirstTEIndex()Get the index of the first defined cell of the array.XPRMSet[]getIndexSets()Get the sets indexing the array.int[]getLastIndex()Get the index of the last cell of the array.java.lang.StringgetSignature()Get array signature (requirement only).intgetSize()Get array size.intgetStructCode()Structure code.java.lang.StringgetStructName()String representation of structure.intgetTypeCode()Type code.java.lang.StringgetTypeName()String representation of type.XPRMArrayIndicesindices(boolean trueIndices)Get an iterator to enumerate all valid indices of the array.booleanisDynamic()Check whether the array is dynamic.booleanisEmpty()Check whether the array is empty.booleanisInitialised()Check whether the array has been initialised.booleannextIndex(int[] indices)Update the given index to point to the next cell in the array.booleannextTEIndex(int[] indices)Update the given index to point to the next defined cell in the array.java.lang.StringtoString()Generate a string representation of the content of the array.
-
-
-
Method Detail
-
asArray
public final XPRMArray asArray()
Description copied from class:XPRMValueAn array. This function is defined if the actual object is an array.
-
isInitialised
public final boolean isInitialised()
Check whether the array has been initialised. Objects are initialised during model execution. Trying to access a Mosel object that has not been created will result on an exception.- Returns:
-
trueif the array has been created
-
isDynamic
public final boolean isDynamic()
Check whether the array is dynamic.- Returns:
-
trueif the array is dynamic
-
getSize
public final int getSize()
Get array size.- Returns:
- Number of cells in the array
-
getDimension
public final int getDimension()
Get array dimension.- Returns:
- Number indices required to access a cell
-
getSignature
public final java.lang.String getSignature()
Get array signature (requirement only). Required arrays are specified by their type and signature. The signature is the list of names of the indexing sets stored in a text string (e.g."S1,S2,S3").- Returns:
- Index sets names as a text string
-
isEmpty
public final boolean isEmpty()
Check whether the array is empty.- Returns:
-
trueif the array contains no cell
-
getIndexSets
public final XPRMSet[] getIndexSets()
Get the sets indexing the array.- Returns:
-
An array of
XPRMSetof sizegetDimension()
-
getFirstIndex
public final int[] getFirstIndex()
Get the index of the first cell of the array.- Returns:
-
An array of size
getDimension()pointing to the first cell in the array
-
getFirstTEIndex
public final int[] getFirstTEIndex()
Get the index of the first defined cell of the array. Dynamic arrays do not necessarily have a defined cell for each index.- Returns:
-
An array of size
getDimension()pointing to the first defined cell in the array
-
getLastIndex
public final int[] getLastIndex()
Get the index of the last cell of the array.- Returns:
-
An array of size
getDimension()pointing to the last cell in the array
-
indices
public final XPRMArrayIndices indices(boolean trueIndices)
Get an iterator to enumerate all valid indices of the array.- Parameters:
-
trueIndices- iftrueenumerate only indices for defined cells - Returns:
- An indices iterator
-
nextIndex
public final boolean nextIndex(int[] indices)
Update the given index to point to the next cell in the array.- Parameters:
-
indices- array of indices - Returns:
-
falseif the provided index points to the last cell in the array
-
nextTEIndex
public final boolean nextTEIndex(int[] indices)
Update the given index to point to the next defined cell in the array.- Parameters:
-
indices- array of indices - Returns:
-
falseif the provided index points to the last defined cell in the array
-
get
public final XPRMValue get(int[] ndx)
Get the cell content associated to the given index.- Parameters:
-
ndx- array of indices - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
get
public final XPRMValue get(int ndx)
Get the cell content associated to the given index (1 dim. array).- Parameters:
-
ndx- index - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If the index is out of bounds.
-
get
public final XPRMValue get(int ndx1, int ndx2)
Get the cell content associated to the given index (2 dim. array).- Parameters:
-
ndx1- index for the first dimension -
ndx2- index for the second dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
get
public final XPRMValue get(int ndx1, int ndx2, int ndx3)
Get the cell content associated to the given index (3 dim. array).- Parameters:
-
ndx1- index for the first dimension -
ndx2- index for the second dimension -
ndx3- index for the third dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsInteger
public int getAsInteger(int[] ndx)
Get the cell content associated to the given index (array of integers).- Parameters:
-
ndx- array of indices - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsInteger
public int getAsInteger(int ndx)
Get the cell content associated to the given index (1 dim. array of integers).- Parameters:
-
ndx- index - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If the index is out of bounds.
-
getAsInteger
public int getAsInteger(int n1, int n2)Get the cell content associated to the given index (2 dim. array of integers).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsInteger
public int getAsInteger(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim. array of integers).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension -
n3- index for the third dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsReal
public double getAsReal(int[] ndx)
Get the cell content associated to the given index (array of reals).- Parameters:
-
ndx- array of indices - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsReal
public double getAsReal(int ndx)
Get the cell content associated to the given index (1 dim. array of reals).- Parameters:
-
ndx- index - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If the index is out of bounds.
-
getAsReal
public double getAsReal(int n1, int n2)Get the cell content associated to the given index (2 dim. array of reals).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsReal
public double getAsReal(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim. array of reals).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension -
n3- index for the third dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsBoolean
public boolean getAsBoolean(int[] ndx)
Get the cell content associated to the given index (array of Booleans).- Parameters:
-
ndx- array of indices - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsBoolean
public boolean getAsBoolean(int ndx)
Get the cell content associated to the given index (1 dim. array of Booleans).- Parameters:
-
ndx- index - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If the index is out of bounds.
-
getAsBoolean
public boolean getAsBoolean(int n1, int n2)Get the cell content associated to the given index (2 dim. array of Booleans).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsBoolean
public boolean getAsBoolean(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim. array of Booleans).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension -
n3- index for the third dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsString
public java.lang.String getAsString(int[] ndx)
Get the cell content associated to the given index (array of strings).- Parameters:
-
ndx- array of indices - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsString
public java.lang.String getAsString(int ndx)
Get the cell content associated to the given index (1 dim. array of strings).- Parameters:
-
ndx- index - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If the index is out of bounds.
-
getAsString
public java.lang.String getAsString(int n1, int n2)Get the cell content associated to the given index (2 dim. array of strings).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getAsString
public java.lang.String getAsString(int n1, int n2, int n3)Get the cell content associated to the given index (3 dim. array of strings).- Parameters:
-
n1- index for the first dimension -
n2- index for the second dimension -
n3- index for the third dimension - Returns:
- Cell associated to the given index
- Throws:
-
java.lang.ArrayIndexOutOfBoundsException- If one of the indices is out of bounds.
-
getTypeCode
public final int getTypeCode()
Description copied from interface:XPRMTypedType code. The code is one of theTYP_*values.- Returns:
- Encoded type
-
getTypeName
public final java.lang.String getTypeName()
Description copied from interface:XPRMTypedString representation of type.- Returns:
- Type name
-
getStructCode
public final int getStructCode()
Description copied from interface:XPRMTypedStructure code. The code is one of theSTR_*values.- Returns:
- Encoded structure
-
getStructName
public final java.lang.String getStructName()
Description copied from interface:XPRMTypedString representation of structure.- Returns:
- Structure name
-
toString
public final java.lang.String toString()
Generate a string representation of the content of the array.- Overrides:
-
toStringin classjava.lang.Object - Returns:
- String describing the array content
-
-
