LocalSolver logo
is now
Hexaly logo

We're excited to share that we are moving forward. We're leaving behind the LocalSolver brand and transitioning to our new identity: Hexaly. This represents a leap forward in our mission to enable every organization to make better decisions faster when faced with operational and strategic challenges.

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.
CreateEvaluationPoint Creates an evaluation point for the black-box function.
GetNbEvaluationPoints Returns the number of black-box evaluation points.
GetEvaluationPoint Returns the black-box evaluation point at the given position.

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
long 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.
LSBlackBoxEvaluationPoint CreateEvaluationPoint()

Creates an evaluation point for the black-box function. It consists of a list of values corresponding to the function’s arguments and return value. Evaluation points are used to specify known points for a function in advance. It can be useful to warm-start the solver when the function is particularly expensive to evaluate, or if you already have a good estimate of the optimal point. Only allowed in state Stopped.

Returns:Black-box evaluation point.
Return type:LSBlackBoxEvaluationPoint
int GetNbEvaluationPoints()

Returns the number of black-box evaluation points. Only allowed in state Stopped.

Returns:Number of black-box evaluation points.
Return type:int
LSBlackBoxEvaluationPoint GetEvaluationPoint(int pos)

Returns the black-box evaluation point at the given position. Only allowed in state Stopped.

Arguments:pos – Position of the black-box evaluation point.
Returns:Black-box evaluation point at the given position.
Return type:LSBlackBoxEvaluationPoint