This data structure stores a linear expression of the variables (Cols) and also has a constant component.
There are several ways to access and modify the contents of this container.
e[v]=5;
e[v]+=12;
e.erase(v);
or you can also iterate through its elements.
double s=0;
s+=*i * primal(i);
const Invalid INVALID
Invalid iterators.
Definition base.cc:32
Const iterator over the expression.
Definition lp_base.h:504
(This code computes the primal value of the expression).
- Numbers (double's) and variables (Cols) directly convert to an Expr and the usual linear operations are defined, so
v+w
2*v-3.12*(v-w/2)+2
v*2.1+(3*v+(v*12+w+6)*3)/2
are valid expressions. The usual assignment operations are also defined. e=v+w;
e+=2*v-3.12*(v-w/2)+2;
e*=3.4;
e/=5;
- The constant member can be set and read by dereference operator (unary *)
- See also
- Constr
|
| | Expr () |
| | Default constructor.
|
| | Expr (const Col &c) |
| | Construct an expression from a column.
|
| | Expr (const Value &v) |
| | Construct an expression from a constant.
|
|
Value | operator[] (const Col &c) const |
| | Returns the coefficient of the column.
|
|
Value & | operator[] (const Col &c) |
| | Returns the coefficient of the column.
|
|
void | set (const Col &c, const Value &v) |
| | Sets the coefficient of the column.
|
|
Value & | operator* () |
| | Returns the constant component of the expression.
|
|
const Value & | operator* () const |
| | Returns the constant component of the expression.
|
|
void | simplify (Value epsilon=0.0) |
| | Removes the coefficients which's absolute value does not exceed epsilon. It also sets to zero the constant component, if it does not exceed epsilon in absolute value.
|
|
void | clear () |
| | Sets all coefficients and the constant component to 0.
|
|
Expr & | operator+= (const Expr &e) |
| | Compound assignment.
|
|
Expr & | operator-= (const Expr &e) |
| | Compound assignment.
|
|
Expr & | operator*= (const Value &v) |
| | Multiply with a constant.
|
|
Expr & | operator/= (const Value &c) |
| | Division with a constant.
|