HxExternalContext Class¶
- class hexaly.optimizer.HxExternalContext¶
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:
Summary¶
Lower bound of the external function. |
|
Upper bound of the external function. |
|
True if the function can return a NaN value, false otherwise. |
Gets the lower bound of the exernal function. |
|
Gets the upper bound of the external function. |
|
Sets the lower bound of the external function. |
|
Sets the upper bound of the external function. |
|
Returns true if the function can return a NaN value. |
|
Sets whether or not the function can return a NaN value. |
|
Enables the surrogate modeling on the associated external function. |
Instance methods¶
- HxExternalContext.get_lower_bound()¶
Gets the lower bound of the exernal function. By default, this property is set to a large integer number or math.inf.
- Returns:
Lower bound of the external function.
- Return type:
int
ordouble
- HxExternalContext.get_upper_bound()¶
Gets the upper bound of the external function. By default, this property is set to a large integer number or math.inf.
- Returns:
Upper bound of the external function.
- HxExternalContext.set_lower_bound(lower_bound)¶
Sets the lower bound of the external function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
HxState.MODELING
.- Parameters:
lower_bound – Lower bound of the function.
- HxExternalContext.set_upper_bound(upper_bound)¶
Sets the upper bound of the external function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
HxState.MODELING
.- Parameters:
upper_bound – Upper bound of the function.
- HxExternalContext.is_nanable()¶
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.
- HxExternalContext.set_nanable(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.
- HxExternalContext.enable_surrogate_modeling()¶
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 stateMODELING
.For more information, please see the section dedicated to surrogate modeling among the modeling features.
- Returns:
Surrogate parameters.
- Return type:
Instance attributes¶
All get/set
methods have their attribute counterpart. You can use them as
shortcuts to improve the readability of your models and codes.
- HxExternalContext.lower_bound¶
Lower bound of the external function. It is a shortcut for
get_lower_bound()
andset_lower_bound()
.
- HxExternalContext.upper_bound¶
Upper bound of the external function. It is a shortcut for
get_upper_bound()
andset_upper_bound()
.
- HxExternalContext.nanable¶
True if the function can return a NaN value, false otherwise. It is a shortcut for
is_nanable()
andset_nanable()
.