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.

LSNativeContext Class

class localsolver.LSNativeContext

Context for native functions. Native context are used to query the values of the arguments passed to native functions.

Since:6.0
See:LSNativeFunction

Summary

Methods
GetLocalSolver Returns the LocalSolver object associated to this context.
IsBool Returns true if the value at the given position is a boolean.
IsInt Returns true if the value at the given position is an integer.
IsDouble Returns true if the value at the given position is a double.
IsCollection Returns true if the value at the given position is a collection (list or set).
IsArray Returns true if the value at the given position is an array.
GetIntValue Returns the integer value at the given position.
GetDoubleValue Returns the double value at the given position.
GetCollectionValue Returns the collection value at the given position.
GetArrayValue Returns the array value at the given position.
Count Returns the number of values in the current context.

Instance methods

LocalSolver GetLocalSolver()

Returns the LocalSolver object associated to this context.

Returns:LocalSolver object
Return type:LocalSolver
bool IsBool(int pos)

Returns true if the value at the given position is a boolean. You can retrieve the value with #GetIntValue.

Arguments:pos (int) – Position of the value to query.
Returns:True if the value at the given position is a boolean.
Return type:bool
bool IsInt(int pos)

Returns true if the value at the given position is an integer. You can retrieve the value with GetIntValue.

Arguments:pos (int) – Position of the value to query.
Returns:True if the value at the given position is an integer.
Return type:bool
bool IsDouble(int pos)

Returns true if the value at the given position is a double. You can retrieve the value with GetDoubleValue.

Arguments:pos (int) – Position of the value to query.
Returns:True if the value at the given position is a double.
Return type:bool
bool IsCollection(int pos)

Returns true if the value at the given position is a collection (list or set). You can retrieve the value with GetCollectionValue.

Arguments:pos (int) – Position of the value to query.
Returns:True if the value at the given position is a collection.
Return type:bool
Since:8.5
bool IsArray(int pos)

Returns true if the value at the given position is an array. You can retrieve the value with GetArrayValue.

Arguments:pos (int) – Position of the value to query.
Returns:True if the value at the given position is an array.
Return type:bool
Since:8.5
long GetIntValue(int pos)

Returns the integer value at the given position. If the value is neither an integer nor a boolean, an exception is thrown.

Arguments:pos (int) – Position of the value to query.
Returns:Integer value.
Return type:long
double GetDoubleValue(int pos)

Returns the double value at the given position. If the value is not a double, an exception is thrown.

Arguments:pos (int) – Position of the value to query.
Returns:Double value.
Return type:double
LSCollection GetCollectionValue(int pos)

Returns the collection value at the given position. If the value is not a collection (list or set), an exception is thrown. Note that the returned collection is read only.

Arguments:pos (int) – Position of the value to query.
Returns:Collection value.
Return type:LSCollection
Since:8.5
LSArray GetArrayValue(int pos)

Returns the array value at the given position. If the value is not an array, an exception is thrown.

Arguments:pos (int) – Position of the value to query.
Returns:Array value.
Return type:LSArray
Since:8.5
int Count()

Returns the number of values in the current context.