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 a black-box function.

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

If you known the bounds of the 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.

See:LSExpression::getBlackBoxContext()
Since:9.5

Summary

Functions
getIntLowerBound Gets the lower bound of the black-box function.
getIntUpperBound Gets the upper bound of the black-box function.
getDoubleLowerBound Gets the lower bound of the black-box function.
getDoubleUpperBound Gets the upper bound of the black-box function.
isNanable Returns true if the function can return a NaN (Not a Number) value.
getEvaluationLimit Returns the maximum number of black-box evaluations.
setLowerBound Sets the lower bound of the black-box function.
setUpperBound Sets the upper bound of the black-box function.
setIntLowerBound Sets the lower bound of the black-box function.
setIntUpperBound Sets the upper bound of the black-box function.
setDoubleLowerBound Sets the lower bound of the black-box function.
setDoubleUpperBound Sets the upper bound of the black-box function.
setNanable Sets whether or not the function can return a NaN (Not a Number) value.
setEvaluationLimit Sets the maximum number of evaluation of black-box evaluations.

Functions

lsint getIntLowerBound() const

Gets the lower bound of the black-box function.

Only allowed if the black-box function is an integer function. By default, this property is set to LONG_LONG_MIN.

Return:Lower bound of the black-box function.

lsint getIntUpperBound() const

Gets the upper bound of the black-box function.

Only allowed if the black-box function is an integer function. By default, this property is set to LONG_LONG_MAX.

Return:Upper bound of the black-box function.

lsdouble getDoubleLowerBound() const

Gets the lower bound of the black-box function.

Only allowed if the black-box function is a double function. By default, this property is set to -INFINITY.

Return:Lower bound of the black-box function.

lsdouble getDoubleUpperBound() const

Gets the upper bound of the black-box function.

Only allowed if the black-box function is a double function. By default, this property is set to INFINITY.

Return:Upper bound of the black-box function.

bool isNanable() const

Returns true if the function can return a NaN (Not a Number) value.

Only allowed if the black-box function is a double function. By default this property is set to true.

Return:True if the function can return a NaN value.

int getEvaluationLimit() const

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^31-1 = 2,147,483,647 > 10^9.

void setLowerBound(lsint 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 S_Modeling. This method has the same behaviour as LSBlackBoxContext#setIntLowerBound(lsint)

Parameters:lowerBound - Lower bound of the function.

void setLowerBound(lsdouble 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 S_Modeling. This method has the same behaviour as LSBlackBoxContext#setDoubleLowerBound(lsdouble)

Parameters:lowerBound - Lower bound of the function

void setUpperBound(lsint 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 S_Modeling. This method has the same behaviour as LSBlackBoxContext#setIntUpperBound(lsint)

Parameters:upperBound - Upper bound of the function.

void setUpperBound(lsdouble 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 S_Modeling. This method has the same behaviour as LSBlackBoxContext#setDoubleLowerBound(lsdouble)

Parameters:upperBound - Upper bound of the function.

void setIntLowerBound(lsint lowerBound)

Sets the lower bound of the black-box function.

Only allowed if the black-box function is an integer function.

Parameters:lowerBound - Lower bound of the function

void setIntUpperBound(lsint 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 S_Modeling.

Parameters:upperBound - Upper bound of the function.

void setDoubleLowerBound(lsdouble lowerBound)

Sets the lower bound of the black-box function.

Only allowed if the black-box function is a double function.

Parameters:lowerBound - Lower bound of the function.

void setDoubleUpperBound(lsdouble 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 S_Modeling.

Parameters:upperBound - Upper bound of the function.

void setNanable(bool nanable)

Sets whether or not the function can return a NaN (Not a Number) value.

Only allowed if the black-box function is a double function. Only allowed in state S_Modeling.

Parameters:nanable - True if the function can return a NaN value, false otherwise.

void setEvaluationLimit(int evaluationLimit)

Sets the maximum number of evaluation of black-box evaluations.

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