LSBlackBoxContext Class¶
-
class
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¶
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 black-box evaluations. |
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. |
Functions¶
-
lsint
LSBlackBoxContext
::
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
.Returns: Lower bound of the black-box function.
-
lsint
LSBlackBoxContext
::
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
.Returns: Upper bound of the black-box function.
-
lsdouble
LSBlackBoxContext
::
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
.Returns: Lower bound of the black-box function.
-
lsdouble
LSBlackBoxContext
::
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
.Returns: Upper bound of the black-box function.
-
bool
LSBlackBoxContext
::
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.
Returns: True if the function can return a NaN value.
-
int
LSBlackBoxContext
::
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.
Returns: Maximum number of calls to the black-box function.
-
void
LSBlackBoxContext
::
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 assetIntLowerBound()
.Parameters: lowerBound – Lower bound of the function.
-
void
LSBlackBoxContext
::
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 assetDoubleLowerBound()
.Parameters: lowerBound – Lower bound of the function
-
void
LSBlackBoxContext
::
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 assetIntUpperBound()
.
-
void
LSBlackBoxContext
::
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 assetDoubleLowerBound()
Parameters: upperBound – Upper bound of the function.
-
void
LSBlackBoxContext
::
setIntLowerBound
(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
.Parameters: lowerBound – Lower bound of the function
-
void
LSBlackBoxContext
::
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
LSBlackBoxContext
::
setDoubleLowerBound
(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
.Parameters: lowerBound – Lower bound of the function.
-
void
LSBlackBoxContext
::
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
LSBlackBoxContext
::
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
LSBlackBoxContext
::
setEvaluationLimit
(int evaluationLimit)¶ Sets 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. Only allowed in state
S_Stopped
.Parameters: evaluationLimit – Maximum number of calls to the black-box function.
-
LSBlackBoxEvaluationPoint
LSBlackBoxContext
::
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
S_Stopped
.Returns: Black-box evaluation point. See: LSBlackBoxEvaluationPoint
-
int
LSBlackBoxContext
::
getNbEvaluationPoints
() const¶ Returns the number of black-box evaluation points.
Only allowed in state
S_Stopped
.Returns: Number of black-box evaluation points.
-
lsint
LSBlackBoxContext
::
getEvaluationPoint
(int pos)¶ Returns the black-box evaluation point at the given position.
Only allowed in state
S_Stopped
.Parameters: pos – Position of the black-box evaluation point. Returns: Black-box evaluation point at the given position. See: LSBlackBoxEvaluationPoint