This page is for an old version of Hexaly Optimizer. We recommend that you update your version and read the documentation for the latest stable release.

LSBlackBoxContext Class

class localsolver.LSBlackBoxContext

Context of an black-box function. Black-box contexts can be used to query and set properties of the associated black-box function.

If you know the bounds of your black-box function or if you know it cannot return a NaN value, we recommend you to specify it as LocalSolver 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:LSExpression.GetBlackBoxContext

Summary

Methods
SetLowerBound Sets the lower bound of the black-box function.
SetUpperBound Sets the upper bound of the black-box function.
GetIntLowerBound Gets the lower bound of the exernal function.
GetDoubleLowerBound Gets the lower bound of the exernal function.
GetIntUpperBound Gets the upper bound of the exernal function.
GetDoubleUpperBound Gets the upper bound of the exernal function.
SetIntLowerBound Sets the lower bound of the black-box function.
SetDoubleLowerBound Sets the lower bound of the black-box function.
SetIntUpperBound Sets the upper bound of the black-box function.
SetDoubleUpperBound Sets the upper bound of the black-box function.
IsNanable Returns true if the function can return a NaN value.
SetNanable Sets whether or not the function can return a NaN value.
GetEvaluationLimit Returns the maximum number of black-box evaluations.
SetEvaluationLimit Sets the maximum number of black-box evalutions.

Instance methods

void SetLowerBound(long lowerBound)

Sets the lower bound of the black-box function. Only allowed if the black-box function is an integer function. Only allowed in state Modeling. This method has the same behaviour as LSBlackBoxContext.SetIntLowerBound(long).

Arguments:lowerBound – Lower bound of the function.
void SetLowerBound(double lowerBound)

Sets the lower bound of the black-box function. Only allowed if the black-box function is a double function. Only allowed in state Modeling. This method has the same behaviour as LSBlackBoxContext.SetDoubleLowerBound(double).

Arguments:lowerBound – Lower bound of the function.
void SetUpperBound(long upperBound)

Sets the upper bound of the black-box function. Only allowed if the black-box function is an integer function. Only allowed in state Modeling. This method has the same behaviour as LSBlackBoxContext.SetIntUpperBound(long).

Arguments:upperBound – Upper bound of the function.
void SetUpperBound(double upperBound)

Sets the upper bound of the black-box function. Only allowed if the black-box function is a double function. Only allowed in state Modeling. This method has the same behaviour as LSBlackBoxContext.SetDoubleUpperBound(double).

Arguments:upperBound – Upper bound of the function.
long GetIntLowerBound()

Gets the lower bound of the exernal function. Only allowed if the black-box function is an integer function. By default, this property is set to Int64.MinValue + 1.

Returns:Lower bound of the black-box function.
Return type:long
double GetDoubleLowerBound()

Gets the lower bound of the exernal function. Only allowed if the black-box function is a double function. By default, this property is set to Double.NegativeInfinity.

Returns:Lower bound of the black-box function.
Return type:double
double GetIntUpperBound()

Gets the upper bound of the exernal function. Only allowed if the black-box function is an integer function. By default, this property is set to Int64.MaxValue.

Returns:Upper bound of the black-box function.
Return type:long
double GetDoubleUpperBound()

Gets the upper bound of the exernal function. Only allowed if the black-box function is a double function. By default, this property is set to Double.PositiveInfinity.

Returns:Upper bound of the black-box function.
Return type:double
void SetIntLowerBound(long lowerBound)

Sets the lower bound of the black-box function. Only allowed if the black-box function is an integer function. Only allowed in state Modeling.

Arguments:lowerBound – Lower bound of the black-box function.
void SetDoubleLowerBound(double lowerBound)

Sets the lower bound of the black-box function. Only allowed if the black-box function is a double function. Only allowed in state Modeling.

Arguments:lowerBound – Lower bound of the black-box function.
void SetIntUpperBound(long upperBound)

Sets the upper bound of the black-box function. Only allowed if the black-box function is an integer function. Only allowed in state Modeling.

Arguments:upperBound – Upper bound of the black-box function.
void SetDoubleUpperBound(double upperBound)

Sets the upper bound of the black-box function. Only allowed if the black-box function is a double function. Only allowed in state Modeling.

Arguments:upperBound – Upper bound of the black-box function.
bool IsNanable()

Returns true if the function can return a NaN value. Only allowed if the black-box function is a double function. By default, this property is set to true.

Returns:True if the function can return a NaN value.
Return type:bool
void SetNanable(bool nanable)

Sets whether or not the function can return a NaN value. Only allowed if the black-box function is a double function. Only allowed in state Modeling.

Arguments:nanable – True if the function can return a NaN value, false otherwise.
int GetEvaluationLimit()

Returns the maximum number of black-box evaluations. By default, the maximum number of evaluations is set to the largest positive integer on 32 bits, that is 2^32-1 = 2,147,483,647 > 10^9.

Returns:Maximum number of black-box evaluations.
Return type:int
void SetEvaluationLimit(int evaluationLimit)

Sets the maximum number of black-box evalutions. By default, the maximum number of evaluations is set to the largest positive integer on 32 bits, that is 2^32-1 = 2,147,483,647 > 10^9. Only allowed in state Stopped.

Arguments:evaluationLimit – Maximum number of black-box evaluations.