HxModel Class

class Hexaly.Optimizer.HxModel

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 optimizer can be launched to resolve it. Note that you cannot modify a model which has been closed: you must reopen it (with HxModel.open) or instantiate another Hexaly Optimizer environment to optimize another model.

See:HxExpression
See:HxOperator

Summary

Methods
GetOptimizer Returns the Hexaly Optimizer object associated to this model.
CreateConstant Creates a constant expression representing the given value.
CreateConstArray Creates a constant array expression containing the given values.
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.
CreateIntArrayExternalFunction Creates an integer array external function.
CreateDoubleArrayExternalFunction Creates a double array external 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(HxObjectiveDirection.Minimize, expr).
Maximize Shortcut for AddObjective(HxObjectiveDirection.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.
Interval Creates an interval decision included in [minStart, maxEnd).
OptionalInterval Creates an optional interval decision, which can either be absent (void) or included in [minStart, maxEnd).
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.
StepArray Creates a step array.
ConstArray Creates a int constant array.
At Creates a “at” 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.
Start Creates a start expression.
End Creates an end expression.
Length Creates a length expression.
Presence Creates a presence expression.
Count Creates a count expression.
IndexOf Creates an indexOf expression.
Distinct Creates a distinct expression.
Intersection Creates an intersection expression of intervals.
Union Creates an union expression.
Hull Creates a hull 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.
Sort Creates a sort expression.
IntExternalFunction Creates an integer external function.
DoubleExternalFunction Creates a double external function.
IntArrayExternalFunction Creates an integer array external function.
DoubleArrayExternalFunction Creates a double array external 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

HexalyOptimizer GetOptimizer()

Returns the Hexaly Optimizer object associated to this model.

Returns:HexalyOptimizer object
Return type:HexalyOptimizer
HxExpression CreateConstant(long value)
HxExpression 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
Returns:Created constant expression
Return type:HxExpression
HxExpression CreateConstArray(long[] values)
HxExpression CreateConstArray(double[] values)

Creates a constant array expression containing the given values. Only allowed in state Modeling. Note that the constant array created does not have operands.

Since:13.5
Arguments:values – Array containing the constant values
Returns:Created constant array expression
Return type:HxExpression
HxExpression CreateExpression(HxOperator op)
HxExpression CreateExpression(HxOperator op, params HxExpression[] operands)
HxExpression CreateExpression(HxOperator op, params long[] operands)
HxExpression CreateExpression(HxOperator op, params double[] operands)
HxExpression CreateExpression(HxOperator op, IEnumerable<HxExpression> operands)
HxExpression CreateExpression(HxOperator op, IEnumerable<long> operands)
HxExpression CreateExpression(HxOperator op, IEnumerable<double> operands)
HxExpression CreateExpression(HxOperator op, HxExpression a, long b)
HxExpression CreateExpression(HxOperator op, long a, long b, HxExpression c)
HxExpression CreateExpression(HxOperator op, long a, HxExpression b, long c)
HxExpression CreateExpression(HxOperator op, long a, HxExpression b, HxExpression c)
HxExpression CreateExpression(HxOperator op, HxExpression a, long b, long c)
HxExpression CreateExpression(HxOperator op, HxExpression a, long b, HxExpression c)
HxExpression CreateExpression(HxOperator op, HxExpression a, HxExpression b, long c)
HxExpression CreateExpression(HxOperator op, double a, HxExpression b)
HxExpression CreateExpression(HxOperator op, HxExpression a, double b)
HxExpression CreateExpression(HxOperator op, double a, double b, HxExpression c)
HxExpression CreateExpression(HxOperator op, double a, HxExpression b, double c)
HxExpression CreateExpression(HxOperator op, double a, HxExpression b, HxExpression c)
HxExpression CreateExpression(HxOperator op, HxExpression a, double b, double c)
HxExpression CreateExpression(HxOperator op, HxExpression a, double b, HxExpression c)
HxExpression CreateExpression(HxOperator op, HxExpression a, HxExpression 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 HxExpressions. 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 HxExpression):

// all the arguments (a, b, c, ...) must be of the same data type
CreateExpression(op, a, b, c, d, e, f, g)
Arguments:
Returns:

Created expression.

Return type:

HxExpression

HxExpression CreateLambdaFunction(HxLambdaFunction0 functor)
HxExpression CreateLambdaFunction(HxLambdaFunction1 functor)
HxExpression CreateLambdaFunction(HxLambdaFunction2 functor)
HxExpression CreateLambdaFunction(HxLambdaFunction3 functor)
HxExpression CreateLambdaFunction(int nbArgs, HxLambdaFunction 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 HxExpressions of type Argument).
  • The body of the function. The body is an HxExpression that will be used to evaluate the result of the function. The body can be any HxExpression composed of any operands and operators supported by Hexaly Optimizer. 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 HxExpression 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 HxExpression will be used as the body of the Hexaly Optimizer 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 HxLambdaFunction0, HxLambdaFunction1, HxLambdaFunction2 and HxLambdaFunction3.
  • function – A function (HxLambdaFunction) that accepts HxExpression as arguments and returns an HxExpression that will be used as the body of the new Hexaly Optimizer function you want to create.
Returns:

Expression of type LambdaFunction.

HxExpression CreateIntExternalFunction(HxIntExternalFunction function)

Creates an integer external function. The argument must implement HxIntExternalFunction. When the external function is called, the argument values will be made accessible to your function through the HxExternalArgumentValues.

Once you have instantiated it, you have to use HxModel.Call() to call it in your model.

Note 1: Most of the time your external function will be called when the optimizer is in state Running. Do not attempt to call any method of the optimizer (to retrieve statistics, values of HxExpressions or whatever) in that state or an exception will be thrown. The only accessible function is HexalyOptimizer.Stop().

Note 2: Your functions must be thread-safe. According to the “nbThreads” parameter, Hexaly Optimizer 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 Hexaly Optimizer to one thread with HxParam.SetNbThreads.

Note 3: You can provide additional data for your function (such as lower and upper bounds) with the help of the HxExternalContext associated with your function (see HxExpression.GetExternalContext().

Since:9.5
Arguments:function (HxIntExternalFunction) – External function to call, passed as a delegate.
Returns:The expression associated to the function.
Return type:HxExpression
HxExpression CreateDoubleExternalFunction(HxDoubleExternalFunction function)

Creates a double external function. The argument must implement HxDoubleExternalFunction. When the external function is called, the argument values will be made accessible to your function through the HxExternalArgumentValues.

Once you have instantiated it, you have to use HxModel.Call() to call it in your model.

Note 1: Most of the time your external function will be called when the optimizer is in state Running. Do not attempt to call any method of the optimizer (to retrieve statistics, values of HxExpressions or whatever) in that state or an exception will be thrown. The only accessible function is HexalyOptimizer.Stop().

Note 2: Your functions must be thread-safe. According to the “nbThreads” parameter, Hexaly Optimizer 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 Hexaly Optimizer to one thread with HxParam.SetNbThreads.

Note 3: You can provide additional data for your function (such as lower and upper bounds) with the help of the HxExternalContext associated with your function (see HxExpression.GetExternalContext().

Since:9.5
Arguments:function (HxDoubleExternalFunction) – External function to call, passed as a delegate.
Returns:The expression associated to the function.
Return type:HxExpression
HxExpression CreateIntArrayExternalFunction(HxIntArrayExternalFunction function)

Creates an integer array external function. The argument must implement HxIntArrayExternalFunction. When the external function is called, the argument values will be made accessible to your function through the HxExternalArgumentValues.

Once you have instantiated it, you have to use HxModel.Call() to call it in your model.

Since:11.0
Arguments:function (HxIntArrayExternalFunction) – External function to call, passed as a delegate.
Returns:The expression associated to the function.
Return type:HxExpression
HxExpression CreateDoubleArrayExternalFunction(HxDoubleArrayExternalFunction function)

Creates a double array external function. The argument must implement HxDoubleArrayExternalFunction. When the external function is called, the argument values will be made accessible to your function through the HxExternalArgumentValues.

Once you have instantiated it, you have to use HxModel.Call() to call it in your model.

Since:11.0
Arguments:function (HxDoubleArrayExternalFunction) – External function to call, passed as a delegate.
Returns:The expression associated to the function.
Return type:HxExpression
int GetNbExpressions()

Returns the number of expressions added to this model.

See:HxModel.GetExpression(int)
Returns:Number of expressions.
Return type:int
HxExpression GetExpression(int exprIndex)

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

See:HxModel.GetNbExpressions()
Arguments:exprIndex (int) – Index of the expression.
Returns:Expression with the given index.
Return type:HxExpression
HxExpression 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:HxExpression
int GetNbDecisions()

Gets the number of decisions in the model. This corresponds to the number of decision variables (HxOperator.Bool, HxOperator.Float, HxOperator.Int, HxOperator.List or HxOperator.Set) declared in the model.

See:HxModel.GetDecision()
Returns:Number of decisions.
Return type:int
HxExpression GetDecision(int decisionIndex)

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

See:HxModel.GetNbDecisions()
Arguments:exprIndex – Index of the decision.
Returns:Decision with the given index.
Return type:HxExpression
void AddConstraint(HxExpression 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 optimizer. 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 (HxExpression) – Expression to constraint.
void Constraint(HxExpression expr)

Shortcut for AddConstraint(expr).

Since:5.5
See:HxModel.AddConstraint(HxExpression)
Arguments:expr (HxExpression) – Expression to constraint.
void RemoveConstraint(HxExpression 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 (HxExpression) – 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:HxModel.GetConstraint(int)
Arguments:constraintIndex (int) – Index of the constraint to remove
int GetNbConstraints()

Returns the number of constraints added to this model.

See:HxModel.GetConstraint(int)
Returns:Number of constraints.
Return type:int
HxExpression GetConstraint(int constraintIndex)

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

See:HxModel.GetNbConstraints()
Arguments:constraintIndex (int) – Index of the constraint.
Returns:Constraint with the given index.
Return type:HxExpression
void AddObjective(HxExpression expr, HxObjectiveDirection 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:
void Minimize(HxExpression expr)

Shortcut for AddObjective(HxObjectiveDirection.Minimize, expr).

Since:5.5
See:HxModel.AddObjective(HxExpression, HxObjectiveDirection)
Arguments:expr (HxExpression) – Expression to minimize.
void Maximize(HxExpression expr)

Shortcut for AddObjective(HxObjectiveDirection.Maximize, expr).

Since:5.5
See:HxModel.AddObjective(HxExpression, HxObjectiveDirection)
Arguments:expr (HxExpression) – 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 HxPhase.SetOptimizedObjective(int)), or to disable it (with HxPhase.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:HxModel.GetObjective(int)
Returns:Number of objectives.
Return type:int
HxExpression GetObjective(int objectiveIndex)

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

See:HxModel.GetNbObjectives()
Arguments:objectiveIndex (int) – Index of the objective.
Returns:Objective with the given index.
Return type:HxExpression
HxObjectiveDirection GetObjectiveDirection(int objectiveIndex)

Gets the direction of the objective with the given index.

See:HxModel.GetObjective(int)
Arguments:objectiveIndex (int) – Index of the objective.
Returns:Objective direction.
Return type:HxObjectiveDirection
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:HxExpression.GetNbOperands()
Returns:Number of operands.
Return type:int
void Close()

Closes the model. Only allowed in state Modeling. When this method is called, the optimizer 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:HxModel.Open()
void Open()

Reopens the model. Only allowed in state Stopped. When this method is called, the optimizer 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:HxModel.Close()
bool IsClosed()

Returns true if the model is closed, false otherwise.

Returns:True if the model is closed.
Return type:bool
HxExpression Bool()

Creates a boolean decision. Binary decision variable with domain { 0, 1 }. This method is a shortcut for CreateExpression(HxOperator.Bool).

See:HxOperator.Bool
See:HxModel.CreateExpression
Since:5.5
HxExpression Float(double lb, double ub)

Creates a float decision. Decision variable with domain [lb, ub]. This method is a shortcut for CreateExpression(HxOperator.Float, lb, ub).

Arguments:
  • lb (double) – Lower bound of the decision variable.
  • ub (double) – Upper bound of the decision variable.
See:

HxOperator.Float

See:

HxModel.CreateExpression

Since:

5.5

HxExpression Int(long lb, long ub)

Creates an integer decision. Decision variable with domain [lb, ub]. This method is a shortcut for CreateExpression(HxOperator.Int, lb, ub).

Arguments:
  • lb (long) – Lower bound of the decision variable.
  • ub (long) – Upper bound of the decision variable.
See:

HxOperator.Int

See:

HxModel.CreateExpression

Since:

5.5

HxExpression Interval()

Creates an interval decision included in [minStart, maxEnd). Start is inclusive and end is exclusive. This method is a shortcut for CreateExpression(HxOperator.Interval).

Arguments:
  • minStart (long) – Min start of the decision variable.
  • maxEnd (long) – Max end of the decision variable.
See:

HxOperator.Interval

See:

HxModel.CreateExpression

Since:

12.0

HxExpression OptionalInterval()

Creates an optional interval decision, which can either be absent (void) or included in [minStart, maxEnd). When present, start is inclusive and end is exclusive. When absent, start and end are undefined. This method is a shortcut for CreateExpression(HxOperator.OptionalInterval).

Arguments:
  • minStart (long) – Min start of the decision variable.
  • maxEnd (long) – Max end of the decision variable.
See:

HxOperator.OptionalInterval

See:

HxModel.CreateExpression

Since:

14.0

HxExpression 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(HxOperator.List, n).

Arguments:n (long) – Collection size.
See:HxOperator.List
See:HxModel.CreateExpression
Since:5.5
HxExpression 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(HxOperator.Set, n).

Arguments:n (long) – Collection size.
See:HxOperator.Set
See:HxModel.CreateExpression
Since:8.0
HxExpression Sum()
HxExpression Sum(params HxExpression[] operands)
HxExpression Sum(IEnumerable<HxExpression> operands)
HxExpression Sum(HxExpression a)
HxExpression Sum(long a)
HxExpression Sum(double a)
HxExpression Sum(long a, HxExpression b)
HxExpression Sum(double a, HxExpression b)
HxExpression Sum(HxExpression a, long b)
HxExpression Sum(HxExpression a, double b)
HxExpression Sum(HxExpression a, HxExpression b)

Creates a sum expression. This method is a shortcut for CreateExpression(HxOperator.Sum, operands).

See:HxOperator.Sum
See:HxModel.CreateExpression
Since:5.5
HxExpression Sub(HxExpression a, HxExpression b)
HxExpression Sub(long a, HxExpression b)
HxExpression Sub(double a, HxExpression b)
HxExpression Sub(HxExpression a, long b)
HxExpression Sub(HxExpression a, double b)

Creates a substraction expression. This method is a shortcut for CreateExpression(HxOperator.Sub, a, b).

See:HxOperator.Sub
See:HxModel.CreateExpression
Since:5.5
HxExpression Prod()
HxExpression Prod(params HxExpression[] operands)
HxExpression Prod(IEnumerable<HxExpression> operands)
HxExpression Prod(HxExpression a)
HxExpression Prod(long a)
HxExpression Prod(double a)
HxExpression Prod(long a, HxExpression b)
HxExpression Prod(double a, HxExpression b)
HxExpression Prod(HxExpression a, long b)
HxExpression Prod(HxExpression a, double b)
HxExpression Prod(HxExpression a, HxExpression b)

Creates a product expression. This method is a shortcut for CreateExpression(HxOperator.Prod, operands).

See:HxOperator.Prod
See:HxModel.CreateExpression
Since:5.5
HxExpression Max()
HxExpression Max(params HxExpression[] operands)
HxExpression Max(IEnumerable<HxExpression> operands)
HxExpression Max(HxExpression a)
HxExpression Max(long a)
HxExpression Max(double a)
HxExpression Max(long a, HxExpression b)
HxExpression Max(double a, HxExpression b)
HxExpression Max(HxExpression a, long b)
HxExpression Max(HxExpression a, double b)
HxExpression Max(HxExpression a, HxExpression b)

Creates a maximum expression. This method is a shortcut for CreateExpression(HxOperator.Max, operands).

See:HxOperator.Max
See:HxModel.CreateExpression
Since:5.5
HxExpression Min()
HxExpression Min(params HxExpression[] operands)
HxExpression Min(IEnumerable<HxExpression> operands)
HxExpression Min(HxExpression a)
HxExpression Min(long a)
HxExpression Min(double a)
HxExpression Min(long a, HxExpression b)
HxExpression Min(double a, HxExpression b)
HxExpression Min(HxExpression a, long b)
HxExpression Min(HxExpression a, double b)
HxExpression Min(HxExpression a, HxExpression b)

Creates a minimum expression. This method is a shortcut for CreateExpression(HxOperator.Min, operands).

See:HxOperator.Min
See:HxModel.CreateExpression
Since:5.5
HxExpression Eq(long a, HxExpression b)
HxExpression Eq(double a, HxExpression b)
HxExpression Eq(HxExpression a, long b)
HxExpression Eq(HxExpression a, double b)
HxExpression Eq(HxExpression a, HxExpression b)

Creates an equality expression. This method is a shortcut for CreateExpression(HxOperator.Eq, a, b).

See:HxOperator.Eq
See:HxModel.CreateExpression
Since:5.5
HxExpression Neq(HxExpression a, HxExpression b)
HxExpression Neq(long a, HxExpression b)
HxExpression Neq(double a, HxExpression b)
HxExpression Neq(HxExpression a, long b)
HxExpression Neq(HxExpression a, double b)

Creates a disequality expression. This method is a shortcut for CreateExpression(HxOperator.Neq, a, b).

See:HxOperator.Neq
See:HxModel.CreateExpression
Since:5.5
HxExpression Geq(HxExpression a, HxExpression b)
HxExpression Geq(long a, HxExpression b)
HxExpression Geq(double a, HxExpression b)
HxExpression Geq(HxExpression a, long b)
HxExpression Geq(HxExpression a, double b)

Creates an inequality expression greater than or equal to. This method is a shortcut for CreateExpression(HxOperator.Geq, a, b).

See:HxOperator.Geq
See:HxModel.CreateExpression
Since:5.5
HxExpression Leq(HxExpression a, HxExpression b)
HxExpression Leq(long a, HxExpression b)
HxExpression Leq(double a, HxExpression b)
HxExpression Leq(HxExpression a, long b)
HxExpression Leq(HxExpression a, double b)

Creates an inequality expression less than or equal to. This method is a shortcut for CreateExpression(HxOperator.Leq, a, b).

See:HxOperator.Leq
See:HxModel.CreateExpression
Since:5.5
HxExpression Gt(HxExpression a, HxExpression b)
HxExpression Gt(long a, HxExpression b)
HxExpression Gt(double a, HxExpression b)
HxExpression Gt(HxExpression a, long b)
HxExpression Gt(HxExpression a, double b)

Creates an inequality expression greater than. This method is a shortcut for CreateExpression(HxOperator.Gt, a, b).

See:HxOperator.Gt
See:HxModel.CreateExpression
Since:5.5
HxExpression Lt(HxExpression a, HxExpression b)
HxExpression Lt(long a, HxExpression b)
HxExpression Lt(double a, HxExpression b)
HxExpression Lt(HxExpression a, long b)
HxExpression Lt(HxExpression a, double b)

Creates an inequality expression less than. This method is a shortcut for CreateExpression(HxOperator.Lt, a, b).

See:HxOperator.Lt
See:HxModel.CreateExpression
Since:5.5
HxExpression If(HxExpression a, HxExpression b, HxExpression c)
HxExpression If(HxExpression a, HxExpression b, long c)
HxExpression If(HxExpression a, long b, HxExpression c)
HxExpression If(HxExpression a, long b, long c)
HxExpression If(HxExpression a, HxExpression b, double c)
HxExpression If(HxExpression a, double b, HxExpression c)
HxExpression If(HxExpression a, double b, double c)

Creates a ternary conditional expression. This method is a shortcut for CreateExpression(HxOperator.If, condExpr, trueExpr, falseExpr).

See:HxOperator.If
See:HxModel.CreateExpression
Since:5.5
HxExpression Not(HxExpression a)

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

See:HxOperator.Not
See:HxModel.CreateExpression
Since:5.5
HxExpression And()
HxExpression And(HxExpression a)
HxExpression And(params HxExpression[] operands)
HxExpression And(IEnumerable<HxExpression> operands)
HxExpression And(HxExpression a, HxExpression b)

Creates an AND expression. This method is a shortcut for CreateExpression(HxOperator.And, operands).

See:HxOperator.And
See:HxModel.CreateExpression
Since:5.5
HxExpression Or()
HxExpression Or(HxExpression a)
HxExpression Or(params HxExpression[] operands)
HxExpression Or(IEnumerable<HxExpression> operands)
HxExpression Or(HxExpression a, HxExpression b)

Creates a OR expression. This method is a shortcut for CreateExpression(HxOperator.Or, operands).

See:HxOperator.Or
See:HxModel.CreateExpression
Since:5.5
HxExpression Xor()
HxExpression Xor(HxExpression a)
HxExpression Xor(params HxExpression[] operands)
HxExpression Xor(IEnumerable<HxExpression> operands)
HxExpression Xor(HxExpression a, HxExpression b)

Creates a XOR expression. This method is a shortcut for CreateExpression(HxOperator.Xor, operands).

See:HxOperator.Xor
See:HxModel.CreateExpression
Since:5.5
HxExpression Abs(HxExpression a)

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

See:HxOperator.Abs
See:HxModel.CreateExpression
Since:5.5
HxExpression Dist(HxExpression a, HxExpression b)
HxExpression Dist(long a, HxExpression b)
HxExpression Dist(double a, HxExpression b)
HxExpression Dist(HxExpression a, long b)
HxExpression Dist(HxExpression a, double b)

Creates a distance expression. This method is a shortcut for CreateExpression(HxOperator.Dist, a, b).

See:HxOperator.Dist
See:HxModel.CreateExpression
Since:5.5
HxExpression Div(HxExpression a, HxExpression b)
HxExpression Div(long a, HxExpression b)
HxExpression Div(double a, HxExpression b)
HxExpression Div(HxExpression a, long b)
HxExpression Div(HxExpression a, double b)

Creates a division expression. This method is a shortcut for CreateExpression(HxOperator.Div, a, b).

See:HxOperator.Div
See:HxModel.CreateExpression
Since:5.5
HxExpression Mod(HxExpression a, HxExpression b)
HxExpression Mod(long a, HxExpression b)
HxExpression Mod(HxExpression a, long b)

Creates a modulo expression. This method is a shortcut for CreateExpression(HxOperator.Mod, a, b).

See:HxOperator.Mod
See:HxModel.CreateExpression
Since:5.5
HxExpression Array()
HxExpression Array(params HxExpression[] operands)
HxExpression Array(params long[] operands)
HxExpression Array(params double[] operands)
HxExpression Array(IEnumerable<HxExpression> operands)
HxExpression Array(IEnumerable<double> operands)
HxExpression Array(IEnumerable<long> operands)

Creates an array expression. This method is a shortcut for CreateExpression(HxOperator.Array, operands).

Any object inheriting from IEnumerable is accepted. Thus, lists, tuples, sets and their comprehensions counterpart are accepted. It is also possible to use this method with a variadic number of arguments. Each operand can be an HxExpression, a boolean, an integer or a double.

When defining a variadic array (with a range or a list decision as the first operand and a lambda function as the second operand), we allow a recursive definition of the elements in this array by using a second argument in the function, containing the evaluation of the function on the previous element of the range. In this case, a third operand can be added, representing the value of the element before the first element in the array.

See:HxOperator.Array
See:HxModel.CreateExpression
Since:5.5
HxExpression StepArray(HxExpression expr0, HxExpression expr1)

Creates a step array. This method is a shortcut for CreateExpression(HxOperator.StepArray, operands).

See:HxOperator.StepArray
See:HxModel.CreateExpression
Since:13.0
HxExpression ConstArray(long[] values)
HxExpression ConstArray(double[] values)

Creates a int constant array. This method is a shortcut for CreateConstArray(values).

See:HxOperator.ConstArray
See:HxModel.CreateConstArray
Since:13.5
HxExpression At(HxExpression array, params HxExpression[] indices)
HxExpression At(HxExpression array, params long[] indices)
HxExpression At(HxExpression array, IEnumerable<HxExpression> indices)
HxExpression At(HxExpression array, IEnumerable<long> indices)

Creates a “at” expression for N-dimensional array. This method is a shortcut for CreateExpression(HxOperator.At, arrayExpr, operands).

See:HxOperator.At
See:HxModel.CreateExpression
Since:5.5
HxExpression Scalar(HxExpression a, HxExpression b)

Creates an expression for the scalar product between two arrays. This method is a shortcut for CreateExpression(HxOperator.Scalar, a, b).

See:HxOperator.Scalar
See:HxModel.CreateExpression
Since:5.5
HxExpression Ceil(HxExpression a)

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

See:HxOperator.Ceil
See:HxModel.CreateExpression
Since:5.5
HxExpression Floor(HxExpression a)

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

See:HxOperator.Floor
See:HxModel.CreateExpression
Since:5.5
HxExpression Round(HxExpression a)

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

See:HxOperator.Round
See:HxModel.CreateExpression
Since:5.5
HxExpression Sqrt(HxExpression a)

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

See:HxOperator.Sqrt
See:HxModel.CreateExpression
Since:5.5
HxExpression Log(HxExpression a)

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

See:HxOperator.Log
See:HxModel.CreateExpression
Since:5.5
HxExpression Exp(HxExpression a)

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

See:HxOperator.Exp
See:HxModel.CreateExpression
Since:5.5
HxExpression Pow(HxExpression a, HxExpression b)
HxExpression Pow(long a, HxExpression b)
HxExpression Pow(double a, HxExpression b)
HxExpression Pow(HxExpression a, long b)
HxExpression Pow(HxExpression a, double b)

Creates a power expression. This method is a shortcut for CreateExpression(HxOperator.Pow, a, b).

See:HxOperator.Pow
See:HxModel.CreateExpression
Since:5.5
HxExpression Cos(HxExpression a)

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

See:HxOperator.Cos
See:HxModel.CreateExpression
Since:5.5
HxExpression Sin(HxExpression a)

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

See:HxOperator.Sin
See:HxModel.CreateExpression
Since:5.5
HxExpression Tan(HxExpression a)

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

See:HxOperator.Tan
See:HxModel.CreateExpression
Since:5.5
HxExpression Piecewise(HxExpression abscissae, HxExpression ordinates, HxExpression x)

Creates a piecewise linear expression. This method is a shortcut for CreateExpression(HxOperator.Piecewise, expr, b, c).

See:HxOperator.Piecewise
See:HxModel.CreateExpression
Since:5.5
HxExpression Start(HxExpression a)

Creates a start expression. This method is a shortcut for CreateExpression(HxOperator.Start, a).

See:HxOperator.Start
See:HxModel.CreateExpression
Since:12.0
HxExpression End(HxExpression a)

Creates an end expression. This method is a shortcut for CreateExpression(HxOperator.End, a).

See:HxOperator.End
See:HxModel.CreateExpression
Since:12.0
HxExpression Length(HxExpression a)

Creates a length expression. This method is a shortcut for CreateExpression(HxOperator.Length, a).

See:HxOperator.Length
See:HxModel.CreateExpression
Since:12.0
HxExpression Presence(HxExpression a)

Creates a presence expression. This method is a shortcut for CreateExpression(HxOperator.Presence, a).

See:HxOperator.Presence
See:HxModel.CreateExpression
Since:14.0
HxExpression Count(HxExpression a)

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

See:HxOperator.Count
See:HxModel.CreateExpression
Since:5.5
HxExpression IndexOf(HxExpression a, HxExpression val)
HxExpression IndexOf(HxExpression a, long val)

Creates an indexOf expression. This method is a shortcut for CreateExpression(HxOperator.IndexOf, a, b).

See:HxOperator.IndexOf
See:HxModel.CreateExpression
Since:5.5
HxExpression Distinct(HxExpression array)
HxExpression Distinct(HxExpression it, HxExpression func)

Creates a distinct expression. This method is a shortcut for CreateExpression(HxOperator.Distinct, operands).

See:HxOperator.Distinct
See:HxModel.CreateExpression
Since:12.5
HxExpression Intersection(IEnumerable<HxExpression> operands)

Creates an intersection expression of intervals. There must be at least one operand. This method is a shortcut for CreateExpression(HxOperator.Intersection, operands).

See:HxOperator.Intersection
See:HxModel.CreateExpression
Since:13.5
HxExpression Intersection(HxExpression expr0, HxExpression expr1)

Creates an intersection expression. This method is a shortcut for CreateExpression(HxOperator.Intersection, expr0, expr1).

See:HxOperator.Intersection
See:HxModel.CreateExpression
Since:12.5
HxExpression Union(IEnumerable<HxExpression> operands)

Creates an union expression. This method is a shortcut for CreateExpression(HxOperator.Union, operands).

See:HxOperator.Union
See:HxModel.CreateExpression
Since:13.5
HxExpression Hull(params HxExpression[] operands)
HxExpression Hull(HxExpression array)
HxExpression Hull(HxExpression it, HxExpression func)
HxExpression Hull(IEnumerable<HxExpression> operands)
HxExpression Hull()

Creates a hull expression. This method is a shortcut for CreateExpression(HxOperator.hull, operands).

See:HxOperator.Hull
See:HxModel.CreateExpression
Since:13.0
HxExpression Contains(HxExpression expr, HxExpression expr)
HxExpression Contains(HxExpression expr, long val)

Creates a contains expression. This method is a shortcut for CreateExpression(HxOperator.Contains, a, b).

See:HxOperator.Contains
See:HxModel.CreateExpression
Since:7.5
HxExpression Partition()
HxExpression Partition(params HxExpression[] operands)
HxExpression Partition(IEnumerable<HxExpression> operands)

Creates a partition expression. This method is a shortcut for CreateExpression(HxOperator.Partition, operands).

See:HxOperator.Partition
See:HxModel.CreateExpression
Since:5.5
HxExpression Disjoint()
HxExpression Disjoint(params HxExpression[] operands)
HxExpression Disjoint(IEnumerable<HxExpression> operands)

Creates a disjoint expression. This method is a shortcut for CreateExpression(HxOperator.Disjoint, operands).

See:HxOperator.Disjoint
See:HxModel.CreateExpression
Since:5.5
HxExpression Cover()
HxExpression Cover(params HxExpression[] operands)
HxExpression Cover(IEnumerable<HxExpression> operands)

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

See:HxOperator.Cover
See:HxModel.CreateExpression
Since:10.5
HxExpression Find()
HxExpression Find(HxExpression array, long val)
HxExpression Find(HxExpression array, HxExpression val)

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

See:HxOperator.Find
See:HxModel.CreateExpression
Since:10.5
HxExpression Sort(HxExpression expr)

Creates a sort expression. This method is a shortcut for CreateExpression(HxOperator.Sort, expr).

The first operand must be an HxExpression representing either a collection or a one-dimensional array containing integers or doubles.

See:HxOperator.Sort
See:HxModel.CreateExpression
Since:11.0
HxExpression Sort(HxExpression expr, HxExpression lambda)

Creates a sort expression. This method is a shortcut for CreateExpression(HxOperator.Sort, expr, lambda).

The first operand must be an HxExpression representing either a collection or a one-dimensional array containing integers or doubles. The second argument is optional and, if specified, must be an HxExpression with lambda function value.

See:HxOperator.Sort
See:HxModel.CreateExpression
Since:12.5
HxExpression IntExternalFunction(HxIntExternalFunction function)

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

See:HxOperator.ExternalFunction
See:HxModel.CreateIntExternalFunction
Since:9.5
HxExpression DoubleExternalFunction(HxDoubleExternalFunction function)

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

See:HxOperator.ExternalFunction
See:HxModel.CreateDoubleExternalFunction
Since:9.5
HxExpression IntArrayExternalFunction(HxIntArrayExternalFunction function)

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

See:HxOperator.ExternalFunction
See:HxModel.CreateIntArrayExternalFunction
Since:11.0
HxExpression DoubleArrayExternalFunction(HxDoubleArrayExternalFunction function)

Creates a double array external function. This method is a shortcut for CreateDoubleArrayExternalFunction.

See:HxOperator.ExternalFunction
See:HxModel.CreateDoubleArrayExternalFunction
Since:11.0
HxExpression LambdaFunction(HxLambdaFunction0 functor)
HxExpression LambdaFunction(HxLambdaFunction1 functor)
HxExpression LambdaFunction(HxLambdaFunction2 functor)
HxExpression LambdaFunction(HxLambdaFunction3 functor)
HxExpression LambdaFunction(int nbArgs, HxLambdaFunction functor)

Creates a lambda function expression. This method is a shortcut for CreateLambdaFunction(functor).

See:HxOperator.LambdaFunction
See:HxModel.CreateLambdaFunction
Since:9.5
HxExpression Call()
HxExpression Call(HxExpression func)
HxExpression Call(HxExpression func, params HxExpression[] arguments)
HxExpression Call(HxExpression func, IEnumerable<HxExpression> arguments)
HxExpression Call(params HxExpression[] operands)
HxExpression Call(IEnumerable<HxExpression> operands)

Creates a call expression. The first operand must be an HxExpression of type LambdaFunction or ExternalFunction. The other operands may be HxExpressions, booleans, integers, and doubles. They are passed to the function as arguments. This method is a shortcut for CreateExpression(HxOperator.Call, operands).

See:HxOperator.Call
See:HxModel.CreateExpression
Since:6.0
HxExpression Range(HxExpression a, HxExpression b)
HxExpression Range(HxExpression a, long b)
HxExpression Range(long a, HxExpression b)
HxExpression 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(HxOperator.Range, a, b).

See:HxOperator.Range
See:HxModel.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