![]() |
OR-Tools
9.6
|
A dedicated container for linear expressions with double coefficients.
This is currently only usable to define a floating point objective.
Usage:
This can be used in the objective definition.
Definition at line 345 of file cp_model.h.
Public Member Functions | |
| DoubleLinearExpr () | |
| DoubleLinearExpr (BoolVar var) | |
| Constructs a linear expression from a Boolean variable. More... | |
| DoubleLinearExpr (IntVar var) | |
| Constructs a linear expression from an integer variable. More... | |
| DoubleLinearExpr (double constant) | |
| Constructs a constant linear expression. More... | |
| DoubleLinearExpr & | operator+= (double value) |
| Adds a constant value to the linear expression. More... | |
| DoubleLinearExpr & | operator+= (IntVar var) |
| Adds a single integer variable to the linear expression. More... | |
| DoubleLinearExpr & | operator+= (BoolVar var) |
| DoubleLinearExpr & | operator+= (const DoubleLinearExpr &expr) |
| Adds another linear expression to the linear expression. More... | |
| DoubleLinearExpr & | AddTerm (IntVar var, double coeff) |
| Adds a term (var * coeff) to the linear expression. More... | |
| DoubleLinearExpr & | AddTerm (BoolVar var, double coeff) |
| DoubleLinearExpr & | AddExpression (const LinearExpr &exprs, double coeff=1.0) |
| Adds a linear expression to the double linear expression. More... | |
| DoubleLinearExpr & | operator-= (double value) |
| Adds a constant value to the linear expression. More... | |
| DoubleLinearExpr & | operator-= (IntVar var) |
| Adds a single integer variable to the linear expression. More... | |
| DoubleLinearExpr & | operator-= (const DoubleLinearExpr &expr) |
| Adds another linear expression to the linear expression. More... | |
| DoubleLinearExpr & | operator*= (double coeff) |
| Multiply the linear expression by a constant. More... | |
| const std::vector< int > & | variables () const |
| Returns the vector of variable indices. More... | |
| const std::vector< double > & | coefficients () const |
| Returns the vector of coefficients. More... | |
| const bool | IsConstant () const |
| double | constant () const |
| Returns the constant term. More... | |
| std::string | DebugString (const CpModelProto *proto=nullptr) const |
| Debug string. See the documentation for LinearExpr::DebugString(). More... | |
Static Public Member Functions | |
| static DoubleLinearExpr | Sum (absl::Span< const IntVar > vars) |
| Constructs the sum of a list of variables. More... | |
| static DoubleLinearExpr | Sum (absl::Span< const BoolVar > vars) |
| Constructs the sum of a list of Boolean variables. More... | |
| static DoubleLinearExpr | WeightedSum (absl::Span< const IntVar > vars, absl::Span< const double > coeffs) |
| Constructs the scalar product of variables and coefficients. More... | |
| static DoubleLinearExpr | WeightedSum (absl::Span< const BoolVar > vars, absl::Span< const double > coeffs) |
| Constructs the scalar product of Boolean variables and coefficients. More... | |
| DoubleLinearExpr | ( | ) |
Definition at line 322 of file cp_model.cc.
|
explicit |
Constructs a linear expression from a Boolean variable.
It deals with logical negation correctly.
Definition at line 324 of file cp_model.cc.
|
explicit |
Constructs a linear expression from an integer variable.
Definition at line 326 of file cp_model.cc.
|
explicit |
Constructs a constant linear expression.
Definition at line 328 of file cp_model.cc.
| DoubleLinearExpr & AddExpression | ( | const LinearExpr & | exprs, |
| double | coeff = 1.0 |
||
| ) |
Adds a linear expression to the double linear expression.
Definition at line 409 of file cp_model.cc.
| DoubleLinearExpr & AddTerm | ( | BoolVar | var, |
| double | coeff | ||
| ) |
Definition at line 396 of file cp_model.cc.
| DoubleLinearExpr & AddTerm | ( | IntVar | var, |
| double | coeff | ||
| ) |
Adds a term (var * coeff) to the linear expression.
Definition at line 390 of file cp_model.cc.
|
inline |
Returns the vector of coefficients.
Definition at line 406 of file cp_model.h.
|
inline |
Returns the constant term.
Definition at line 412 of file cp_model.h.
| std::string DebugString | ( | const CpModelProto * | proto = nullptr | ) | const |
Debug string. See the documentation for LinearExpr::DebugString().
Definition at line 449 of file cp_model.cc.
|
inline |
Definition at line 409 of file cp_model.h.
| DoubleLinearExpr & operator*= | ( | double | coeff | ) |
Multiply the linear expression by a constant.
Definition at line 441 of file cp_model.cc.
| DoubleLinearExpr & operator+= | ( | BoolVar | var | ) |
Definition at line 376 of file cp_model.cc.
| DoubleLinearExpr & operator+= | ( | const DoubleLinearExpr & | expr | ) |
Adds another linear expression to the linear expression.
Definition at line 381 of file cp_model.cc.
| DoubleLinearExpr & operator+= | ( | double | value | ) |
Adds a constant value to the linear expression.
Definition at line 366 of file cp_model.cc.
| DoubleLinearExpr & operator+= | ( | IntVar | var | ) |
Adds a single integer variable to the linear expression.
Definition at line 371 of file cp_model.cc.
| DoubleLinearExpr & operator-= | ( | const DoubleLinearExpr & | expr | ) |
Adds another linear expression to the linear expression.
Definition at line 431 of file cp_model.cc.
| DoubleLinearExpr & operator-= | ( | double | value | ) |
Adds a constant value to the linear expression.
Definition at line 421 of file cp_model.cc.
| DoubleLinearExpr & operator-= | ( | IntVar | var | ) |
Adds a single integer variable to the linear expression.
Definition at line 426 of file cp_model.cc.
|
static |
Constructs the sum of a list of Boolean variables.
Definition at line 338 of file cp_model.cc.
|
static |
Constructs the sum of a list of variables.
Definition at line 330 of file cp_model.cc.
|
inline |
Returns the vector of variable indices.
Definition at line 403 of file cp_model.h.
|
static |
Constructs the scalar product of Boolean variables and coefficients.
Definition at line 356 of file cp_model.cc.
|
static |
Constructs the scalar product of variables and coefficients.
Definition at line 346 of file cp_model.cc.