Expression Class
Base class for all expressions. Expressions are the building blocks for all constraints represented by
Inequality and also for indicator constraints. Expressions are created by combining variables and constant using operators and functions. The operators available for combining constants, variables and expressions are
plus,
minus,
mul (multiply) and
div (divide) and are defined as member functions of the
Expression Class (or its subclasses). To add two variables
x and
y one would do ce.
x.Plus(y). To create the expression
2x + 3y one could write
x.Mul(2).Plus(y.Mul(3)). All operators are overloaded, so that you could also write
2*x+3*y. The functions that can be used to combine expressions can be found in the
Utils class. Examples are
sum,
sin, etc. Expressions are unmodifiable and are represented as expression trees. This means that all operators are implemented to take only constant time to produce the result. An exception to the above are linear and quadratic Expressions (class
LinExpression and
QuadExpression). Linear and quadratic expressions are very common to math programming and thus they can be built in even more efficient ways: The
LinExpression and
QuadExpression are the only mutable expressions. They can be modified using the
AddTerm() family of functions. When creating a linear expression like
2x+3y+4z then it is more efficient to do this as
LinExpression.Create().AddTerm(x,2).AddTerm(y,3).AddTerm(z,4) than to create the expression using operators
plus and
mul. For short expressions the performance difference will not be measurable but for longer expressions it will start to matter. Since operators copy their argument expressions by reference, care must be taken when applying operators to
LinExpression or
QuadExpression: when changing an instance of
LinExpression or
QuadExpression, this will implicitly change any other expression that references this expression through operators or functions.
Inheritance Hierarchy
SystemObject
Optimizer.ObjectsExpression
Optimizer.ObjectsAbstractExpression
Optimizer.ObjectsVariable
Optimizer.ObjectsExpression
Optimizer.ObjectsAbstractExpression
Optimizer.ObjectsVariable
Namespace: Optimizer.Objects
Assembly: xprsdn (in xprsdn.dll) Version: 46.01.01+e7dbcd5cc8ed0edc368dbf8cae6139abaa498963
Syntax
C#
public abstract class Expression
The Expression type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| Expression | Initializes a new instance of the Expression class |
Methods
| Name | Description | |
|---|---|---|
| Div(Double) | Create a new expression that represents the quotient of this and arg. | |
| Div(Expression) | Create a new expression that represents the quotient of this and arg. | |
| Eq(Double) | Create an "equals" constraint with this expression as left-hand side. | |
| Eq(Expression) | Create an "equals" constraint with this expression as left-hand side. | |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
|
| Evaluate | Compute the value of this expression with respect to the given solution Vector (which is not required to be feasible). | |
| Extract(Double, IPostfixExtractor) | Extract this expression into postfix notation. | |
| Extract(Double, XPRSprobRowCreator) | Extract this expression into a row. This is for internal use only, you should never have to call this function explicitly. | |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
|
| Geq(Double) | Create a "greater than or equal" constraint with this expression as left-hand side. | |
| Geq(Expression) | Create a "greater than or equal" constraint with this expression as left-hand side. | |
| GetConstantView | Get the constant value to which this expression evaluates. If this expression can be treated as a constant value then the function returns the constant value. If the expression cannot be treated as a constant then an exception is raised. In order to test whether the expression can be treated as constant, use function [!:.GetMaxDegree()] and check whether it returns 0. | |
| GetHashCode | Serves as the default hash function. (Inherited from Object) |
|
| GetLinearView | Get a linear read-only view on this expression. If this expression can be treated as a linear expression then the function returns a readonly view on the linear terms (including the constant term if there is any). If the expression cannot be treated as a linear expression then an exception is raised. In order to test this expression can be treated as linear, use function [!:.GetMaxDegree()] and check whether it returns 0 or 1. In the returned System.Collections.Generic.KeyValuePair instances the constant term is indicated with a key of NULL_VARIABLE. Note that depending on the actual expression class and its implementation, the terms may not be presented in the same order in which you added them. There may also be multiple elements with the same key (again depending on the implementation of the actual object). | |
| GetMaxDegree | Get the maximum degree of any of the terms/monomials that appear in the symbolic representation of all parenthesized sub-expressions are fully expanded. The maximum degree is
|
|
| GetQuadView | Get a quadratic read-only view on this expression. If this expression can be treated as a quadratic expression then the function returns a readonly view on the quadratic terms (including the constant term and linear terms if there are any). If the expression cannot be treated as a linear expression then an exception is raised. In order to test this expression can be treated as quadratic, use function [!:.GetMaxDegree()] and check whether it returns 0, 1, or 2. In the returned System.Collections.Generic.KeyValuePair instances the constant term is indicated with a key with two NULL_VARIABLEs. Linear terms are represented by a QPair with NULL_VARIABLE as second variable. Note that depending on the actual expression class and its implementation, the terms may not be presented in the same order in which you added them. There may also be multiple elements with the same key (again depending on the implementation of the actual object). | |
| GetRTTI | Get runtime type identification. | |
| GetType | Gets the Type of the current instance. (Inherited from Object) |
|
| In | Create a range constraint that bounds this expression from below and above. | |
| Leq(Double) | Create a "less than or equal" constraint with this expression as left-hand side. | |
| Leq(Expression) | Create a "less than or equal" constraint with this expression as left-hand side. | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
|
| Minus(Double) | Create a new expression that represents the difference of this and arg. | |
| Minus(Expression) | Create a new expression that represents the difference of this and arg. | |
| Mul(Double) | Create a new expression that represents the product of this and arg. | |
| Mul(Expression) | Create a new expression that represents the product of this and arg. | |
| Plus(Double) | Create a new expression that represents the sum of this and arg. | |
| Plus(Expression) | Create a new expression that represents the sum of this and arg. | |
| ToString | Returns a string that represents the current object. (Inherited from Object) |
|
| Uminus | Create a new expression that represents the unary minus of this one. |
Operators
Top
See Also
Reference
© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation ("FICO"). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.
