Class Expression
An expression essentially is a tree which stores operators on subtrees which can either be Expressions or Terms themselves
Inheritance
Inherited Members
Namespace: OPTANO.Modeling.Optimization
Assembly: Optimization.dll
Syntax
[DataContract]
[Serializable]
public abstract class Expression
Fields
_bigMUserValue
Declaration
protected double? _bigMUserValue
Field Value
Type | Description |
---|---|
System.Nullable<System.Double> |
Properties
BigM
Uses the
Hint for user-provided value:
BigM is used during the automatic transformation of OperatorExpressions into 'linear expressions' that can be handled by common MIP/LP solvers.
Large number, only used if the bounds of the variables of the expressions are non-finite
It should be chosen large enough, so that the solution space is not cut. But choosing this value too large, it can cause numerical errors.
Declaration
public double BigM { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown, if MRE evaluates to System.Double.IsInfinity(System.Double) and user did not provide a finite BigM estimation. |
Constant
Gets the constant of this expression.
Declaration
public virtual double Constant { get; }
Property Value
Type | Description |
---|---|
System.Double | The constant. |
ContainsAtMostOneVariable
Declaration
public abstract bool ContainsAtMostOneVariable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ContainsNoVariables
Declaration
public abstract bool ContainsNoVariables { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
EmptyExpression
Gets an empty Expression.
Declaration
public static Expression EmptyExpression { get; }
Property Value
Type | Description |
---|---|
Expression |
IsLinear
Gets or sets a value indicating whether this instance is linear.
Declaration
public abstract bool IsLinear { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
NonZeroTerms
Gets all terms with non-0 factors. Does not check if results are unique.
Declaration
protected IEnumerable<Term> NonZeroTerms { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Term> |
Terms
Gets a list of the terms in this expression. It does not contain any operators and does not tell you anything aobut how they are combined with operators.
Declaration
public abstract IEnumerable<Term> Terms { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Term> | The terms. |
Variables
Gets the variables in this expression.
Declaration
public abstract IEnumerable<Variable> Variables { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Variable> | The variables. |
Methods
Absolute(Expression, Nullable<Double>)
Creates an OperatorExpression that represents the absolute
of the given expression
.
Declaration
public static Abs Absolute(Expression expression, double? bigM = default(double? ))
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | Expressions of which the absolute should be determined. Mustn't be null. |
System.Nullable<System.Double> | bigM | Large number, only used if the bounds of the variables of the expressions are non-finite. It should be chosen large enough, so that the solution space is not cut. But choosing this value too large, it can cause numerical errors. |
Returns
Type | Description |
---|---|
Abs | An Abs that represents |
Ceiling(Expression, Nullable<Double>)
Creates an OperatorExpression that represents the ceiling
of the given expression
.
Declaration
public static Ceil Ceiling(Expression expression, double? bigM = default(double? ))
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | Expressions of which the ceiling should be determined. Mustn't be null. |
System.Nullable<System.Double> | bigM | Large number, only used if the bounds of the variables of the expressions are non-finite. It should be chosen large enough, so that the solution space is not cut. But choosing this value too large, it can cause numerical errors. |
Returns
Type | Description |
---|---|
Ceil | A Ceil expression that will be evaluated to the smallest integer greater or equal to the given |
Evaluate(IDictionary<String, Double>)
Evaluates the expression using the specified variable values.
Declaration
public double Evaluate(IDictionary<string, double> variableValues)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.Double> | variableValues | The variable values. |
Returns
Type | Description |
---|---|
System.Double | The |
Floor(Expression, Nullable<Double>)
Creates an OperatorExpression that represents the floor
of the given expression
.
Declaration
public static Floor Floor(Expression expression, double? bigM = default(double? ))
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | Expressions of which the floor should be determined. Mustn't be null. |
System.Nullable<System.Double> | bigM | Large number, only used if the bounds of the variables of the expressions are non-finite. It should be chosen large enough, so that the solution space is not cut. But choosing this value too large, it can cause numerical errors. |
Returns
Type | Description |
---|---|
Floor | A Floor(Expression, Nullable<Double>) expression that will be evaluated to the largest integer less or equal to the given |
Maximum(IEnumerable<Expression>, Nullable<Double>)
Creates an OperatorExpression that represents the Max over the given expressions
.
Declaration
public static Max Maximum(IEnumerable<Expression> expressions, double? bigM = default(double? ))
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Expression> | expressions | Expressions of which the maximum should be determined. Mustn't be null or empty. |
System.Nullable<System.Double> | bigM | Large number, only used if the bounds of the variables of the expressions are non-finite. It should be chosen large enough, so that the solution space is not cut. But choosing this value too large, it can cause numerical errors. |
Returns
Type | Description |
---|---|
Max | A Max OperatorExpression over the given |
Minimum(IEnumerable<Expression>, Nullable<Double>)
Creates an Expression that represents the Min over the given expressions
.
Declaration
public static Min Minimum(IEnumerable<Expression> expressions, double? bigM = default(double? ))
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Expression> | expressions | Expressions of which the minimum should be determined. Mustn't be null or empty. |
System.Nullable<System.Double> | bigM | Large number, only used if the bounds of the variables of the expressions are non-finite. It should be chosen large enough, so that the solution space is not cut. But choosing this value too large, it can cause numerical errors. |
Returns
Type | Description |
---|---|
Min | A Min OperatorExpression over the given |
Normalize()
Flattens the expression. Only works for linear expressions and the result is a sum of terms + a constant.
Declaration
public Expression Normalize()
Returns
Type | Description |
---|---|
Expression | The Expression. |
Sum(IEnumerable<Expression>)
Sums the specified expressions.
Declaration
public static Expression Sum(IEnumerable<Expression> expressions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Expression> | expressions | The expressions. |
Returns
Type | Description |
---|---|
Expression | The Expression. |
Sum(IEnumerable<Term>)
Sums the specified terms.
Declaration
public static Expression Sum(IEnumerable<Term> expressions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Term> | expressions | The terms. |
Returns
Type | Description |
---|---|
Expression | The Expression. |
Sum(IEnumerable<Variable>)
Sums the specified variables.
Declaration
public static Expression Sum(IEnumerable<Variable> variables)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Variable> | variables | The variables. |
Returns
Type | Description |
---|---|
Expression | The Expression. |
Sum(IEnumerable<Double>)
Sums up the specified values.
Declaration
public static Expression Sum(IEnumerable<double> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Double> | values | The expressions. |
Returns
Type | Description |
---|---|
Expression | The Expression. |
Sum(Int32, Int32, Func<Int32, Expression>)
Sums the specified range of expressions.
Declaration
public static Expression Sum(int start, int count, Func<int, Expression> selector)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | The start. |
System.Int32 | count | The count. |
System.Func<System.Int32, Expression> | selector | The selector. |
Returns
Type | Description |
---|---|
Expression | The Expression. |
Sum(Int32, Int32, Func<Int32, Term>)
Sums the specified range of terms.
Declaration
public static Expression Sum(int start, int count, Func<int, Term> selector)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | The start. |
System.Int32 | count | The count. |
System.Func<System.Int32, Term> | selector | The selector. |
Returns
Type | Description |
---|---|
Expression | The Expression. |
Operators
Addition(Expression, Expression)
Implements the operator +.
Declaration
public static Expression operator +(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Addition(Expression, Variable)
Implements the operator +.
Declaration
public static Expression operator +(Expression expression1, Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The expression. |
Variable | variable | The variable. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Addition(Expression, Double)
Adds a constant to an expression
Declaration
public static Expression operator +(Expression expression, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | |
System.Double | constant |
Returns
Type | Description |
---|---|
Expression |
Addition(Variable, Expression)
Implements the operator +.
Declaration
public static Expression operator +(Variable variable, Expression expression1)
Parameters
Type | Name | Description |
---|---|---|
Variable | variable | The variable. |
Expression | expression1 | The expression. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Addition(Double, Expression)
Adds a constant to an expression
Declaration
public static Expression operator +(double constant, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Double | constant | |
Expression | expression |
Returns
Type | Description |
---|---|
Expression |
Division(Expression, Double)
Implements the operator /.
Declaration
public static Expression operator /(Expression expression, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Equality(Expression, Expression)
Implements the operator ==.
Declaration
public static Constraint operator ==(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Equality(Expression, Variable)
Implements the operator '=='.
Declaration
public static Constraint operator ==(Expression expression, Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Variable | variable | The variable. |
Returns
Type | Description |
---|---|
Constraint | A Constraint where |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Arguments mustn't be |
Equality(Expression, Double)
Implements the operator ==.
Declaration
public static Constraint operator ==(Expression expression, double value)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
System.Double | value | The constant. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Equality(Variable, Expression)
Creates a new equality constraint
Declaration
public static Constraint operator ==(Variable variable, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Variable | variable | The variable. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The a new constraint as the result of the operator. |
Equality(Double, Expression)
Implements the operator ==.
Declaration
public static Constraint operator ==(double value, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The constant. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
GreaterThanOrEqual(Expression, Expression)
Implements the operator >=.
Declaration
public static Constraint operator >=(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
GreaterThanOrEqual(Expression, Variable)
Implements the operator >=.
Declaration
public static Constraint operator >=(Expression expression, Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Variable | variable | The variable. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
GreaterThanOrEqual(Expression, Double)
Implements the operator >=.
Declaration
public static Constraint operator >=(Expression expression, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
GreaterThanOrEqual(Variable, Expression)
Implements the operator >=.
Declaration
public static Constraint operator >=(Variable variable, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Variable | variable | The variable. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
GreaterThanOrEqual(Double, Expression)
Implements the operator >=.
Declaration
public static Constraint operator >=(double constant, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Double | constant | The constant. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Implicit(Variable to Expression)
Implicit conversion from Variable to Expression.
Declaration
public static implicit operator Expression(Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Variable | variable | The variable to convert. |
Returns
Type | Description |
---|---|
Expression | A new Term that contains the variable, casted as a general Expression. |
Inequality(Expression, Expression)
Please construct inequalities using <= and >=
Declaration
public static Constraint operator !=(Expression expression, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Expression | expression2 | The expression2. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Inequality(Expression, Variable)
Please construct inequalities using <= and >=
Declaration
public static Constraint operator !=(Expression expression, Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Variable | variable | The variable. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Inequality(Expression, Double)
Please construct inequalities using <= and >=
Declaration
public static Constraint operator !=(Expression expression, double value)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
System.Double | value | The value. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Inequality(Variable, Expression)
Please construct inequalities using <= and >=
Declaration
public static Constraint operator !=(Variable variable, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Variable | variable | The variable. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Inequality(Double, Expression)
Please construct inequalities using <= and >=
Declaration
public static Constraint operator !=(double value, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
LessThanOrEqual(Expression, Expression)
Implements the operator <=.
Declaration
public static Constraint operator <=(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
LessThanOrEqual(Expression, Variable)
Implements the operator <=.
Declaration
public static Constraint operator <=(Expression expression, Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Variable | variable | The variable. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
LessThanOrEqual(Expression, Double)
Implements the operator <=.
Declaration
public static Constraint operator <=(Expression expression, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
LessThanOrEqual(Variable, Expression)
Implements the operator <=.
Declaration
public static Constraint operator <=(Variable variable, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Variable | variable | The variable. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
LessThanOrEqual(Double, Expression)
Implements the operator <=.
Declaration
public static Constraint operator <=(double constant, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Double | constant | The constant. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Constraint | The result of the operator. |
Multiply(Expression, Expression)
Implements the operator *.
Declaration
public static Expression operator *(Expression expression, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Multiply(Expression, Variable)
Implements the operator *.
Declaration
public static Expression operator *(Expression expression, Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Variable | variable | The variable. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Multiply(Expression, Double)
Implements the operator *.
Declaration
public static Expression operator *(Expression expression, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Multiply(Double, Expression)
Implements the operator *.
Declaration
public static Expression operator *(double constant, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Double | constant | The constant. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Subtraction(Expression, Expression)
Implements the operator -.
Declaration
public static Expression operator -(Expression expression1, Expression expression2)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The first expression. |
Expression | expression2 | The second expression. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Subtraction(Expression, Variable)
Implements the operator -.
Declaration
public static Expression operator -(Expression expression, Variable variable)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression. |
Variable | variable | The variable. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Subtraction(Expression, Double)
Implements the operator -.
Declaration
public static Expression operator -(Expression expression1, double constant)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression1 | The expression. |
System.Double | constant | The constant. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Subtraction(Variable, Expression)
Implements the operator -.
Declaration
public static Expression operator -(Variable variable, Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Variable | variable | The variable. |
Expression | expression | The expression. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |
Subtraction(Double, Expression)
Implements the operator -.
Declaration
public static Expression operator -(double constant, Expression expression1)
Parameters
Type | Name | Description |
---|---|---|
System.Double | constant | The constant. |
Expression | expression1 | The expression1. |
Returns
Type | Description |
---|---|
Expression | The result of the operator. |