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.

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:LSExpression.GetExternalContext

Summary

Methods
SetLowerBound Sets the lower bound of the external function.
SetUpperBound Sets the upper bound of the external 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 external function.
SetDoubleLowerBound Sets the lower bound of the external function.
SetIntUpperBound Sets the upper bound of the external function.
SetDoubleUpperBound Sets the upper bound of the external function.
IsNanable Returns true if the function can return a NaN value.
SetNanable Sets whether or not the function can return a NaN value.

Instance methods

void SetLowerBound(long lowerBound)

Sets the lower bound of the external function. Only allowed if the external function is an integer function. Only allowed in state Modeling. This method has the same behaviour as LSExternalContext.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. Only allowed in state Modeling. This method has the same behaviour as LSExternalContext.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. Only allowed in state Modeling. This method has the same behaviour as LSExternalContext.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. Only allowed in state Modeling. This method has the same behaviour as LSExternalContext.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. 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. 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. 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. 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. Only allowed in state Modeling.

Arguments:nanable – True if the function can return a NaN value, false otherwise.