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.get_blackbox_context()

Summary

Attributes
lower_bound Lower bound of the black-box function.
upper_bound Upper bound of the black-box function.
nanable True if the function can return a NaN value, false otherwise.
evaluation_limit Maximum number of black-box evaluations.
Methods
get_lower_bound Gets the lower bound of the exernal function.
get_upper_bound Gets the upper bound of the black-box function.
is_nanable Returns true if the function can return a NaN value.
get_evaluation_limit Returns the maximum number of black-box evaluations.
set_lower_bound Sets the lower bound of the black-box function.
set_upper_bound Sets the upper bound of the black-box function.
set_nanable Sets whether or not the function can return a NaN value.
set_evaluation_limit Sets the maximum number of black-box evalutions.

Instance methods

LSBlackBoxContext.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 black-box function.
Return type:int or double
LSBlackBoxContext.get_upper_bound()

Gets the upper bound of the black-box function. By default, this property is set to a large integer number or math.inf.

Returns:Upper bound of the black-box function.
Return type:int or double
LSBlackBoxContext.is_nanable()

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.
LSBlackBoxContext.get_evaluation_limit()

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.
LSBlackBoxContext.set_lower_bound(lower_bound)

Sets the lower bound of the black-box function. Only allowed in state LSState.MODELING.

Parameters:lower_bound – Lower bound of the function.
LSBlackBoxContext.set_upper_bound(upper_bound)

Sets the upper bound of the black-box function. Only allowed in state LSState.MODELING.

Parameters:upper_bound – Upper bound of the function.
LSBlackBoxContext.set_nanable(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 LSState.MODELING.

Parameters:nanable – True if the function can return a NaN value, false otherwise.
LSBlackBoxContext.set_evaluation_limit(evaluation_limit)

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.

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

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.

LSBlackBoxContext.lower_bound

Lower bound of the black-box function. It is a shortcut for get_lower_bound() and set_lower_bound().

LSBlackBoxContext.upper_bound

Upper bound of the black-box function. It is a shortcut for get_upper_bound() and set_upper_bound().

LSBlackBoxContext.nanable

True if the function can return a NaN value, false otherwise. It is a shortcut for is_nanable() and set_nanable().

LSBlackBoxContext.evaluation_limit

Maximum number of black-box evaluations. It is a shortcut for get_evaluation_limit() and set_evaluation_limit()