HxExternalArgumentValues Class¶
- class Hexaly.Optimizer.HxExternalArgumentValues¶
Argument values for external functions. Argument values are used to query the values of the arguments passed to external functions.
- Since:
9.5
- See:
HxExternalFunction
Summary¶
Returns the Hexaly Optimizer object associated to the argument values. |
|
Returns true if the argument at the given position has an undefined value. |
|
Returns true if the value at the given position is a boolean. |
|
Returns true if the value at the given position is an integer. |
|
Returns true if the value at the given position is a double. |
|
Returns true if the value at the given position is an interval. |
|
Returns true if the value at the given position is a collection (list or set). |
|
Returns true if the value at the given position is an array. |
|
Returns the integer value at the given position. |
|
Returns the double value at the given position. |
|
Returns the interval value at the given position. |
|
Returns the collection value at the given position. |
|
Returns the array value at the given position. |
|
Returns the number of values in the current argument values. |
|
Copy all the values of the argument values to the given array. |
Instance methods¶
- HexalyOptimizer GetOptimizer()¶
Returns the Hexaly Optimizer object associated to the argument values.
- Returns:
Hexaly Optimizer object
- Return type:
- bool IsUndefined(int pos)¶
Returns true if the argument at the given position has an undefined value. An undefined value is often the result of an illegal or impossible operation. For example, the square root of a negative number, the addition of 2 opposite infinities, accessing an array or collection outside its bounds…
Attempting to access an argument with an undefined value will raise an exception. It is therefore recommended to check whether or not each argument is undefined before accessing its value. This is particularly true during the feasibility phase, when the probability of incorrect operations is very high.
- Arguments:
pos (int) – Position of the argument to query.
- Returns:
True if the argument at the given pos is undefined.
- Return type:
bool
- bool IsBool(int pos)¶
Returns true if the value at the given position is a boolean. You can retrieve the value with
HxExternalArgumentValues.GetIntValue()
.- Arguments:
pos (int) – Position of the value to query.
- Returns:
True if the value at the given position is a boolean.
- Return type:
bool
- bool IsInt(int pos)¶
Returns true if the value at the given position is an integer. You can retrieve the value with
HxExternalArgumentValues.GetIntValue()
.- Arguments:
pos (int) – Position of the value to query.
- Returns:
True if the value at the given position is an integer.
- Return type:
bool
- bool IsDouble(int pos)¶
Returns true if the value at the given position is a double. You can retrieve the value with
HxExternalArgumentValues.GetDoubleValue()
.- Arguments:
pos (int) – Position of the value to query.
- Returns:
True if the value at the given position is a double.
- Return type:
bool
- bool IsInterval(int pos)¶
Returns true if the value at the given position is an interval. You can retrieve the value with
HxExternalArgumentValues.GetIntervalValue()
.- Arguments:
pos (int) – Position of the value to query.
- Returns:
True if the value at the given position is an interval.
- Return type:
bool
- bool IsCollection(int pos)¶
Returns true if the value at the given position is a collection (list or set). You can retrieve the value with
HxExternalArgumentValues.GetCollectionValue()
.- Arguments:
pos (int) – Position of the value to query.
- Returns:
True if the value at the given position is a collection.
- Return type:
bool
- bool IsArray(int pos)¶
Returns true if the value at the given position is an array. You can retrieve the value with
HxExternalArgumentValues.GetArrayValue()
.- Arguments:
pos (int) – Position of the value to query.
- Returns:
True if the value at the given position is an array.
- Return type:
bool
- long GetIntValue(int pos)¶
Returns the integer value at the given position. If the value is neither an integer nor a boolean, an exception is thrown.
- Arguments:
pos (int) – Position of the value to query.
- Returns:
Integer value.
- Return type:
long
- double GetDoubleValue(int pos)¶
Returns the double value at the given position. If the value is not a double, an exception is thrown.
- Arguments:
pos (int) – Position of the value to query.
- Returns:
Double value.
- Return type:
double
- HxInterval GetIntervalValue(int pos)¶
Returns the interval value at the given position. If the value is not an interval, an exception is thrown.
- Arguments:
pos (int) – Position of the value to query.
- Returns:
Interval value.
- Return type:
- HxCollection GetCollectionValue(int pos)¶
Returns the collection value at the given position. If the value is not a collection (list or set), an exception is thrown. Note that the returned collection is read only.
- Arguments:
pos (int) – Position of the value to query.
- Returns:
Collection value.
- Return type:
- HxArray GetArrayValue(int pos)¶
Returns the array value at the given position. If the value is not an array, an exception is thrown.
- Arguments:
pos (int) – Position of the value to query.
- Returns:
Array value.
- Return type:
- int Count()¶
Returns the number of values in the current argument values.
- void CopyTo(long[] values)¶
Copy all the values of the argument values to the given array. Only the integer values are copied to their corresponding position in the array. Cells of the array that correspond to positions of non-integer values in the argument values remain unchanged.
The length of the array can be different from the number of elements in the argument values. In that case, only the elements that fit in the array are copied.
This method is recommended if you need to access all the values of the argument values, instead of the roughly equivalent, but less performant, following code:
for(int i = 0; i < Math.Min(values.Length, argumentValues.Count()); i++) { if(!argumentValues.IsInt(i)) continue; values[i] = argumentValues.GetIntValue(i); }
- Arguments:
values (long[]) – Array that will receive the integer values of the argument values.
- void CopyTo(double[] values)
Copy all the values of the argument values to the given array. Only the double values are copied to their corresponding position in the array. Cells of the array that correspond to positions of non-double values in the argument values remain unchanged.
The length of the array can be different from the number of elements in the argument values. In that case, only the elements that fit in the array are copied.
This method is recommended if you need to access all the values of the argument values, instead of the roughly equivalent, but less performant, following code:
for(int i = 0; i < Math.Min(values.Length, argumentValues.Count()); i++) { if(!argumentValues.IsDouble(i)) continue; values[i] = argumentValues.GetDoubleValue(i); }
- Arguments:
values (double[]) – Array that will receive the double values of the argument values.