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 reope it (with
LSModel.open()
) or instantiate another LocalSolver environment to optimize another model.- See
- See
Summary¶
Returns the LocalSolver object associated to this model. |
|
Creates a constant expression representing the given value. |
|
Creates an expression of the given type, with the given ordered operands. |
|
Creates a lambda function with arguments. |
|
Creates an integer external function. |
|
Creates a double external function. |
|
Creates an integer array external function. |
|
Creates a double array external function. |
|
Returns the number of expressions added to this model. |
|
Gets the expression with the given index in this model. |
|
Gets the number of decisions in the model. |
|
Gets the decision with the given index. |
|
Adds the given expression to the list of constraints. |
|
Shortcut for AddConstraint(expr). |
|
Removes the given expression from the list of constraints. |
|
Returns the number of constraints added to this model. |
|
Gets the constraint with the given index in this model. |
|
Adds the given expression to the list of objectives to optimize. |
|
Shortcut for AddObjective(LSObjectiveDirection.Minimize, expr). |
|
Shortcut for AddObjective(LSObjectiveDirection.Maximize, expr). |
|
Removes the objective at the given position in the list of objectives. |
|
Returns the number of objectives added to this model. |
|
Gets the objective with the given index in this model. |
|
Gets the direction of the objective with the given index. |
|
Gets the number of operands in the model. |
|
Closes the model. |
|
Reopens the model. |
|
Returns true if the model is closed, false otherwise. |
|
Creates a boolean decision. |
|
Creates a float decision. |
|
Creates an integer decision. |
|
Creates a list decision with the given length. |
|
Creates a set decision with the given length. |
|
Creates a sum expression. |
|
Creates a substraction expression. |
|
Creates a product expression. |
|
Creates a maximum expression. |
|
Creates a minimum expression. |
|
Creates an equality expression. |
|
Creates a disequality expression. |
|
Creates an inequality expression greater than or equal to. |
|
Creates an inequality expression less than or equal to. |
|
Creates an inequality expression greater than. |
|
Creates an inequality expression less than. |
|
Creates a ternary conditional expression. |
|
Creates a NOT expression. |
|
Creates an AND expression. |
|
Creates a OR expression. |
|
Creates a XOR expression. |
|
Creates an absolute value expression. |
|
Creates a distance expression. |
|
Creates a division expression. |
|
Creates a modulo expression. |
|
Creates an array expression. |
|
Creates a “at” expression for N-dimensional array. |
|
Creates an expression for the scalar product between two arrays. |
|
Creates a ceil expression. |
|
Creates a floor expression. |
|
Creates a rounding expression. |
|
Creates a square root expression. |
|
Creates a log expression. |
|
Creates an exponential expression. |
|
Creates a power expression. |
|
Creates a cosine expression. |
|
Creates a sine expression. |
|
Creates a tangent expression. |
|
Creates a piecewise linear expression. |
|
Creates a count expression. |
|
Creates an indexOf expression. |
|
Creates a contains expression. |
|
Creates a partition expression. |
|
Creates a disjoint expression. |
|
Creates a cover expression. |
|
Creates a find expression. |
|
Creates a sort expression. |
|
Creates an integer external function. |
|
Creates a double external function. |
|
Creates an integer array external function. |
|
Creates a double array external function. |
|
Creates a lambda function expression. |
|
Creates a call expression. |
|
Creates a range expression, where a is the lower bound (inclusive) and b is the upper bound (exclusive). |
|
Returns a string representation of this model. |
Instance methods¶
- LocalSolver GetLocalSolver()¶
Returns the LocalSolver object associated to this model.
- Returns
LocalSolver object
- Return type
- 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 constant- Returns
Created constant expression
- Return type
- 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 0b (
long
,double
orLSExpression
) – Operand 1c (
long
,double
orLSExpression
) – Operand 2operands – 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
.
- 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 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 (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 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 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 (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 CreateIntArrayExternalFunction(LSIntArrayExternalFunction function)¶
Creates an integer array external function. The argument must implement
LSIntArrayExternalFunction
. 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.- Since
11.0
- Arguments
function (LSIntArrayExternalFunction) – External function to call, passed as a delegate.
- Returns
The expression associated to the function.
- Return type
- LSExpression CreateDoubleArrayExternalFunction(LSDoubleArrayExternalFunction function)¶
Creates a double array external function. The argument must implement
LSDoubleArrayExternalFunction
. 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.- Since
11.0
- Arguments
function (LSDoubleArrayExternalFunction) – External function to call, passed as a delegate.
- Returns
The expression associated to the function.
- Return type
- int GetNbExpressions()¶
Returns the number of expressions added to this model.
- See
- 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
- Arguments
exprIndex (
int
) – Index of the expression.- Returns
Expression with the given index.
- Return type
- 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
- 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
- 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
- Arguments
exprIndex – Index of the decision.
- Returns
Decision with the given index.
- Return type
- 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
- See
- 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
- Arguments
constraintIndex (
int
) – Index of the constraint to remove
- int GetNbConstraints()¶
Returns the number of constraints added to this model.
- See
- 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
- Arguments
constraintIndex (
int
) – Index of the constraint.- Returns
Constraint with the given index.
- Return type
- 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
- Arguments
expr (LSExpression) – Expression to minimize.
- void Maximize(LSExpression expr)¶
Shortcut for
AddObjective(LSObjectiveDirection.Maximize, expr)
.- Since
5.5
- See
- 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
- 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
- Arguments
objectiveIndex (int) – Index of the objective.
- Returns
Objective with the given index.
- Return type
- LSObjectiveDirection GetObjectiveDirection(int objectiveIndex)¶
Gets the direction of the objective with the given index.
- See
- Arguments
objectiveIndex (int) – Index of the objective.
- Returns
Objective direction.
- Return type
- 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
- 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
- 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
- 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
- See
- 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, n-1]. This method is a shortcut for
CreateExpression(LSOperator.List, n)
.- See
- See
- 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, n-1]. This method is a shortcut for
CreateExpression(LSOperator.Set, n)
.- See
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- Since
5.5
- LSExpression Not(LSExpression a)¶
Creates a NOT expression. This method is a shortcut for
CreateExpression(LSOperator.Not, a)
.- See
- See
- 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
- See
- 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
- See
- 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
- See
- Since
5.5
- LSExpression Abs(LSExpression a)¶
Creates an absolute value expression. This method is a shortcut for
CreateExpression(LSOperator.Abs, a)
.- See
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- 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 N-dimensional array. This method is a shortcut for
CreateExpression(LSOperator.At, arrayExpr, operands)
.- See
- See
- 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
- See
- Since
5.5
- LSExpression Ceil(LSExpression a)¶
Creates a ceil expression. This method is a shortcut for
CreateExpression(LSOperator.Ceil, a)
.- See
- See
- Since
5.5
- LSExpression Floor(LSExpression a)¶
Creates a floor expression. This method is a shortcut for
CreateExpression(LSOperator.Floor, a)
.- See
- See
- Since
5.5
- LSExpression Round(LSExpression a)¶
Creates a rounding expression. This method is a shortcut for
CreateExpression(LSOperator.Round, a)
.- See
- See
- Since
5.5
- LSExpression Sqrt(LSExpression a)¶
Creates a square root expression. This method is a shortcut for
CreateExpression(LSOperator.Sqrt, a)
.- See
- See
- Since
5.5
- LSExpression Log(LSExpression a)¶
Creates a log expression. This method is a shortcut for
CreateExpression(LSOperator.Log, a)
.- See
- See
- Since
5.5
- LSExpression Exp(LSExpression a)¶
Creates an exponential expression. This method is a shortcut for
CreateExpression(LSOperator.Exp, a)
.- See
- See
- 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
- See
- Since
5.5
- LSExpression Cos(LSExpression a)¶
Creates a cosine expression. This method is a shortcut for
CreateExpression(LSOperator.Cos, a)
.- See
- See
- Since
5.5
- LSExpression Sin(LSExpression a)¶
Creates a sine expression. This method is a shortcut for
CreateExpression(LSOperator.Sin, a)
.- See
- See
- Since
5.5
- LSExpression Tan(LSExpression a)¶
Creates a tangent expression. This method is a shortcut for
CreateExpression(LSOperator.Tan, a)
.- See
- See
- 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
- See
- Since
5.5
- LSExpression Count(LSExpression list)¶
Creates a count expression. This method is a shortcut for
CreateExpression(LSOperator.Count, a)
.- See
- See
- 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
- See
- 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
- See
- 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
- See
- 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
- See
- Since
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
- See
- Since
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
- See
- Since
10.5
- LSExpression Sort(LSExpression array)¶
Creates a sort expression. This method is a shortcut for
CreateExpression(LSOperator.Sort, array)
.The first operand must be an LSExpression representing a one-dimensional array containing integers or doubles.
- See
- See
- Since
11.0
- LSExpression IntExternalFunction(LSIntExternalFunction function)¶
Creates an integer external function. This method is a shortcut for
CreateIntExternalFunction
.- See
- See
- Since
9.5
- LSExpression DoubleExternalFunction(LSDoubleExternalFunction function)¶
Creates a double external function. This method is a shortcut for
CreateDoubleExternalFunction
.- See
- See
- Since
9.5
- LSExpression IntArrayExternalFunction(LSIntArrayExternalFunction function)¶
Creates an integer array external function. This method is a shortcut for
CreateIntArrayExternalFunction
.- See
- See
- Since
11.0
- LSExpression DoubleArrayExternalFunction(LSDoubleArrayExternalFunction function)¶
Creates a double array external function. This method is a shortcut for
CreateDoubleArrayExternalFunction
.- See
- See
- Since
11.0
- 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
- See
- 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
- See
- 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
- See
- 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