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.

LSBlackBoxArgumentValues Class

class localsolver.LSBlackBoxArgumentValues

Argument values for black-box functions. Argument values are used to query the values of the arguments passed to black-box functions.

Since:9.5
See:LSBlackBoxFunction

Summary

Methods
GetLocalSolver Returns the LocalSolver object associated to the argument values.
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.
GetIntValue Returns the integer value at the given position.
GetDoubleValue Returns the double value at the given position.
Count Returns the number of values in the current argument values.
CopyTo Copy all the values of the argument values to the given array.

Instance methods

LocalSolver GetLocalSolver()

Returns the LocalSolver object associated to the argument values.

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 LSBlackBoxArgumentValues.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 LSBlackBoxArgumentValues.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 LSBlackBoxArgumentValues.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
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
int Count()

Returns the number of values in the current argument values.

void CopyTo(long[] values)

Copy all the values of the argument values to the given array. Only the integer values are copied to their corresponding position in the array. Cells of the array that correspond to positions of non-integer values in the argument values remain unchanged.

The length of the array can be different from the number of elements in the argument values. In that case, only the elements that fit in the array are copied.

This method is recommended if you need to access all the values of the argument values, instead of the roughly equivalent, but less performant, following code:

for(int i = 0; i < Math.Min(values.Length, argumentValues.Count()); i++)
{
    if(!argumentValues.IsInt(i)) continue;
    values[i] = argumentValues.GetIntValue(i);
}
Arguments:values (long[]) – Array that will receive the integer values of the argument values.
void CopyTo(double[] values)

Copy all the values of the argument values to the given array. Only the double values are copied to their corresponding position in the array. Cells of the array that correspond to positions of non-double values in the argument values remain unchanged.

The length of the array can be different from the number of elements in the argument values. In that case, only the elements that fit in the array are copied.

This method is recommended if you need to access all the values of the argument values, instead of the roughly equivalent, but less performant, following code:

for(int i = 0; i < Math.Min(values.Length, argumentValues.Count()); i++)
{
    if(!argumentValues.IsDouble(i)) continue;
    values[i] = argumentValues.GetDoubleValue(i);
}
Arguments:values (double[]) – Array that will receive the double values of the argument values.