LSModel Class¶

class
localsolver.
LSModel
¶ Mathematical optimization model. A model is composed of expressions (some of which are decisions), organized as a tree. Then, some expressions of the model can be constrained or optimized. Once your optimization model is created and closed, the solver can be launched to resolve it. Note that you cannot modify a model which has been closed: you must reopen it (with
LSModel.open()
) or instantiate another LocalSolver environment to optimize another model.See: LSExpression See: LSOperator
Summary¶
GetLocalSolver 
Returns the LocalSolver object associated to this model. 
CreateConstant 
Creates a constant expression representing the given value. 
CreateExpression 
Creates an expression of the given type, with the given ordered operands. 
CreateLambdaFunction 
Creates a lambda function with arguments. 
CreateIntExternalFunction 
Creates an integer external function. 
CreateDoubleExternalFunction 
Creates a double external function. 
CreateDoubleBlackBoxFunction 
Creates a double blackbox function. 
GetNbExpressions 
Returns the number of expressions added to this model. 
GetExpression 
Gets the expression with the given index in this model. 
GetNbDecisions 
Gets the number of decisions in the model. 
GetDecision 
Gets the decision with the given index. 
AddConstraint 
Adds the given expression to the list of constraints. 
Constraint 
Shortcut for AddConstraint(expr). 
RemoveConstraint 
Removes the given expression from the list of constraints. 
GetNbConstraints 
Returns the number of constraints added to this model. 
GetConstraint 
Gets the constraint with the given index in this model. 
AddObjective 
Adds the given expression to the list of objectives to optimize. 
Minimize 
Shortcut for AddObjective(LSObjectiveDirection.Minimize, expr). 
Maximize 
Shortcut for AddObjective(LSObjectiveDirection.Maximize, expr). 
RemoveObjective 
Removes the objective at the given position in the list of objectives. 
GetNbObjectives 
Returns the number of objectives added to this model. 
GetObjective 
Gets the objective with the given index in this model. 
GetObjectiveDirection 
Gets the direction of the objective with the given index. 
GetNbOperands 
Gets the number of operands in the model. 
Close 
Closes the model. 
Open 
Reopens the model. 
IsClosed 
Returns true if the model is closed, false otherwise. 
Bool 
Creates a boolean decision. 
Float 
Creates a float decision. 
Int 
Creates an integer decision. 
List 
Creates a list decision with the given length. 
Set 
Creates a set decision with the given length. 
Sum 
Creates a sum expression. 
Sub 
Creates a substraction expression. 
Prod 
Creates a product expression. 
Max 
Creates a maximum expression. 
Min 
Creates a minimum expression. 
Eq 
Creates an equality expression. 
Neq 
Creates a disequality expression. 
Geq 
Creates an inequality expression greater than or equal to. 
Leq 
Creates an inequality expression less than or equal to. 
Gt 
Creates an inequality expression greater than. 
Lt 
Creates an inequality expression less than. 
If 
Creates a ternary conditional expression. 
Not 
Creates a NOT expression. 
And 
Creates an AND expression. 
Or 
Creates a OR expression. 
Xor 
Creates a XOR expression. 
Abs 
Creates an absolute value expression. 
Dist 
Creates a distance expression. 
Div 
Creates a division expression. 
Mod 
Creates a modulo expression. 
Array 
Creates an array expression. 
At 
Creates a “at” expression for Ndimensional array. 
Scalar 
Creates an expression for the scalar product between two arrays. 
Ceil 
Creates a ceil expression. 
Floor 
Creates a floor expression. 
Round 
Creates a rounding expression. 
Sqrt 
Creates a square root expression. 
Log 
Creates a log expression. 
Exp 
Creates an exponential expression. 
Pow 
Creates a power expression. 
Cos 
Creates a cosine expression. 
Sin 
Creates a sine expression. 
Tan 
Creates a tangent expression. 
Piecewise 
Creates a piecewise linear expression. 
Count 
Creates a count expression. 
IndexOf 
Creates an indexOf expression. 
Contains 
Creates a contains expression. 
Partition 
Creates a partition expression. 
Disjoint 
Creates a disjoint expression. 
IntExternalFunction 
Creates an integer external function. 
DoubleExternalFunction 
Creates a double external function. 
DoubleBlackBoxFunction 
Creates a double blackbox function. 
LambdaFunction 
Creates a lambda function expression. 
Call 
Creates a call expression. 
Range 
Creates a range expression, where a is the lower bound (inclusive) and b is the upper bound (exclusive). 
ToString 
Returns a string representation of this model. 
Instance methods¶

LocalSolver
GetLocalSolver
()¶ Returns the LocalSolver object associated to this model.
Returns: LocalSolver object Return type: LocalSolver

LSExpression
CreateConstant
(long value)¶ 
LSExpression
CreateConstant
(double value) Creates a constant expression representing the given value. Only allowed in state
Modeling
. Note that if a constant has been already created with the same value, this method can return the same expression, but it is not guaranteed. The exact behavior is implementation defined.Arguments: value ( long
ordouble
) – Value of the constantReturns: Created constant expression Return type: LSExpression

LSExpression
CreateExpression
(LSOperator op)¶ 
LSExpression
CreateExpression
(LSOperator op, params LSExpression[] operands) 
LSExpression
CreateExpression
(LSOperator op, params long[] operands) 
LSExpression
CreateExpression
(LSOperator op, params double[] operands) 
LSExpression
CreateExpression
(LSOperator op, IEnumerable<LSExpression> operands) 
LSExpression
CreateExpression
(LSOperator op, IEnumerable<long> operands) 
LSExpression
CreateExpression
(LSOperator op, IEnumerable<double> operands) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, long b) 
LSExpression
CreateExpression
(LSOperator op, long a, long b, LSExpression c) 
LSExpression
CreateExpression
(LSOperator op, long a, LSExpression b, long c) 
LSExpression
CreateExpression
(LSOperator op, long a, LSExpression b, LSExpression c) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, long b, long c) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, long b, LSExpression c) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, LSExpression b, long c) 
LSExpression
CreateExpression
(LSOperator op, double a, LSExpression b) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, double b) 
LSExpression
CreateExpression
(LSOperator op, double a, double b, LSExpression c) 
LSExpression
CreateExpression
(LSOperator op, double a, LSExpression b, double c) 
LSExpression
CreateExpression
(LSOperator op, double a, LSExpression b, LSExpression c) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, double b, double c) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, double b, LSExpression c) 
LSExpression
CreateExpression
(LSOperator op, LSExpression a, LSExpression b, double c) Creates an expression of the given type, with the given ordered operands. Only allowed in state
Modeling
. The operands can be doubles, longs or previously declared LSExpressions. It is also possible to use this method with arrays or enumerables.This method can be called with a variable number of arguments thanks to the
params
keyword. The following code is valid as long as all the arguments share the same type (i.elong
,double
orLSExpression
):// all the arguments (a, b, c, ...) must be of the same data type CreateExpression(op, a, b, c, d, e, f, g)
Arguments:  op (LSOperator) – Type of expression to create
 a (
long
,double
orLSExpression
) – Operand 0  b (
long
,double
orLSExpression
) – Operand 1  c (
long
,double
orLSExpression
) – Operand 2  operands – Operands.
Returns: Created expression.
Return type:

LSExpression
CreateLambdaFunction
(LSLambdaFunction0 functor)¶ 
LSExpression
CreateLambdaFunction
(LSLambdaFunction1 functor) 
LSExpression
CreateLambdaFunction
(LSLambdaFunction2 functor) 
LSExpression
CreateLambdaFunction
(LSLambdaFunction3 functor) 
LSExpression
CreateLambdaFunction
(int nbArgs, LSLambdaFunction functor) Creates a lambda function with arguments. A lambda function is a particular expression composed of two parts:
 The arguments of the function (which are also LSExpressions of type
Argument
).  The body of the function. The body is an LSExpression that will be used to evaluate the result of the function. The body can be any LSExpression composed of any operands and operators supported by LocalSolver. Thus, the body expression can use the arguments of the function but can also capture and refer to expressions declared outside of the function.
The functor you provide will not be used directly during the solving process, but will be evaluated once by the API, with a number of LSExpression of type
Argument
that corresponds to the number of arguments you want and your function expects. At the end of the evaluation of your function, the returned LSExpression will be used as the body of the LocalSolver function.Since: 9.5
Arguments:  nbArgs – Number of arguments you want for your function. Only useful if you want a function with more than 3 arguments. Otherwise, you can use the dedicated shortcuts LSLambdaFunction0, LSLambdaFunction1, LSLambdaFunction2 and LSLambdaFunction3.
 function – A function (LSLambdaFunction) that accepts
LSExpression
as arguments and returns anLSExpression
that will be used as the body of the new LocalSolver function you want to create.
Returns: Expression of type
LambdaFunction
. The arguments of the function (which are also LSExpressions of type

LSExpression
CreateIntExternalFunction
(LSIntExternalFunction function)¶ Creates an integer external function. The argument must implement
LSIntExternalFunction
. When the external function is called, the argument values will be made accessible to your function through theLSExternalArgumentValues
.Once you have instantiated it, you have to use
LSModel.Call()
to call it in your model.Note 1: Most of the time your external function will be called when the solver is in state
Running
. Do not attempt to call any method of the solver (to retrieve statistics, values of LSExpressions or whatever) in that state or an exception will be thrown. The only accessible function isLocalSolver.Stop()
.Note 2: Your functions must be threadsafe. According to the “nbThreads” parameter, LocalSolver can be multithreaded. In that case, your external functions must be thread safe. If you cannot guarantee the threadsafety of your code, we strongly recommend you to limit the search of LocalSolver to one thread with
LSParam.SetNbThreads
.Note 3: You can provide additional data for your function (such as lower and upper bounds) with the help of the
LSExternalContext
associated with your function (seeLSExpression.GetExternalContext()
.Since: 9.5 Arguments: function (LSIntExternalFunction) – External function to call, passed as a delegate. Returns: The expression associated to the function. Return type: LSExpression

LSExpression
CreateDoubleExternalFunction
(LSDoubleExternalFunction function)¶ Creates a double external function. The argument must implement
LSDoubleExternalFunction
. When the external function is called, the argument values will be made accessible to your function through theLSExternalArgumentValues
.Once you have instantiated it, you have to use
LSModel.Call()
to call it in your model.Note 1: Most of the time your external function will be called when the solver is in state
Running
. Do not attempt to call any method of the solver (to retrieve statistics, values of LSExpressions or whatever) in that state or an exception will be thrown. The only accessible function isLocalSolver.Stop()
.Note 2: Your functions must be threadsafe. According to the “nbThreads” parameter, LocalSolver can be multithreaded. In that case, your external functions must be thread safe. If you cannot guarantee the threadsafety of your code, we strongly recommend you to limit the search of LocalSolver to one thread with
LSParam.SetNbThreads
.Note 3: You can provide additional data for your function (such as lower and upper bounds) with the help of the
LSExternalContext
associated with your function (seeLSExpression.GetExternalContext()
.Since: 9.5 Arguments: function (LSDoubleExternalFunction) – External function to call, passed as a delegate. Returns: The expression associated to the function. Return type: LSExpression

LSExpression
CreateDoubleBlackBoxFunction
(LSDoubleBlackBoxFunction function)¶ Creates a double blackbox function. The argument must implement
LSDoubleBlackBoxFunction
. When the blackbox function is called, the argument values will be made accessible to your function through theLSBlackBoxArgumentValues
.Once you have instantiated it, you have to use
LSModel.Call()
to call it in your model.Note: You can provide additional data and parameters for your function (such as bounds or the maximum number of evaluations) with the help of the
LSBlackBoxContext
associated with your function (seeLSExpression.GetBlackBoxContext()
).Since: 9.5 Arguments: function (LSDoubleBlackBoxFunction) – Blackbox function to call, passed as a delegate. Returns: The expression associated to the function. Return type: LSExpression

int
GetNbExpressions
()¶ Returns the number of expressions added to this model.
See: LSModel.GetExpression(int) Returns: Number of expressions. Return type: int

LSExpression
GetExpression
(int exprIndex)¶ Gets the expression with the given index in this model. Throws an exception if
exprIndex < 0
orexprIndex >= GetNbExpressions()
See: LSModel.GetNbExpressions() Arguments: exprIndex ( int
) – Index of the expression.Returns: Expression with the given index. Return type: LSExpression

LSExpression
GetExpression
(string exprName) Gets the expression with the given name. Throws an exception if no expression with the given name exists.
Arguments: exprName ( name
) – Name.Returns: Expression with the given name. Return type: LSExpression

int
GetNbDecisions
()¶ Gets the number of decisions in the model. This corresponds to the number of decision variables (
LSOperator.Bool
,LSOperator.Float
,LSOperator.Int
orLSOperator.List
) declared in the model.See: LSModel.GetDecision() Returns: Number of decisions. Return type: int

LSExpression
GetDecision
(int decisionIndex)¶ Gets the decision with the given index. Throws an exception if
decisionIndex < 0
ordecisionIndex >= GetNbDecisions()
See: LSModel.GetNbDecisions() Arguments: exprIndex – Index of the decision. Returns: Decision with the given index. Return type: LSExpression

void
AddConstraint
(LSExpression expr)¶ Adds the given expression to the list of constraints. It means that the value of this expression must be constrained to be equal to 1 in any solution found by the solver. Hence, only boolean expressions (that is, expressions whose value is boolean) can be constrained. Only allowed in state
Modeling
. If the expression is already a constraint, this method does nothing and returns immediately.Try to avoid hard constraints as much as possible, because LocalSolver (and more generally local search) is not suited for solving hardly constrained problems. In particular, banish constraints that are not surely satisfied in practice. Ideally, only combinatorial constraints (which induce the combinatorial structure of your problem) have to be set. All the other constraints can be relaxed as primary objectives in order to be “softly” satisfied (goal programming). For instance, constraint
a <= b
can be transformed into minimizemax(ba, 0)
.Arguments: expr (LSExpression) – Expression to constraint.

void
Constraint
(LSExpression expr)¶ Shortcut for
AddConstraint(expr)
.Since: 5.5 See: LSModel.AddConstraint(LSExpression) Arguments: expr (LSExpression) – Expression to constraint.

void
RemoveConstraint
(LSExpression expr)¶ Removes the given expression from the list of constraints. If the expression was not constrained, this method does nothing and returns immediately. Only allowed in state
Modeling
.Since: 5.0 Arguments: expr (LSExpression) – Expression

void
RemoveConstraint
(int constraintIndex) Removes the constraint at the given position in the list of constraints. Only allowed in state
Modeling
.Since: 5.0 See: LSModel.GetConstraint(int) Arguments: constraintIndex ( int
) – Index of the constraint to remove

int
GetNbConstraints
()¶ Returns the number of constraints added to this model.
See: LSModel.GetConstraint(int) Returns: Number of constraints. Return type: int

LSExpression
GetConstraint
(int constraintIndex)¶ Gets the constraint with the given index in this model. Throws an exception if
constraintIndex < 0
orconstraintIndex >= GetNbConstraints()
.See: LSModel.GetNbConstraints() Arguments: constraintIndex ( int
) – Index of the constraint.Returns: Constraint with the given index. Return type: LSExpression

void
AddObjective
(LSExpression expr, LSObjectiveDirection direction)¶ Adds the given expression to the list of objectives to optimize. The same expression can be added more than once. Only allowed in state
Modeling
. Note that the objectives will be optimized in the order in which they have been added to the model. It is useful for lexicographic multiobjective optimization, and more particularly for goal programming.Arguments:  expr (LSExpression) – Expression.
 direction (LSObjectiveDirection) – Optimisation direction of this objective

void
Minimize
(LSExpression expr)¶ Shortcut for
AddObjective(LSObjectiveDirection.Minimize, expr)
.Since: 5.5 See: LSModel.AddObjective(LSExpression, LSObjectiveDirection) Arguments: expr (LSExpression) – Expression to minimize.

void
Maximize
(LSExpression expr)¶ Shortcut for
AddObjective(LSObjectiveDirection.Maximize, expr)
.Since: 5.5 See: LSModel.AddObjective(LSExpression, LSObjectiveDirection) Arguments: expr (LSExpression) – Expression to maximize.

void
RemoveObjective
(int objectiveIndex)¶ Removes the objective at the given position in the list of objectives. Note that the objectives created after the removed one have their index decreased by 1. Phases are not modified when an objective is removed. It is the user’s responsibility to change the objective index of each phase to keep it coherent (with
LSPhase.SetOptimizedObjective(int)
), or to disable it (withLSPhase.SetEnabled(bool)
).Only allowed in state
Modeling
.Since: 5.0 Arguments: objectiveIndex (int) – position of the objective to remove.

int
GetNbObjectives
()¶ Returns the number of objectives added to this model.
See: LSModel.GetObjective(int) Returns: Number of objectives. Return type: int

LSExpression
GetObjective
(int objectiveIndex)¶ Gets the objective with the given index in this model. Throws an exception if
objectiveIndex < 0
orobjectiveIndex >= GetNbObjectives()
.See: LSModel.GetNbObjectives() Arguments: objectiveIndex (int) – Index of the objective. Returns: Objective with the given index. Return type: LSExpression

LSObjectiveDirection
GetObjectiveDirection
(int objectiveIndex)¶ Gets the direction of the objective with the given index.
See: LSModel.GetObjective(int) Arguments: objectiveIndex (int) – Index of the objective. Returns: Objective direction. Return type: LSObjectiveDirection

int
GetNbOperands
()¶ Gets the number of operands in the model. This corresponds to the number of operands for all expressions declared in the model. It is an analog of the number of non zeros in matrix model encountered in mathematical programming: it gives an hint about the size and the density of your model.
See: LSExpression.GetNbOperands() Returns: Number of operands. Return type: int

void
Close
()¶ Closes the model. Only allowed in state
Modeling
. When this method is called, the solver is placed in stateStopped
.Once the model is closed, no expressions, constraints or objectives can be added or removed unless the model is reopened. The model must be closed before starting its resolution.
See: LSModel.Open()

void
Open
()¶ Reopens the model. Only allowed in state
Stopped
. When this method is called, the solver is placed in stateModeling
.In this state, the model can be modified: it is possible to add new expressions, constraints or objectives, modify expression operands, and remove existing constraints and objectives. However, existing expressions cannot be deleted.
See: LSModel.Close()

bool
IsClosed
()¶ Returns true if the model is closed, false otherwise.
Returns: True if the model is closed. Return type: bool

LSExpression
Bool
()¶ Creates a boolean decision. Binary decision variable with domain { 0, 1 }. This method is a shortcut for
CreateExpression(LSOperator.Bool)
.See: LSOperator.Bool See: LSModel.CreateExpression Since: 5.5

LSExpression
Float
(double lb, double ub)¶ Creates a float decision. Decision variable with domain [lb, ub]. This method is a shortcut for
CreateExpression(LSOperator.Float, lb, ub)
.Arguments:  lb (double) – Lower bound of the decision variable.
 ub (double) – Upper bound of the decision variable.
See: See: Since: 5.5

LSExpression
Int
(long lb, long ub)¶ Creates an integer decision. Decision variable with domain [lb, ub]. This method is a shortcut for
CreateExpression(LSOperator.Int, lb, ub)
.Arguments:  lb (long) – Lower bound of the decision variable.
 ub (long) – Upper bound of the decision variable.
See: See: Since: 5.5

LSExpression
List
(long n)¶ Creates a list decision with the given length. A list is an ordered collection of integers within a domain [0, n1]. This method is a shortcut for
CreateExpression(LSOperator.List, n)
.See: LSOperator.List See: LSModel.CreateExpression Since: 5.5

LSExpression
Set
(long n)¶ Creates a set decision with the given length. A set is an unordered collection of integers within a domain [0, n1]. This method is a shortcut for
CreateExpression(LSOperator.Set, n)
.See: LSOperator.Set See: LSModel.CreateExpression Since: 8.0

LSExpression
Sum
()¶ 
LSExpression
Sum
(params LSExpression[] operands) 
LSExpression
Sum
(IEnumerable<LSExpression> operands) 
LSExpression
Sum
(long a) 
LSExpression
Sum
(double a) 
LSExpression
Sum
(long a, LSExpression b) 
LSExpression
Sum
(double a, LSExpression b) 
LSExpression
Sum
(LSExpression a, long b) 
LSExpression
Sum
(LSExpression a, double b) 
LSExpression
Sum
(LSExpression a, LSExpression b) Creates a sum expression. This method is a shortcut for
CreateExpression(LSOperator.Sum, operands)
.See: LSOperator.Sum See: LSModel.CreateExpression Since: 5.5

LSExpression
Sub
(LSExpression a, LSExpression b)¶ 
LSExpression
Sub
(long a, LSExpression b) 
LSExpression
Sub
(double a, LSExpression b) 
LSExpression
Sub
(LSExpression a, long b) 
LSExpression
Sub
(LSExpression a, double b) Creates a substraction expression. This method is a shortcut for
CreateExpression(LSOperator.Sub, a, b)
.See: LSOperator.Sub See: LSModel.CreateExpression Since: 5.5

LSExpression
Prod
()¶ 
LSExpression
Prod
(params LSExpression[] operands) 
LSExpression
Prod
(IEnumerable<LSExpression> operands) 
LSExpression
Prod
(long a) 
LSExpression
Prod
(double a) 
LSExpression
Prod
(long a, LSExpression b) 
LSExpression
Prod
(double a, LSExpression b) 
LSExpression
Prod
(LSExpression a, long b) 
LSExpression
Prod
(LSExpression a, double b) 
LSExpression
Prod
(LSExpression a, LSExpression b) Creates a product expression. This method is a shortcut for
CreateExpression(LSOperator.Prod, operands)
.See: LSOperator.Prod See: LSModel.CreateExpression Since: 5.5

LSExpression
Max
()¶ 
LSExpression
Max
(params LSExpression[] operands) 
LSExpression
Max
(IEnumerable<LSExpression> operands) 
LSExpression
Max
(long a) 
LSExpression
Max
(double a) 
LSExpression
Max
(long a, LSExpression b) 
LSExpression
Max
(double a, LSExpression b) 
LSExpression
Max
(LSExpression a, long b) 
LSExpression
Max
(LSExpression a, double b) 
LSExpression
Max
(LSExpression a, LSExpression b) Creates a maximum expression. This method is a shortcut for
CreateExpression(LSOperator.Max, operands)
.See: LSOperator.Max See: LSModel.CreateExpression Since: 5.5

LSExpression
Min
()¶ 
LSExpression
Min
(params LSExpression[] operands) 
LSExpression
Min
(IEnumerable<LSExpression> operands) 
LSExpression
Min
(long a) 
LSExpression
Min
(double a) 
LSExpression
Min
(long a, LSExpression b) 
LSExpression
Min
(double a, LSExpression b) 
LSExpression
Min
(LSExpression a, long b) 
LSExpression
Min
(LSExpression a, double b) 
LSExpression
Min
(LSExpression a, LSExpression b) Creates a minimum expression. This method is a shortcut for
CreateExpression(LSOperator.Min, operands)
.See: LSOperator.Min See: LSModel.CreateExpression Since: 5.5

LSExpression
Eq
(long a, LSExpression b)¶ 
LSExpression
Eq
(double a, LSExpression b) 
LSExpression
Eq
(LSExpression a, long b) 
LSExpression
Eq
(LSExpression a, double b) 
LSExpression
Eq
(LSExpression a, LSExpression b) Creates an equality expression. This method is a shortcut for
CreateExpression(LSOperator.Eq, a, b)
.See: LSOperator.Eq See: LSModel.CreateExpression Since: 5.5

LSExpression
Neq
(LSExpression a, LSExpression b)¶ 
LSExpression
Neq
(long a, LSExpression b) 
LSExpression
Neq
(double a, LSExpression b) 
LSExpression
Neq
(LSExpression a, long b) 
LSExpression
Neq
(LSExpression a, double b) Creates a disequality expression. This method is a shortcut for
CreateExpression(LSOperator.Neq, a, b)
.See: LSOperator.Neq See: LSModel.CreateExpression Since: 5.5

LSExpression
Geq
(LSExpression a, LSExpression b)¶ 
LSExpression
Geq
(long a, LSExpression b) 
LSExpression
Geq
(double a, LSExpression b) 
LSExpression
Geq
(LSExpression a, long b) 
LSExpression
Geq
(LSExpression a, double b) Creates an inequality expression greater than or equal to. This method is a shortcut for
CreateExpression(LSOperator.Geq, a, b)
.See: LSOperator.Geq See: LSModel.CreateExpression Since: 5.5

LSExpression
Leq
(LSExpression a, LSExpression b)¶ 
LSExpression
Leq
(long a, LSExpression b) 
LSExpression
Leq
(double a, LSExpression b) 
LSExpression
Leq
(LSExpression a, long b) 
LSExpression
Leq
(LSExpression a, double b) Creates an inequality expression less than or equal to. This method is a shortcut for
CreateExpression(LSOperator.Leq, a, b)
.See: LSOperator.Leq See: LSModel.CreateExpression Since: 5.5

LSExpression
Gt
(LSExpression a, LSExpression b)¶ 
LSExpression
Gt
(long a, LSExpression b) 
LSExpression
Gt
(double a, LSExpression b) 
LSExpression
Gt
(LSExpression a, long b) 
LSExpression
Gt
(LSExpression a, double b) Creates an inequality expression greater than. This method is a shortcut for
CreateExpression(LSOperator.Gt, a, b)
.See: LSOperator.Gt See: LSModel.CreateExpression Since: 5.5

LSExpression
Lt
(LSExpression a, LSExpression b)¶ 
LSExpression
Lt
(long a, LSExpression b) 
LSExpression
Lt
(double a, LSExpression b) 
LSExpression
Lt
(LSExpression a, long b) 
LSExpression
Lt
(LSExpression a, double b) Creates an inequality expression less than. This method is a shortcut for
CreateExpression(LSOperator.Lt, a, b)
.See: LSOperator.Lt See: LSModel.CreateExpression Since: 5.5

LSExpression
If
(LSExpression a, LSExpression b, LSExpression c)¶ 
LSExpression
If
(LSExpression a, LSExpression b, long c) 
LSExpression
If
(LSExpression a, long b, LSExpression c) 
LSExpression
If
(LSExpression a, long b, long c) 
LSExpression
If
(LSExpression a, LSExpression b, double c) 
LSExpression
If
(LSExpression a, double b, LSExpression c) 
LSExpression
If
(LSExpression a, double b, double c) Creates a ternary conditional expression. This method is a shortcut for
CreateExpression(LSOperator.If, condExpr, trueExpr, falseExpr)
.See: LSOperator.If See: LSModel.CreateExpression Since: 5.5

LSExpression
Not
(LSExpression a)¶ Creates a NOT expression. This method is a shortcut for
CreateExpression(LSOperator.Not, a)
.See: LSOperator.Not See: LSModel.CreateExpression Since: 5.5

LSExpression
And
()¶ 
LSExpression
And
(params LSExpression[] operands) 
LSExpression
And
(IEnumerable<LSExpression> operands) Creates an AND expression. This method is a shortcut for
CreateExpression(LSOperator.And, operands)
.See: LSOperator.And See: LSModel.CreateExpression Since: 5.5

LSExpression
Or
()¶ 
LSExpression
Or
(params LSExpression[] operands) 
LSExpression
Or
(IEnumerable<LSExpression> operands) Creates a OR expression. This method is a shortcut for
CreateExpression(LSOperator.Or, operands)
.See: LSOperator.Or See: LSModel.CreateExpression Since: 5.5

LSExpression
Xor
()¶ 
LSExpression
Xor
(params LSExpression[] operands) 
LSExpression
Xor
(IEnumerable<LSExpression> operands) Creates a XOR expression. This method is a shortcut for
CreateExpression(LSOperator.Xor, operands)
.See: LSOperator.Xor See: LSModel.CreateExpression Since: 5.5

LSExpression
Abs
(LSExpression a)¶ Creates an absolute value expression. This method is a shortcut for
CreateExpression(LSOperator.Abs, a)
.See: LSOperator.Abs See: LSModel.CreateExpression Since: 5.5

LSExpression
Dist
(LSExpression a, LSExpression b)¶ 
LSExpression
Dist
(long a, LSExpression b) 
LSExpression
Dist
(double a, LSExpression b) 
LSExpression
Dist
(LSExpression a, long b) 
LSExpression
Dist
(LSExpression a, double b) Creates a distance expression. This method is a shortcut for
CreateExpression(LSOperator.Dist, a, b)
.See: LSOperator.Dist See: LSModel.CreateExpression Since: 5.5

LSExpression
Div
(LSExpression a, LSExpression b)¶ 
LSExpression
Div
(long a, LSExpression b) 
LSExpression
Div
(double a, LSExpression b) 
LSExpression
Div
(LSExpression a, long b) 
LSExpression
Div
(LSExpression a, double b) Creates a division expression. This method is a shortcut for
CreateExpression(LSOperator.Div, a, b)
.See: LSOperator.Div See: LSModel.CreateExpression Since: 5.5

LSExpression
Mod
(LSExpression a, LSExpression b)¶ 
LSExpression
Mod
(long a, LSExpression b) 
LSExpression
Mod
(LSExpression a, long b) Creates a modulo expression. This method is a shortcut for
CreateExpression(LSOperator.Mod, a, b)
.See: LSOperator.Mod See: LSModel.CreateExpression Since: 5.5

LSExpression
Array
()¶ 
LSExpression
Array
(params LSExpression[] operands) 
LSExpression
Array
(params long[] operands) 
LSExpression
Array
(params double[] operands) 
LSExpression
Array
(IEnumerable<LSExpression> operands) 
LSExpression
Array
(IEnumerable<double> operands) 
LSExpression
Array
(IEnumerable<long> operands) Creates an array expression. This method is a shortcut for
CreateExpression(LSOperator.Array, operands)
.See: LSOperator.Array See: LSModel.CreateExpression Since: 5.5

LSExpression
At
(LSExpression array, params LSExpression[] indices)¶ 
LSExpression
At
(LSExpression array, params long[] indices) 
LSExpression
At
(LSExpression array, IEnumerable<LSExpression> indices) 
LSExpression
At
(LSExpression array, IEnumerable<long> indices) Creates a “at” expression for Ndimensional array. This method is a shortcut for
CreateExpression(LSOperator.At, arrayExpr, operands)
.See: LSOperator.At See: LSModel.CreateExpression Since: 5.5

LSExpression
Scalar
(LSExpression a, LSExpression b)¶ Creates an expression for the scalar product between two arrays. This method is a shortcut for
CreateExpression(LSOperator.Scalar, a, b)
.See: LSOperator.Scalar See: LSModel.CreateExpression Since: 5.5

LSExpression
Ceil
(LSExpression a)¶ Creates a ceil expression. This method is a shortcut for
CreateExpression(LSOperator.Ceil, a)
.See: LSOperator.Ceil See: LSModel.CreateExpression Since: 5.5

LSExpression
Floor
(LSExpression a)¶ Creates a floor expression. This method is a shortcut for
CreateExpression(LSOperator.Floor, a)
.See: LSOperator.Floor See: LSModel.CreateExpression Since: 5.5

LSExpression
Round
(LSExpression a)¶ Creates a rounding expression. This method is a shortcut for
CreateExpression(LSOperator.Round, a)
.See: LSOperator.Round See: LSModel.CreateExpression Since: 5.5

LSExpression
Sqrt
(LSExpression a)¶ Creates a square root expression. This method is a shortcut for
CreateExpression(LSOperator.Sqrt, a)
.See: LSOperator.Sqrt See: LSModel.CreateExpression Since: 5.5

LSExpression
Log
(LSExpression a)¶ Creates a log expression. This method is a shortcut for
CreateExpression(LSOperator.Log, a)
.See: LSOperator.Log See: LSModel.CreateExpression Since: 5.5

LSExpression
Exp
(LSExpression a)¶ Creates an exponential expression. This method is a shortcut for
CreateExpression(LSOperator.Exp, a)
.See: LSOperator.Exp See: LSModel.CreateExpression Since: 5.5

LSExpression
Pow
(LSExpression a, LSExpression b)¶ 
LSExpression
Pow
(long a, LSExpression b) 
LSExpression
Pow
(double a, LSExpression b) 
LSExpression
Pow
(LSExpression a, long b) 
LSExpression
Pow
(LSExpression a, double b) Creates a power expression. This method is a shortcut for
CreateExpression(LSOperator.Pow, a, b)
.See: LSOperator.Pow See: LSModel.CreateExpression Since: 5.5

LSExpression
Cos
(LSExpression a)¶ Creates a cosine expression. This method is a shortcut for
CreateExpression(LSOperator.Cos, a)
.See: LSOperator.Cos See: LSModel.CreateExpression Since: 5.5

LSExpression
Sin
(LSExpression a)¶ Creates a sine expression. This method is a shortcut for
CreateExpression(LSOperator.Sin, a)
.See: LSOperator.Sin See: LSModel.CreateExpression Since: 5.5

LSExpression
Tan
(LSExpression a)¶ Creates a tangent expression. This method is a shortcut for
CreateExpression(LSOperator.Tan, a)
.See: LSOperator.Tan See: LSModel.CreateExpression Since: 5.5

LSExpression
Piecewise
(LSExpression abscissae, LSExpression ordinates, LSExpression x)¶ Creates a piecewise linear expression. This method is a shortcut for
CreateExpression(LSOperator.Piecewise, expr, b, c)
.See: LSOperator.Piecewise See: LSModel.CreateExpression Since: 5.5

LSExpression
Count
(LSExpression list)¶ Creates a count expression. This method is a shortcut for
CreateExpression(LSOperator.Count, a)
.See: LSOperator.Count See: LSModel.CreateExpression Since: 5.5

LSExpression
IndexOf
(LSExpression list, LSExpression val)¶ 
LSExpression
IndexOf
(LSExpression list, long val) Creates an indexOf expression. This method is a shortcut for
CreateExpression(LSOperator.IndexOf, a, b)
.See: LSOperator.IndexOf See: LSModel.CreateExpression Since: 5.5

LSExpression
Contains
(LSExpression list, LSExpression val)¶ 
LSExpression
Contains
(LSExpression list, long val) Creates a contains expression. This method is a shortcut for
CreateExpression(LSOperator.Contains, a, b)
.See: LSOperator.Contains See: LSModel.CreateExpression Since: 7.5

LSExpression
Partition
()¶ 
LSExpression
Partition
(params LSExpression[] operands) 
LSExpression
Partition
(IEnumerable<LSExpression> operands) Creates a partition expression. This method is a shortcut for
CreateExpression(LSOperator.Partition, operands)
.See: LSOperator.Partition See: LSModel.CreateExpression Since: 5.5

LSExpression
Disjoint
()¶ 
LSExpression
Disjoint
(params LSExpression[] operands) 
LSExpression
Disjoint
(IEnumerable<LSExpression> operands) Creates a disjoint expression. This method is a shortcut for
CreateExpression(LSOperator.Disjoint, operands)
.See: LSOperator.Disjoint See: LSModel.CreateExpression Since: 5.5

LSExpression
IntExternalFunction
(LSIntExternalFunction function)¶ Creates an integer external function. This method is a shortcut for
CreateIntExternalFunction
.See: LSOperator.ExternalFunction See: LSModel.CreateIntExternalFunction Since: 9.5

LSExpression
DoubleExternalFunction
(LSDoubleExternalFunction function)¶ Creates a double external function. This method is a shortcut for
CreateDoubleExternalFunction
.See: LSOperator.ExternalFunction See: LSModel.CreateDoubleExternalFunction Since: 9.5

LSExpression
DoubleBlackBoxFunction
(LSDoubleBlackBoxFunction function)¶ Creates a double blackbox function. This method is a shortcut for
CreateDoubleBlackBoxFunction
.See: LSOperator.BlackBoxFunction See: LSModel.CreateDoubleBlackBoxFunction Since: 9.5

LSExpression
LambdaFunction
(LSLambdaFunction0 functor)¶ 
LSExpression
LambdaFunction
(LSLambdaFunction1 functor) 
LSExpression
LambdaFunction
(LSLambdaFunction2 functor) 
LSExpression
LambdaFunction
(LSLambdaFunction3 functor) 
LSExpression
LambdaFunction
(int nbArgs, LSLambdaFunction functor) Creates a lambda function expression. This method is a shortcut for
CreateLambdaFunction(functor)
.See: LSOperator.LambdaFunction See: LSModel.CreateLambdaFunction Since: 9.5

LSExpression
Call
()¶ 
LSExpression
Call
(LSExpression func) 
LSExpression
Call
(LSExpression func, params LSExpression[] arguments) 
LSExpression
Call
(LSExpression func, IEnumerable<LSExpression> arguments) 
LSExpression
Call
(params LSExpression[] operands) 
LSExpression
Call
(IEnumerable<LSExpression> operands) Creates a call expression. The first operand must be an LSExpression of type
Function
orExternalFunction
. The other operands may be LSExpressions, booleans, integers, and doubles. They are passed to the function as arguments. This method is a shortcut forCreateExpression(LSOperator.Call, operands)
.See: LSOperator.Call See: LSModel.CreateExpression Since: 6.0

LSExpression
Range
(LSExpression a, LSExpression b)¶ 
LSExpression
Range
(LSExpression a, long b) 
LSExpression
Range
(long a, LSExpression b) 
LSExpression
Range
(long a, long b) Creates a range expression, where a is the lower bound (inclusive) and b is the upper bound (exclusive). This method is a shortcut for
CreateExpression(LSOperator.Range, a, b)
.See: LSOperator.Range See: LSModel.CreateExpression Since: 7.0

string
ToString
()¶ Returns a string representation of this model. This representation provides: * The number of expressions, decisions, constraints, and objectives. * The density of the model.
Useful for debugging or logging purposes.
Returns: String representation. Return type: string