Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <cp_model.h>
Public Member Functions | |
DoubleLinearExpr () | |
DoubleLinearExpr (BoolVar var) | |
DoubleLinearExpr (IntVar var) | |
Constructs a linear expression from an integer variable. | |
DoubleLinearExpr (double constant) | |
Constructs a constant linear expression. | |
DoubleLinearExpr & | operator+= (double value) |
Adds a constant value to the linear expression. | |
DoubleLinearExpr & | operator+= (IntVar var) |
Adds a single integer variable to the linear expression. | |
DoubleLinearExpr & | operator+= (BoolVar var) |
DoubleLinearExpr & | operator+= (const DoubleLinearExpr &expr) |
Adds another linear expression to the linear expression. | |
DoubleLinearExpr & | AddTerm (IntVar var, double coeff) |
Adds a term (var * coeff) to the linear expression. | |
DoubleLinearExpr & | AddTerm (BoolVar var, double coeff) |
DoubleLinearExpr & | AddExpression (const LinearExpr &exprs, double coeff=1.0) |
Adds a linear expression to the double linear expression. | |
DoubleLinearExpr & | operator-= (double value) |
Adds a constant value to the linear expression. | |
DoubleLinearExpr & | operator-= (IntVar var) |
Adds a single integer variable to the linear expression. | |
DoubleLinearExpr & | operator-= (const DoubleLinearExpr &expr) |
Adds another linear expression to the linear expression. | |
DoubleLinearExpr & | operator*= (double coeff) |
Multiply the linear expression by a constant. | |
const std::vector< int > & | variables () const |
Returns the vector of variable indices. | |
const std::vector< double > & | coefficients () const |
Returns the vector of coefficients. | |
bool | IsConstant () const |
Returns true if the expression has no variable. | |
double | constant () const |
Returns the constant term. | |
std::string | DebugString (const CpModelProto *proto=nullptr) const |
Debug string. See the documentation for LinearExpr::DebugString(). | |
Static Public Member Functions | |
static DoubleLinearExpr | Sum (absl::Span< const IntVar > vars) |
Constructs the sum of a list of variables. | |
static DoubleLinearExpr | Sum (absl::Span< const BoolVar > vars) |
Constructs the sum of a list of Boolean variables. | |
static DoubleLinearExpr | WeightedSum (absl::Span< const IntVar > vars, absl::Span< const double > coeffs) |
Constructs the scalar product of variables and coefficients. | |
static DoubleLinearExpr | WeightedSum (absl::Span< const BoolVar > vars, absl::Span< const double > coeffs) |
Constructs the scalar product of Boolean variables and coefficients. | |
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 350 of file cp_model.h.
|
default |
|
explicit |
Constructs a linear expression from a Boolean variable. It deals with logical negation correctly.
Definition at line 325 of file cp_model.cc.
|
explicit |
Constructs a linear expression from an integer variable.
Definition at line 327 of file cp_model.cc.
|
explicit |
Constructs a constant linear expression.
Definition at line 329 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::AddExpression | ( | const LinearExpr & | exprs, |
double | coeff = 1.0 ) |
Adds a linear expression to the double linear expression.
Definition at line 410 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::AddTerm | ( | BoolVar | var, |
double | coeff ) |
Definition at line 397 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::AddTerm | ( | IntVar | var, |
double | coeff ) |
Adds a term (var * coeff) to the linear expression.
Definition at line 391 of file cp_model.cc.
|
inline |
Returns the vector of coefficients.
Definition at line 411 of file cp_model.h.
|
inline |
Returns the constant term.
Definition at line 417 of file cp_model.h.
std::string operations_research::sat::DoubleLinearExpr::DebugString | ( | const CpModelProto * | proto = nullptr | ) | const |
Debug string. See the documentation for LinearExpr::DebugString().
Definition at line 450 of file cp_model.cc.
|
inline |
Returns true if the expression has no variable.
Definition at line 414 of file cp_model.h.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator*= | ( | double | coeff | ) |
Multiply the linear expression by a constant.
Definition at line 442 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator+= | ( | BoolVar | var | ) |
Definition at line 377 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator+= | ( | const DoubleLinearExpr & | expr | ) |
Adds another linear expression to the linear expression.
Definition at line 382 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator+= | ( | double | value | ) |
Adds a constant value to the linear expression.
Definition at line 367 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator+= | ( | IntVar | var | ) |
Adds a single integer variable to the linear expression.
Definition at line 372 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator-= | ( | const DoubleLinearExpr & | expr | ) |
Adds another linear expression to the linear expression.
Definition at line 432 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator-= | ( | double | value | ) |
Adds a constant value to the linear expression.
Definition at line 422 of file cp_model.cc.
DoubleLinearExpr & operations_research::sat::DoubleLinearExpr::operator-= | ( | IntVar | var | ) |
Adds a single integer variable to the linear expression.
Definition at line 427 of file cp_model.cc.
|
static |
Constructs the sum of a list of Boolean variables.
Definition at line 339 of file cp_model.cc.
|
static |
Constructs the sum of a list of variables.
Definition at line 331 of file cp_model.cc.
|
inline |
Returns the vector of variable indices.
Definition at line 408 of file cp_model.h.
|
static |
Constructs the scalar product of Boolean variables and coefficients.
Definition at line 357 of file cp_model.cc.
|
static |
Constructs the scalar product of variables and coefficients.
Definition at line 347 of file cp_model.cc.