# 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 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. CreateIntBlackBoxFunction Creates an integer black-box function. CreateDoubleBlackBoxFunction Creates a double black-box 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 \u201cat\u201d expression for N-dimensional 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. Cover Creates a cover expression. Find Creates a find expression. IntExternalFunction Creates an integer external function. DoubleExternalFunction Creates a double external function. IntBlackBoxFunction Creates an integer black-box function. DoubleBlackBoxFunction Creates a double black-box 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 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 or double) – Value of the constant Created constant expression 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.e long, double or LSExpression):

// 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 or LSExpression) – Operand 0 b (long, double or LSExpression) – Operand 1 c (long, double or LSExpression) – Operand 2 operands – Operands. Created expression. LSExpression
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 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 an LSExpression that will be used as the body of the new LocalSolver function you want to create. Expression of type LambdaFunction.
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 the LSExternalArgumentValues.

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 is LocalSolver.Stop().

Note 2: Your functions must be thread-safe. According to the “nbThreads” parameter, LocalSolver can be multi-threaded. In that case, your external functions must be thread safe. If you cannot guarantee the thread-safety 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 (see LSExpression.GetExternalContext().

Since: 9.5 function (LSIntExternalFunction) – External function to call, passed as a delegate. The expression associated to the function. 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 the LSExternalArgumentValues.

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 is LocalSolver.Stop().

Note 2: Your functions must be thread-safe. According to the “nbThreads” parameter, LocalSolver can be multi-threaded. In that case, your external functions must be thread safe. If you cannot guarantee the thread-safety 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 (see LSExpression.GetExternalContext().

Since: 9.5 function (LSDoubleExternalFunction) – External function to call, passed as a delegate. The expression associated to the function. LSExpression
LSExpression CreateIntBlackBoxFunction(LSIntBlackBoxFunction function)

Creates an integer black-box function. The argument must implement LSIntBlackBoxFunction. When the black-box function is called, the argument values will be made accessible to your function through the LSBlackBoxArgumentValues.

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 (see LSExpression.GetBlackBoxContext()).

Since: 10.0 function (LSIntBlackBoxFunction) – Black-box function to call, passed as a delegate. The expression associated to the function. LSExpression
LSExpression CreateDoubleBlackBoxFunction(LSDoubleBlackBoxFunction function)

Creates a double black-box function. The argument must implement LSDoubleBlackBoxFunction. When the black-box function is called, the argument values will be made accessible to your function through the LSBlackBoxArgumentValues.

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 (see LSExpression.GetBlackBoxContext()).

Since: 9.5 function (LSDoubleBlackBoxFunction) – Black-box function to call, passed as a delegate. The expression associated to the function. LSExpression
int GetNbExpressions()

Returns the number of expressions added to this model.

See: LSModel.GetExpression(int) Number of expressions. int
LSExpression GetExpression(int exprIndex)

Gets the expression with the given index in this model. Throws an exception if exprIndex < 0 or exprIndex >= GetNbExpressions()

See: LSModel.GetNbExpressions() exprIndex (int) – Index of the expression. Expression with the given index. 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. Expression with the given name. 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 or LSOperator.List) declared in the model.

See: LSModel.GetDecision() Number of decisions. int
LSExpression GetDecision(int decisionIndex)

Gets the decision with the given index. Throws an exception if decisionIndex < 0 or decisionIndex >= GetNbDecisions()

See: LSModel.GetNbDecisions() exprIndex – Index of the decision. Decision with the given index. 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.

Arguments: expr (LSExpression) – Expression to constraint.
void Constraint(LSExpression expr)

Shortcut for AddConstraint(expr).

Since: 5.5 LSModel.AddConstraint(LSExpression) 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 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 LSModel.GetConstraint(int) constraintIndex (int) – Index of the constraint to remove
int GetNbConstraints()

Returns the number of constraints added to this model.

See: LSModel.GetConstraint(int) Number of constraints. int
LSExpression GetConstraint(int constraintIndex)

Gets the constraint with the given index in this model. Throws an exception if constraintIndex < 0 or constraintIndex >= GetNbConstraints().

See: LSModel.GetNbConstraints() constraintIndex (int) – Index of the constraint. Constraint with the given index. 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 LSModel.AddObjective(LSExpression, LSObjectiveDirection) expr (LSExpression) – Expression to minimize.
void Maximize(LSExpression expr)

Shortcut for AddObjective(LSObjectiveDirection.Maximize, expr).

Since: 5.5 LSModel.AddObjective(LSExpression, LSObjectiveDirection) 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 (with LSPhase.SetEnabled(bool)).

Only allowed in state Modeling.

Since: 5.0 objectiveIndex (int) – position of the objective to remove.
int GetNbObjectives()

Returns the number of objectives added to this model.

See: LSModel.GetObjective(int) Number of objectives. int
LSExpression GetObjective(int objectiveIndex)

Gets the objective with the given index in this model. Throws an exception if objectiveIndex < 0 or objectiveIndex >= GetNbObjectives().

See: LSModel.GetNbObjectives() objectiveIndex (int) – Index of the objective. Objective with the given index. LSExpression
LSObjectiveDirection GetObjectiveDirection(int objectiveIndex)

Gets the direction of the objective with the given index.

See: LSModel.GetObjective(int) objectiveIndex (int) – Index of the objective. Objective direction. 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() Number of operands. int
void Close()

Closes the model. Only allowed in state Modeling. When this method is called, the solver is placed in state Stopped.

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 state Modeling.

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. 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 LSModel.CreateExpression 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. LSOperator.Float LSModel.CreateExpression 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. LSOperator.Int LSModel.CreateExpression 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, n-1]. This method is a shortcut for CreateExpression(LSOperator.List, n).

See: LSOperator.List LSModel.CreateExpression 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, n-1]. This method is a shortcut for CreateExpression(LSOperator.Set, n).

See: LSOperator.Set LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 5.5
LSExpression Not(LSExpression a)

Creates a NOT expression. This method is a shortcut for CreateExpression(LSOperator.Not, a).

See: LSOperator.Not LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 5.5
LSExpression Abs(LSExpression a)

Creates an absolute value expression. This method is a shortcut for CreateExpression(LSOperator.Abs, a).

See: LSOperator.Abs LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 N-dimensional array. This method is a shortcut for CreateExpression(LSOperator.At, arrayExpr, operands).

See: LSOperator.At LSModel.CreateExpression 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 LSModel.CreateExpression 5.5
LSExpression Ceil(LSExpression a)

Creates a ceil expression. This method is a shortcut for CreateExpression(LSOperator.Ceil, a).

See: LSOperator.Ceil LSModel.CreateExpression 5.5
LSExpression Floor(LSExpression a)

Creates a floor expression. This method is a shortcut for CreateExpression(LSOperator.Floor, a).

See: LSOperator.Floor LSModel.CreateExpression 5.5
LSExpression Round(LSExpression a)

Creates a rounding expression. This method is a shortcut for CreateExpression(LSOperator.Round, a).

See: LSOperator.Round LSModel.CreateExpression 5.5
LSExpression Sqrt(LSExpression a)

Creates a square root expression. This method is a shortcut for CreateExpression(LSOperator.Sqrt, a).

See: LSOperator.Sqrt LSModel.CreateExpression 5.5
LSExpression Log(LSExpression a)

Creates a log expression. This method is a shortcut for CreateExpression(LSOperator.Log, a).

See: LSOperator.Log LSModel.CreateExpression 5.5
LSExpression Exp(LSExpression a)

Creates an exponential expression. This method is a shortcut for CreateExpression(LSOperator.Exp, a).

See: LSOperator.Exp LSModel.CreateExpression 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 LSModel.CreateExpression 5.5
LSExpression Cos(LSExpression a)

Creates a cosine expression. This method is a shortcut for CreateExpression(LSOperator.Cos, a).

See: LSOperator.Cos LSModel.CreateExpression 5.5
LSExpression Sin(LSExpression a)

Creates a sine expression. This method is a shortcut for CreateExpression(LSOperator.Sin, a).

See: LSOperator.Sin LSModel.CreateExpression 5.5
LSExpression Tan(LSExpression a)

Creates a tangent expression. This method is a shortcut for CreateExpression(LSOperator.Tan, a).

See: LSOperator.Tan LSModel.CreateExpression 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 LSModel.CreateExpression 5.5
LSExpression Count(LSExpression list)

Creates a count expression. This method is a shortcut for CreateExpression(LSOperator.Count, a).

See: LSOperator.Count LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 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 LSModel.CreateExpression 5.5
LSExpression Cover()
LSExpression Cover(params LSExpression[] operands)
LSExpression Cover(IEnumerable<LSExpression> operands)

Creates a cover expression. This method is a shortcut for CreateExpression(LSOperator.Cover, operands).

See: LSOperator.Cover LSModel.CreateExpression 10.5
LSExpression Find()
LSExpression Find(LSExpression array, long val)
LSExpression Find(LSExpression array, LSExpression val)

Creates a find expression. This method is a shortcut for CreateExpression(LSOperator.Find, a, b).

See: LSOperator.Find LSModel.CreateExpression 10.5
LSExpression IntExternalFunction(LSIntExternalFunction function)

Creates an integer external function. This method is a shortcut for CreateIntExternalFunction.

See: LSOperator.ExternalFunction LSModel.CreateIntExternalFunction 9.5
LSExpression DoubleExternalFunction(LSDoubleExternalFunction function)

Creates a double external function. This method is a shortcut for CreateDoubleExternalFunction.

See: LSOperator.ExternalFunction LSModel.CreateDoubleExternalFunction 9.5
LSExpression IntBlackBoxFunction(LSIntBlackBoxFunction function)

Creates an integer black-box function. This method is a shortcut for CreateIntBlackBoxFunction.

See: LSOperator.BlackBoxFunction LSModel.CreateIntBlackBoxFunction 10.0
LSExpression DoubleBlackBoxFunction(LSDoubleBlackBoxFunction function)

Creates a double black-box function. This method is a shortcut for CreateDoubleBlackBoxFunction.

See: LSOperator.BlackBoxFunction LSModel.CreateDoubleBlackBoxFunction 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 LSModel.CreateLambdaFunction 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 or ExternalFunction. The other operands may be LSExpressions, booleans, integers, and doubles. They are passed to the function as arguments. This method is a shortcut for CreateExpression(LSOperator.Call, operands).

See: LSOperator.Call LSModel.CreateExpression 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 LSModel.CreateExpression 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. string