LSExternalContext Class¶
- class localsolver.LSExternalContext¶
Context of an external function. External contexts can be used to query and set properties of the associated external function.
If you know the bounds of your external 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
Summary¶
Sets the lower bound of the external function. |
|
Sets the upper bound of the external function. |
|
Gets the lower bound of the exernal function. |
|
Gets the lower bound of the exernal function. |
|
Gets the upper bound of the exernal function. |
|
Gets the upper bound of the exernal function. |
|
Sets the lower bound of the external function. |
|
Sets the lower bound of the external function. |
|
Sets the upper bound of the external function. |
|
Sets the upper bound of the external function. |
|
Returns true if the function can return a NaN value. |
|
Sets whether or not the function can return a NaN value. |
|
Enables the surrogate modeling on the associated external function. |
Instance methods¶
- void SetLowerBound(long lowerBound)¶
Sets the lower bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
. This method has the same behaviour asLSExternalContext.SetIntLowerBound(long)
.- Arguments
lowerBound – Lower bound of the function.
- void SetLowerBound(double lowerBound)
Sets the lower bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
. This method has the same behaviour asLSExternalContext.SetDoubleLowerBound(double)
.- Arguments
lowerBound – Lower bound of the function.
- void SetUpperBound(long upperBound)¶
Sets the upper bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
. This method has the same behaviour asLSExternalContext.SetIntUpperBound(long)
.- Arguments
upperBound – Upper bound of the function.
- void SetUpperBound(double upperBound)
Sets the upper bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
. This method has the same behaviour asLSExternalContext.SetDoubleUpperBound(double)
.- Arguments
upperBound – Upper bound of the function.
- long GetIntLowerBound()¶
Gets the lower bound of the exernal function. Only allowed if the external function is an integer function. By default, this property is set to
Int64.MinValue + 1
.- Returns
Lower bound of the external function.
- Return type
long
- double GetDoubleLowerBound()¶
Gets the lower bound of the exernal function. Only allowed if the external function is a double function. By default, this property is set to
Double.NegativeInfinity
.- Returns
Lower bound of the external function.
- Return type
double
- double GetIntUpperBound()¶
Gets the upper bound of the exernal function. Only allowed if the external function is an integer function. By default, this property is set to
Int64.MaxValue
.- Returns
Upper bound of the external function.
- Return type
long
- double GetDoubleUpperBound()¶
Gets the upper bound of the exernal function. Only allowed if the external function is a double function. By default, this property is set to
Double.PositiveInfinity
.- Returns
Upper bound of the external function.
- Return type
double
- void SetIntLowerBound(long lowerBound)¶
Sets the lower bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
.- Arguments
lowerBound – Lower bound of the external function.
- void SetDoubleLowerBound(double lowerBound)¶
Sets the lower bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
.- Arguments
lowerBound – Lower bound of the external function.
- void SetIntUpperBound(long upperBound)¶
Sets the upper bound of the external function. Only allowed if the external function is an integer function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
.- Arguments
upperBound – Upper bound of the external function.
- void SetDoubleUpperBound(double upperBound)¶
Sets the upper bound of the external function. Only allowed if the external function is a double function. If it is an array function, the bound will apply to all elements of the array. Only allowed in state
Modeling
.- Arguments
upperBound – Upper bound of the external function.
- bool IsNanable()¶
Returns true if the function can return a NaN value. Only allowed if the external 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 external function is a double function. If it is an array function, this parameter will apply to all elements of the array. Only allowed in state
Modeling
.- Arguments
nanable – True if the function can return a NaN value, false otherwise.
- LSSurrogateParameters EnableSurrogateModeling()¶
Enables the surrogate modeling on the associated external function. This method changes the internal behavior of the solver: the solver now considers that the function is computationally expensive and therefore uses surrogate modeling. This method returns the
LSSurrogateParameters
which are used to parameterize various aspects of surrogate modeling. Note: Once the surrogate modeling is enabled, it cannot be disabled. Only allowed in stateModeling
.For more information, please see the section dedicated to surrogate modeling among the modeling features.
- Returns
Surrogate parameters.
- Return type