LSOperator Enumeration¶

enum LSOperator¶
Mathematical operators available for modeling. These operators are used to type the expressions created in a LocalSolver optimization model.
 See
 See

enumerator O_Bool¶
Boolean decision. Decisional operator with no operand. Decision variable with domain
{0,1}
.

enumerator O_Float¶
Float decision. Operator with two operands that represent the lower bound and the upper bound of the decision (domain
[lb, ub]
). The bounds must be constants (integers or doubles). Since
4.0

enumerator O_Const¶
Constant. Operator with no argument. Constants can be booleans, long or doubles. Note that constants 0 or 1 are considered as boolean. Constants are implicitly created when passing long or double arguments to
LSModel::createExpression()
orLSExpression::addOperand()
. They can also be created with the dedicated functionLSModel::createConstant()
.

enumerator O_Sum¶
Sum. Nary arithmetic operator.
SUM(e1, e2, ..., eN)
is equal to the sum of all operandse1, e2, ..., eN
. This operator returns an integer if all the operands are booleans or integers and a double as soon as one operand is a double.With collections (lists, sets) or intervals
This operator can also be used with intervals,
O_List
orO_Set
to create expressions with a dynamic number of operands. In that case, this operator becomes a binary operator that takes an interval, a list or a set as first operand and aO_LambdaFunction
as second operand. The operator will call the function on each value of the interval, list or set and will sum all the values computed and returned by the function.

enumerator O_Sub¶
Substraction. Binary arithmetic operator.
SUB(x, y)
is equal to the value ofx  y
. This operator returns an integer if the two operands are booleans or integers, and a double as soon as one operand is a double. Since
4.0

enumerator O_Prod¶
Product. Nary arithmetic operator.
PROD(e1, e2, ..., eN)
is equal to the product of all operandse1, e2, ..., eN
. This operator returns an integer if all the operands are booleans or integers, and a double as soon as one operand is a double.With collections (lists, sets) or intervals
This operator can also be used with intervals,
O_List
orO_Set
to create expressions with a dynamic number of operands. In that case, this operator becomes a binary operator that takes an interval, a list or a set as first operand and aO_LambdaFunction
as second operand. The operator will call the function on each value of the interval, list or set and will compute the product of all the values returned by the function.

enumerator O_Max¶
Maximum. Nary arithmetic operator.
MAX(e1, e2, ..., eN)
is equal to the maximum value among all operandse1, e2, ..., eN
. This operator returns an integer if all the operands are booleans or integers, and a double as soon as one operand is a double.With collections (lists, sets) or intervals
This operator can also be used with intervals,
O_List
orO_Set
to create expressions with a dynamic number of operands. In that case, this operator becomes a binary operator that takes an interval, a list or a set as first operand and aO_LambdaFunction
as second operand. The operator will call the function on each value of the interval, list or set and will find the maximum value among all the values returned by the function.

enumerator O_Min¶
Minimum. Nary arithmetic operator.
MIN(e1, e2, ..., eN)
is equal to the minimum value among all operandse1, e2, ..., eN
. This operator returns an integer if all the operands are booleans or integers, and a double as soon as one operand is a double.With collections (lists, sets) or intervals
This operator can also be used with intervals,
O_List
orO_Set
to create expressions with a dynamic number of operands. In that case, this operator becomes a binary operator that takes an interval, a list or a set as first operand and aO_LambdaFunction
as second operand. The operator will call the function on each value of the interval, list or set and will find the minimum value among all the values returned by the function.

enumerator O_Eq¶
Equal. Binary relational operator.
EQ(a,b) = 1
ifa == b
, and0
otherwise. This operator returns a boolean.

enumerator O_Neq¶
Not equal to. Binary relational operator.
NEQ(a,b) = 1
ifa != b
, and0
otherwise. This operator returns a boolean.

enumerator O_Geq¶
Greater than or equal to. Binary relational operator.
GEQ(a,b) = 1
ifa >= b
, and0
otherwise. This operator returns a boolean.

enumerator O_Leq¶
Lower than or equal to. Binary relational operator.
LEQ(a,b) = 1
ifa <= b
, and0
otherwise. This operator returns a boolean.

enumerator O_Gt¶
Strictly greater than. Binary relational operator.
GT(a,b) = 1
ifa > b
, and0
otherwise. Can be used to compare two intervals, in that caseGT(a, b) = 1
ifstart(a) >= end(b)
, and0
otherwise. Undefined ifa
orb
is void. This operator returns a boolean.

enumerator O_Lt¶
Strictly lower than. Binary relational operator.
LT(a, b) = 1
ifa < b
, and0
otherwise. Can be used to compare two intervals, in that caseLT(a, b) = 1
ifend(a) <= start(b)
, and0
otherwise. Undefined ifa
orb
is void. This operator returns a boolean.

enumerator O_If¶
IfThenElse. Ternary conditional operator.
IF(a, b, c)
is equal tob
ifa = 1
, andc
otherwise. The first operand must be a boolean (that is, equal to 0 or 1). This operator returns a boolean if the three operands are booleans, an integer if the second and third operands are integers, and a double if the second or the third operand is a double.

enumerator O_Not¶
Not. Unary logical operator.
NOT(a) = 1  a
. The operand must be boolean (that is, equal to 0 or 1). This operator returns a boolean.

enumerator O_And¶
And. Nary logical operator.
AND(e1, e2, ..., eN)
is equal to 1 (true) if all the operandse1, e2, ..., eN
are 1, and 0 otherwise. All the operands must be boolean (that is, equal to 0 or 1). This operator returns a boolean.With collections (lists, sets) or intervals
This operator can also be used with intervals,
O_List
orO_Set
to create expressions with a dynamic number of operands. In that case, this operator becomes a binary operator that takes an interval, a list or a set as first operand and aO_LambdaFunction
as second operand. The operator will call the function on each value of the interval, list or set and will return 1 if all the values returned by the function are 1 and 0 otherwise.

enumerator O_Or¶
Or. Nary logical operator.
OR(e1, e2, ..., eN)
is equal to 0 (false) if all operandse1, e2, ..., eN
are 0, and 1 otherwise. All the operands must be boolean (that is, equal to 0 or 1). This operator returns a boolean.With collections (lists, sets) or intervals
This operator can also be used with intervals,
O_List
orO_Set
to create expressions with a dynamic number of operands. In that case, this operator becomes a binary operator that takes an interval, a list or a set as first operand and aO_LambdaFunction
as second operand. The operator will call the function on each value of the interval, list or set and will return 0 if all the values returned by the function are 0 and 1 otherwise.

enumerator O_Xor¶
Exclusive or (also called “xor”). Nary logical operator.
XOR(e1, e2, ..., eN)
is equal to 0 if the number of operands with value 1 amonge1, e2, ..., eN
is even, and 1 otherwise. Remarkable case:XOR(a,b) = 1
ifa == b
, and0
otherwise. All the operands must be boolean (that is, equal to 0 or 1). This operator returns a boolean.With collections (lists, sets) or intervals
This operator can also be used with intervals,
O_List
orO_Set
to create expressions with a dynamic number of operands. In that case, this operator becomes a binary operator that takes an interval, a list or a set as first operand and aO_LambdaFunction
as second operand. The operator will call the function on each value of the interval, list or set and will return 0 if the number of value 1 returned by the function is even, and 1 otherwise.

enumerator O_Abs¶
Absolute value. Unary arithmetic operator.
ABS(e) = e >= 0 ? e : e
. This operator returns an integer if the operand is a boolean or an integer, and a double otherwise.

enumerator O_Dist¶
Distance between two numbers. Binary arithmetic operator.
DIST(a,b) = ABS(ab)
. This operator returns an integer if the two operands are booleans or integers, and a double as soon as one of the operand is a double.

enumerator O_Div¶
Division. Binary arithmetic operator. This operator always returns a double. Note that until version 4.0, the division was an integer division if both operands were integers.

enumerator O_Mod¶
Modulo (remainder of the integer division). Binary arithmetic operator.
MOD(a, b) = r
such thata = q * b + r
withq
,r
integers, wherer
,a
have the same sign andr < b
. The operands must be integers or booleans. This operator returns an integer.

enumerator O_Array¶
Array. An array is a collection of elements. Indexes begin at 0. It could be used with operators like
O_At
orO_Scalar
. An array doesn’t have a value by itself, but can contain operands of type boolean, integer, double, array (for multidimensional arrays) or collection (list, set). In the latter case, the collections must share the same domain and same type (either list or set). All the elements of an array must be of the same type.With intervals
This operator can also be used with intervals to create an array with a dynamic number of elements. In that case, this operator becomes a binary operator that takes an interval as first operand and a
O_LambdaFunction
as second operand. The operator will call the function on each value of the interval and the returned values will be used to populate the array. Since
2.1

enumerator O_At¶
Returns the element at specific coordinates of an array or a list.
For arrays
The first operand must be the array and the other operands must be the coordinates of the element to get. The number of coordinates depends on the dimension of the array. Thus AT(myArray, i) returns the i element of the onedimensional array myArray. This operator returns a boolean, an integer or a double according to the type of the operands in the array. If one of the specified coordinate is out of range, the evaluation of the expression will fail.
For lists
The first operand must be the list and the second operand must be the index of the element to get. If the index is out of range (index < 0 or index > count(list)), the evaluation of the expression will not fail but will return 1.
 Since
2.1

enumerator O_Scalar¶
Scalar product.
SCALAR(a, x) = sum(a[i]*x[i])
wherea
andx
are two onedimensional arrays. This operator returns an integer or a double according to the type of the operands in the arrays. Since
2.1

enumerator O_Ceil¶
Ceil. Unary arithmetic operator. Returns a value rounded to the next highest integer. The operand can be a boolean, an integer or a double. This operator returns an integer.
 Since
3.0

enumerator O_Floor¶
Floor. Unary arithmetic operator. Returns a value rounded to the next lowest integer. The operand can be a boolean, an integer or a double. This operator returns an integer.
 Since
3.0

enumerator O_Round¶
Round. Unary arithmetic operator. Returns a value rounded to the nearest integer. The operand can be a boolean, an integer or a double. This operator returns an integer.
 Since
3.0

enumerator O_Sqrt¶
Square root. Unary arithmetic operator. The operand can be a boolean, an integer or a double. This operator returns a double.
 Since
3.0

enumerator O_Log¶
Natural logarithm (basee). Unary arithmetic operator. The operand can be a boolean, an integer or a double. This operator returns a double.
 Since
3.0

enumerator O_Exp¶
Basee exponential. Unary arithmetic operator. The operand can be a boolean, an integer or a double. This operator returns a double.
 Since
3.0

enumerator O_Pow¶
Power operator.
POW(x, y)
is equals to the value ofx
to the power ofy
. The operands can be booleans, integers or doubles. This operator returns a double. Since
3.0

enumerator O_Cos¶
Cosine. Unary arithmetic operator. The operand can be a boolean, an integer or a double. This operator returns a double.
 Since
3.0

enumerator O_Sin¶
Sine. Unary arithmetic operator. The operand can be a boolean, an integer or a double. This operator returns a double.
 Since
3.0

enumerator O_Tan¶
Tangent. Unary arithmetic operator. The operand can be a boolean, an integer or a double. This operator returns a double.
 Since
3.0

enumerator O_Int¶
Integer decision variable. Operator with two operands that represent the lower bound and the upper bound of the decision (domain
[lb, ub]
). The bounds must be integer constants. Since
5.0

enumerator O_Interval¶
Interval decision variable. Operator with two integer constant operands that represent the min start and the max end of the decision. The interval is included in
[minStart, maxEnd)
. Its start is inclusive and its end is exclusive. Since
12.0

enumerator O_Piecewise¶
Piecewiselinear function operator. The piecewise linear function is defined by two arrays of numbers giving the breakpoints of the function. This operator has exactly 3 operands: The first two operands must be two arrays of equal sizes (necessarily larger or equal to 2). These arrays must contain constant numbers (integers or doubles). The first array must contain numbers in ascending order. The third operand must be an integer or a double expression. The evaluation of the piecewise will fail if the value of the third operand is strictly smaller that the first element of the first array, or strictly larger than the last element of the first array. This operator returns a double.
PIECEWISE(x,y,z)
returns the image of z by the function defined by geometric points(x[0],y[0]), (x[1],y[1]), ..., (x[n1],y[n1])
, For instancePIECEWISE(ARRAY(0, 50, 100), ARRAY(0, 10, 100), 75)
returns55
.Discontinuities are allowed in the definition of the function, that is to say that two geometric points can share the same xcoordinate. By convention the value taken by the function at such a discontinuous point is the one associated to the last occurrence of this xcoordinate in array x. For instance
PIECEWISE(ARRAY(0, 50, 50, 100), ARRAY(0, 0.1, 0.9, 1), 50)
returns0.9
; Since
5.0

enumerator O_List¶
A list is an ordered collection of integers within a domain
[0, n1]
wheren
is the unique argument of this operator. Mathematically a list is a permutation of a subset of[0, n1]
. This operator takes exactly one operand: a strictly positive integer constant. All values in the list will be pairwise different, non negative and strictly smaller that this number.The elements of the list can be accessed individually with the operator
O_At
. Since
5.5

enumerator O_Count¶
The number of elements in an array, a collection or an interval. This operator takes exactly one argument of type array, collection or interval and returns an integer.
 Since
5.5

enumerator O_IndexOf¶
The index of a value in a list (1 if the value is not in the list). This operator takes exactly two arguments: the first one is a list, the second one is an integer expression.
 Since
5.5

enumerator O_Partition¶
Partition. Nary logical operator.
PARTITION(c1, c2, ..., cN)
is true if all lists or setsc1, c2, ..., cN
form a partition of their common domain. All the operands must be collections of the same type (either list or set) and on the same range. These collections can be stored in a LSArray that will be passed as argument of the partition:PARTITION(array(c1, c2, ..., cN))
. Since
5.5

enumerator O_Disjoint¶
Disjoint. Nary logical operator.
DISJOINT(c1, c2, ..., cN)
is true if all lists or setsc1, c2, ..., cN
are pairwise disjoint. All the operands must be collections of the same type (either list or set) and on the same range. These collections can be stored in a LSArray that will be passed as argument of the disjoint:DISJOINT(array(c1, c2, ..., cN))
. Since
5.5

enumerator O_Cover¶
Cover. Nary logical operator.
COVER(c1, c2, ..., cN)
is true if all values in the domain are at least in one list or setc1, c2, ..., cN
. All the operands must be collections of the same type (either list or set) and on the same range. These collections can be stored in a LSArray that will be passed as argument of the cover:COVER(array(c1, c2, ..., cN))
. Since
10.5

enumerator O_Find¶
Find.
find(a, v)
returns the position of the collection in the arraya
that contains the valuev
. If the value is not in any collections of the array, it returns 1. This operator takes exactly two arguments: the first one is anO_Array
of collections, the second one is the value searched. All the collections of the array must be of the same type and on the same range. Since
10.5

enumerator O_ExternalFunction¶
External function. External functions are used to compute the value of expressions from external functions written with your favorite programming language. External functions are created with the dedicated methods
LSModel::createIntExternalFunction()
orLSModel::createDoubleExternalFunction()
. See
LSIntExternalFunction
 See
LSDoubleExternalFunction
 Since
9.5

enumerator O_Call¶
Call a particular function. The first operand must be a function (like
O_ExternalFunction
orO_LambdaFunction
). The other operands are passed to the function as arguments. If the function is not a external function, the number of operands must match the number of arguments of the function. Since
6.0

enumerator O_LambdaFunction¶
Lambda function. Lambda functions are created with the dedicated method
LSModel::createLambdaFunction()
. Since
9.5

enumerator O_Argument¶
Argument of a function. Arguments are automatically and implicitely created when you create a function with method
LSModel::createLambdaFunction()
. Since
7.0

enumerator O_Range¶
Range expression. This operator takes exactly two integer operands. The first one is the lower bound (inclusive), the second one is the upper bound (exclusive).
A range has an interval value and can be used with Nary operators like
O_Sum
,O_Prod
,O_Min
,O_Max
,O_Or
,O_And
,O_Xor
orO_Array
to create expressions that have a dynamic number of operands. Since
7.0

enumerator O_Contains¶
Contains.
contains(expr, v)
is true if and only if the expressionexpr
contains the valuev
. This operator takes exactly two arguments: the first one is a collection (O_List
orO_Set
), an interval or anO_Array
of collections, the second one is the integer expression searched. Ifexpr
is an array, all its collections must be of the same type and on the same range. Since
7.5

enumerator O_Set¶
A set is an unordered collection of integers within a range [0, n1] where n is the unique argument of this operator. This operator takes exactly one operand: a strictly positive integer constant. All values in the set will be pairwise different, non negative and strictly smaller that this number. Contrary to the
O_List
operator, elements in a set are not ordered and cannot be indexed withO_At
. Sets can only be manipulated with lambdas and nary operators likeO_Sum
,O_Min
,O_And
, … Since
8.0

enumerator O_Sort¶
Sort operator takes a onedimensional array of integers or doubles as input and returns an array sorted by ascending values. This operator returns an array of integers if the input array is solely composed of booleans or integers, and an array of doubles as soon as the input array contains a double.
 Since
11.0

enumerator O_Start¶
The start of a nonvoid interval. This operator takes exactly one argument of type interval and returns an integer.
 Since
12.0

enumerator O_End¶
The end of a nonvoid interval. This operator takes exactly one argument of type interval and returns an integer.
 Since
12.0

enumerator O_Length¶
The length of a nonvoid interval. This operator takes exactly one argument of type interval and returns an integer. The length of an interval is equivalent to
end(interval)  start(interval).
It differs from the count on void intervals since the length of a void interval is undefined whereas the count of a void interval is 0. Since
12.0