Class HxExternalArgumentValues

java.lang.Object
com.hexaly.optimizer.HxExternalArgumentValues

public class HxExternalArgumentValues extends Object
Argument values for external functions. Argument values are used to query the values of the arguments passed to external functions.
Since:
9.5
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    copyTo(double[] values)
    Copy all the double values of the argument values to the given array.
    void
    copyTo(long[] values)
    Copy all the integer values of the argument values to the given array.
    int
    Returns the number of values in the current argument values.
    boolean
     
    getArrayValue(int pos)
    Returns the array value at the given position.
    Returns the collection value at the given position.
    double
    getDoubleValue(int pos)
    Returns the double value at the given position.
    Returns the interval value at the given position.
    long
    getIntValue(int pos)
    Returns the integer value at the given position.
    Returns the Hexaly Optimizer object associated to the argument values.
    int
     
    boolean
    isArray(int pos)
    Returns true if the value at the given position is an array.
    boolean
    isBool(int pos)
    Returns true if the value at the given position is a boolean.
    boolean
    isCollection(int pos)
    Returns true if the value at the given position is a collection (list or set).
    boolean
    isDouble(int pos)
    Returns true if the value at the given position is a double.
    boolean
    isInt(int pos)
    Returns true if the value at the given position is an integer.
    boolean
    isInterval(int pos)
    Returns true if the value at the given position is an interval.
    boolean
    isUndefined(int pos)
    Returns true if the argument at the given position has an undefined value.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getOptimizer

      public HexalyOptimizer getOptimizer()
      Returns the Hexaly Optimizer object associated to the argument values.
      Returns:
      Hexaly Optimizer object.
    • isUndefined

      public boolean 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.

      Parameters:
      pos - Position of the argument to query.
      Returns:
      True if the argument at the given position is undefined.
    • isBool

      public boolean isBool(int pos)
      Returns true if the value at the given position is a boolean. You can retrieve the value with getIntValue(int).
      Parameters:
      pos - Position of the value to query.
      Returns:
      True if the value at the given position is a boolean.
    • isInt

      public boolean isInt(int pos)
      Returns true if the value at the given position is an integer. You can retrieve the value with getIntValue(int).
      Parameters:
      pos - Position of the value to query.
      Returns:
      True if the value at the given position is an integer.
    • isDouble

      public boolean isDouble(int pos)
      Returns true if the value at the given position is a double. You can retrieve the value with getDoubleValue(int).
      Parameters:
      pos - Position of the value to query.
      Returns:
      True if the value at the given position is a double.
    • isInterval

      public boolean isInterval(int pos)
      Returns true if the value at the given position is an interval. You can retrieve the value with getIntervalValue(int).
      Parameters:
      pos - Position of the value to query.
      Returns:
      True if the value at the given position is an interval.
    • isCollection

      public boolean isCollection(int pos)
      Returns true if the value at the given position is a collection (list or set). You can retrieve the value with getCollectionValue(int).
      Parameters:
      pos - Position of the value to query.
      Returns:
      True if the value at the given position is a collection.
    • isArray

      public boolean isArray(int pos)
      Returns true if the value at the given position is an array. You can retrieve the value with getArrayValue(int).
      Parameters:
      pos - Position of the value to query.
      Returns:
      True if the value at the given position is an array.
    • getIntValue

      public 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.
      Parameters:
      pos - Position of the value to query.
      Returns:
      Integer value.
    • getDoubleValue

      public double getDoubleValue(int pos)
      Returns the double value at the given position. If the value is not a double, an exception is thrown.
      Parameters:
      pos - Position of the value to query.
      Returns:
      Double value.
    • getIntervalValue

      public HxInterval getIntervalValue(int pos)
      Returns the interval value at the given position. If the value is not an interval, an exception is thrown.
      Parameters:
      pos - Position of the value to query.
      Returns:
      Interval value.
    • getCollectionValue

      public 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.
      Parameters:
      pos - Position of the value to query.
      Returns:
      Collection value.
    • getArrayValue

      public HxArray getArrayValue(int pos)
      Returns the array value at the given position. If the value is not an array, an exception is thrown.
      Parameters:
      pos - Position of the value to query.
      Returns:
      Array value.
    • count

      public int count()
      Returns the number of values in the current argument values. Values are indexed from 0 to count() - 1.
      Returns:
      Number of values.
    • copyTo

      public void copyTo(long[] values)

      Copy all the integer 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);
       }
       
       
      Parameters:
      values - array that will receive the integer values of the argument values.
    • copyTo

      public void copyTo(double[] values)

      Copy all the double 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.getDouble(i);
       }
       
       
      Parameters:
      values - array that will receive the double values of the argument values.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object