Initializing help system before first use

Expression

Base class for all expressions. More...

#include <xpress_objects.hpp>

Inheritance diagram for xpress::objects::Expression:
xpress::objects::AbstractExpression xpress::objects::Variable xpress::objects::ConstantExpression xpress::objects::FormulaExpression xpress::objects::LinExpression xpress::objects::LinTerm xpress::objects::QuadExpression xpress::objects::QuadTerm xpress::objects::SumExpression xpress::objects::BinaryExpression xpress::objects::InternalFunctionExpression xpress::objects::PWLExpression xpress::objects::UnaryExpression xpress::objects::UserFunctionExpression xpress::objects::LinTermList xpress::objects::LinTermMap xpress::objects::QuadTermList xpress::objects::QuadTermMap

Public Member Functions

virtual auto  div (double arg) const -> xpress::objects::Expression
  Create a expression that represents the quotient of this and arg.
 
virtual auto  div (Expression arg) const -> xpress::objects::Expression
  Create a expression that represents the quotient of this and arg.
 
virtual auto  eq (double rhs) const -> xpress::objects::InequalityDefinition
  Create an "equals" constraint with this expression as left-hand side.
 
virtual auto  eq (Expression const &rhs) const -> xpress::objects::InequalityDefinition
  Create an "equals" constraint with this expression as left-hand side.
 
virtual auto  evaluate (xpress::SizedArray< double const > const &solution) const -> double
  Compute the value of this expression with respect to the given solution vector (which is not required to be feasible).
 
virtual auto  geq (double rhs) const -> xpress::objects::InequalityDefinition
  Create a "greater than or equal" constraint with this expression as left-hand side.
 
virtual auto  geq (Expression const &rhs) const -> xpress::objects::InequalityDefinition
  Create a "greater than or equal" constraint with this expression as left-hand side.
 
virtual auto  getConstantView () const -> double
  Get the constant value to which this expression evaluates.
 
virtual auto  getLinearView () const -> std::shared_ptr< xpress::objects::LinearView >
  Get a linear read-only view on this expression.
 
virtual auto  getMaxDegree () const -> int
  Get the maximum degree of any of the terms/monomials that appear in the symbolic representation of all parenthesized sub-expressions are fully expanded.
 
virtual auto  getQuadView () const -> std::shared_ptr< xpress::objects::QuadView >
  Get a quadratic read-only view on this expression.
 
virtual auto  in (double lb, double ub) -> xpress::objects::InequalityDefinition
  Create a range constraint that bounds this expression from below and above.
 
virtual auto  leq (double rhs) const -> xpress::objects::InequalityDefinition
  Create a "less than or equal" constraint with this expression as left-hand side.
 
virtual auto  leq (Expression const &rhs) const -> xpress::objects::InequalityDefinition
  Create a "less than or equal" constraint with this expression as left-hand side.
 
virtual auto  minus (double arg) const -> xpress::objects::Expression
  Create a expression that represents the difference of this and arg.
 
virtual auto  minus (xpress::objects::Expression arg) const -> xpress::objects::Expression
  Create a expression that represents the difference of this and arg.
 
virtual auto  mul (double arg) const -> xpress::objects::Expression
  Create a expression that represents the product of this and arg.
 
virtual auto  mul (Expression arg) const -> xpress::objects::Expression
  Create a expression that represents the product of this and arg.
 
virtual auto  plus (double arg) const -> xpress::objects::Expression
  Create a expression that represents the sum of this and arg.
 
virtual auto  plus (xpress::objects::Expression arg) const -> xpress::objects::Expression
  Create a expression that represents the sum of this and arg.
 
virtual auto  toString () const -> std::string
  Get a string representation of this expression.
 
virtual auto  uminus () const -> xpress::objects::Expression
  Create a expression that represents the unary minus of this one.
 

Detailed Description

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)). 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.

Since
44.00

Member Function Documentation

div() [1/2]

auto xpress::objects::Expression::div ( double arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the quotient of this and arg.

Parameters
arg Divisor.
Returns
Quotient of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression, xpress::objects::LinTerm, xpress::objects::QuadTerm, and xpress::objects::Variable.

div() [2/2]

auto xpress::objects::Expression::div ( Expression arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the quotient of this and arg.

Parameters
arg Divisor.
Returns
Quotient of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression, xpress::objects::LinTerm, xpress::objects::QuadTerm, and xpress::objects::Variable.

eq() [1/2]

auto xpress::objects::Expression::eq ( double rhs ) const -> xpress::objects::InequalityDefinition
inlinevirtual

Create an "equals" constraint with this expression as left-hand side.

Parameters
rhs Right-hand side of constraint.
Returns
The constraint.
Since
44.00

Reimplemented in xpress::objects::AbstractExpression, and xpress::objects::Variable.

eq() [2/2]

auto xpress::objects::Expression::eq ( Expression const & rhs ) const -> xpress::objects::InequalityDefinition
inlinevirtual

Create an "equals" constraint with this expression as left-hand side.

Parameters
rhs Right-hand side of constraint.
Returns
The constraint.
Since
44.00

Reimplemented in xpress::objects::AbstractExpression, and xpress::objects::Variable.

evaluate()

auto xpress::objects::Expression::evaluate ( xpress::SizedArray< double const > const & solution ) const -> double
inlinevirtual

Compute the value of this expression with respect to the given solution vector (which is not required to be feasible).

Parameters
solution Solution values for which the expression is evaluated.
Returns
The value of this expression evaluated at solution.
Since
44.00

Reimplemented in xpress::objects::BinaryExpression, xpress::objects::ConstantExpression, xpress::objects::InternalFunctionExpression, xpress::objects::LinTerm, xpress::objects::LinTermList, xpress::objects::LinTermMap, xpress::objects::PWLExpression, xpress::objects::QuadTerm, xpress::objects::QuadTermList, xpress::objects::QuadTermMap, xpress::objects::SumExpression, xpress::objects::UnaryExpression, xpress::objects::UserFunctionExpression, and xpress::objects::Variable.

geq() [1/2]

auto xpress::objects::Expression::geq ( double rhs ) const -> xpress::objects::InequalityDefinition
inlinevirtual

Create a "greater than or equal" constraint with this expression as left-hand side.

Parameters
rhs Right-hand side of constraint.
Returns
The constraint.
Since
44.00

Reimplemented in xpress::objects::AbstractExpression, and xpress::objects::Variable.

geq() [2/2]

auto xpress::objects::Expression::geq ( Expression const & rhs ) const -> xpress::objects::InequalityDefinition
inlinevirtual

Create a "greater than or equal" constraint with this expression as left-hand side.

Parameters
rhs Right-hand side of constraint.
Returns
The constraint.
Since
44.00

Reimplemented in xpress::objects::AbstractExpression, and xpress::objects::Variable.

getConstantView()

auto xpress::objects::Expression::getConstantView ( ) const -> double
inlinevirtual

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.

Returns
The constant represented by this expression.
Since
44.00

getLinearView()

auto xpress::objects::Expression::getLinearView ( ) const -> std::shared_ptr<xpress::objects::LinearView>
inlinevirtual

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 std::pair instances the constant term is indicated with a key of xpress::objects::XpressProblem#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).

Returns
View on this linear expression.
Since
44.00

getMaxDegree()

auto xpress::objects::Expression::getMaxDegree ( ) const -> int
inlinevirtual

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

  • 0 for constant expressions.
  • 1 for linear expressions.
  • 2 for quadratic expressions.
  • std::numeric_limits<int>::max() for function calls or formulas.
Returns
The maximum degree in this function.
Since
44.00

getQuadView()

auto xpress::objects::Expression::getQuadView ( ) const -> std::shared_ptr<xpress::objects::QuadView>
inlinevirtual

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 std::pair instances the constant term is indicated with a key with two xpress::objects::XpressProblem#NULL_VARIABLEs. Linear terms are represented by a QPair with xpress::objects::XpressProblem#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).

Returns
View on this linear expression.
Since
44.00

in()

auto xpress::objects::Expression::in ( double lb,
double ub ) -> xpress::objects::InequalityDefinition
inlinevirtual

Create a range constraint that bounds this expression from below and above.

Parameters
lb Lower bound for this expression.
ub Upper bound for this expression.
Returns
The constraint.
Since
44.00

Reimplemented in xpress::objects::AbstractExpression, and xpress::objects::Variable.

leq() [1/2]

auto xpress::objects::Expression::leq ( double rhs ) const -> xpress::objects::InequalityDefinition
inlinevirtual

Create a "less than or equal" constraint with this expression as left-hand side.

Parameters
rhs Right-hand side of constraint.
Returns
The constraint.
Since
44.00

Reimplemented in xpress::objects::AbstractExpression, and xpress::objects::Variable.

leq() [2/2]

auto xpress::objects::Expression::leq ( Expression const & rhs ) const -> xpress::objects::InequalityDefinition
inlinevirtual

Create a "less than or equal" constraint with this expression as left-hand side.

Parameters
rhs Right-hand side of constraint.
Returns
The constraint.
Since
44.00

Reimplemented in xpress::objects::AbstractExpression, and xpress::objects::Variable.

minus() [1/2]

auto xpress::objects::Expression::minus ( double arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the difference of this and arg.

Parameters
arg Minuend.
Returns
Difference of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression.

minus() [2/2]

auto xpress::objects::Expression::minus ( xpress::objects::Expression arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the difference of this and arg.

Parameters
arg Minuend.
Returns
Difference of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression.

mul() [1/2]

auto xpress::objects::Expression::mul ( double arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the product of this and arg.

Parameters
arg Factor.
Returns
Product of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression, xpress::objects::LinTerm, xpress::objects::QuadTerm, and xpress::objects::Variable.

mul() [2/2]

auto xpress::objects::Expression::mul ( Expression arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the product of this and arg.

Parameters
arg Factor.
Returns
Product of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression, xpress::objects::LinTerm, xpress::objects::QuadTerm, and xpress::objects::Variable.

plus() [1/2]

auto xpress::objects::Expression::plus ( double arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the sum of this and arg.

Parameters
arg Addend.
Returns
Sum of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression.

plus() [2/2]

auto xpress::objects::Expression::plus ( xpress::objects::Expression arg ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the sum of this and arg.

Parameters
arg Addend.
Returns
Sum of this and arg.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression.

toString()

uminus()

auto xpress::objects::Expression::uminus ( ) const -> xpress::objects::Expression
inlinevirtual

Create a expression that represents the unary minus of this one.

Returns
Expression representing -this.
Since
44.00

Reimplemented in xpress::objects::ConstantExpression, xpress::objects::LinTerm, xpress::objects::QuadTerm, and xpress::objects::Variable.


The documentation for this class was generated from the following file:
  • xpress_objects.hpp

© 2001-2024 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.