Class HxExternalContext


  • public class HxExternalContext
    extends java.lang.Object
    Context of an external function. External context can be used to query and set properties of the associated external function. If you know the bounds of your external function or if you know it cannot return a NaN value, we recommend you to specify it as Hexaly Optimizer is then able to improve its search process. But beware! If the evaluation of the function returns an unexpected value (like a value outside of the bounds), an exception will be thrown during the search.
    Since:
    9.5
    See Also:
    HxExpression.getExternalContext()
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      HxSurrogateParameters enableSurrogateModeling()
      Enables the surrogate modeling on the associated external function.
      boolean equals​(java.lang.Object obj)  
      double getDoubleLowerBound()
      Gets the lower bound of the external function.
      double getDoubleUpperBound()
      Gets the upper bound of the external function.
      long getIntLowerBound()
      Gets the lower bound of the external function.
      long getIntUpperBound()
      Gets the upper bound of the external function.
      int hashCode()  
      boolean isNanable()
      Returns true if the function can return a NaN value.
      void setDoubleLowerBound​(double lowerBound)
      Sets the lower bound of the external function.
      void setDoubleUpperBound​(double upperBound)
      Sets the upper bound of the external function.
      void setIntLowerBound​(long lowerBound)
      Sets the lower bound of the external function.
      void setIntUpperBound​(long upperBound)
      Sets the upper bound of the external function.
      void setLowerBound​(double lowerBound)
      Sets the lower bound of the external function.
      void setLowerBound​(long lowerBound)
      Sets the lower bound of the external function.
      void setNanable​(boolean nanable)
      Sets whether or not the function can return a NaN value.
      void setUpperBound​(double upperBound)
      Sets the upper bound of the external function.
      void setUpperBound​(long upperBound)
      Sets the upper bound of the external function.
      • Methods inherited from class java.lang.Object

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

      • setLowerBound

        public void setLowerBound​(long lowerBound)
        Sets the lower bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state HxState.Modeling. This method has the same behaviour as setIntLowerBound(long)
        Parameters:
        lowerBound - Lower bound of the function.
      • setLowerBound

        public void setLowerBound​(double lowerBound)
        Sets the lower bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state HxState.Modeling. This method has the same behaviour as setDoubleLowerBound(double)
        Parameters:
        lowerBound - Lower bound of the function.
      • setUpperBound

        public void setUpperBound​(long upperBound)
        Sets the upper bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. in state HxState.Modeling. This method has the same behaviour as setIntUpperBound(long)
        Parameters:
        upperBound - Upper bound of the function.
      • setUpperBound

        public void setUpperBound​(double upperBound)
        Sets the upper bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state HxState.Modeling. This method has the same behaviour as setDoubleUpperBound(double)
        Parameters:
        upperBound - Upper bound of the function.
      • getIntLowerBound

        public long getIntLowerBound()
        Gets the lower bound of the external function. Only allowed if the external function is an integer function. By default, this property is set to Long.MIN_VALUE + 1.
        Returns:
        Lower bound of the function.
      • setIntLowerBound

        public void setIntLowerBound​(long lowerBound)
        Sets the lower bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state HxState.Modeling.
        Parameters:
        lowerBound - Lower bound of the function.
      • getIntUpperBound

        public long getIntUpperBound()
        Gets the upper bound of the external function. Only allowed if the external function is an integer function. By default, this property is set to Long.MAX_VALUE.
        Returns:
        Upper bound of the function.
      • setIntUpperBound

        public void setIntUpperBound​(long upperBound)
        Sets the upper bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state HxState.Modeling.
        Parameters:
        upperBound - Upper bound of the function.
      • getDoubleLowerBound

        public double getDoubleLowerBound()
        Gets the lower bound of the external function. Only allowed if the external function is a double function. By default, this property is set to Double.NEGATIVE_INFINITY.
        Returns:
        Lower bound of the function.
      • setDoubleLowerBound

        public void setDoubleLowerBound​(double lowerBound)
        Sets the lower bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state HxState.Modeling.
        Parameters:
        lowerBound - Lower bound of the function.
      • getDoubleUpperBound

        public double getDoubleUpperBound()
        Gets the upper bound of the external function. Only allowed if the external function is a double function. By default, this property is set to Double.POSITIVE_INFINITY.
        Returns:
        Upper bound of the function.
      • setDoubleUpperBound

        public void setDoubleUpperBound​(double upperBound)
        Sets the upper bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state HxState.Modeling.
        Parameters:
        upperBound - Upper bound of the function.
      • isNanable

        public boolean isNanable()
        Returns true if the function can return a NaN value. Only allowed if the external function is a double function. By default, this property is set to true.
        Returns:
        True if the function can return a NaN value.
      • setNanable

        public void setNanable​(boolean nanable)
        Sets whether or not the function can return a NaN value. Only allowed if the external function is a double function. If it is an array function, this parameter will apply to all elements of the array. Only allowed in state HxState.Modeling.
        Parameters:
        nanable - True if the function can return a NaN value, false otherwise.
      • enableSurrogateModeling

        public HxSurrogateParameters enableSurrogateModeling()
        Enables the surrogate modeling on the associated external function. This method changes the internal behavior of the optimizer: the optimizer now considers that the function is computationally expensive and therefore uses surrogate modeling. This method returns the HxSurrogateParameters which are used to parameterize various aspects of surrogate modeling.

        Note: Once the surrogate modeling is enabled, it cannot be disabled. Only allowed in state HxState.Modeling. For more information, please see the section dedicated to surrogate modeling among the modeling features.

        Returns:
        Surrogate parameters.
        See Also:
        HxSurrogateParameters
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object