C++ Reference: class LinearExpr
Note: This documentation is automatically generated.
Method |
coefficients | Return type: const std::vector<int64_t>& Returns the vector of coefficients.
|
constant | Return type: int64_t Returns the constant term.
|
DebugString | Return type: std::string Arguments: const CpModelProto* proto = nullptr |
FromProto | Return type: static LinearExpr Arguments: const LinearExpressionProto& proto Constructs a linear expr from its proto representation.
|
IsConstant | Return type: const bool Returns true if the expression has no variables.
|
LinearExpr | Creates an empty linear expression with value zero.
|
LinearExpr | Arguments: BoolVar var Constructs a linear expression from a Boolean variable.
It deals with logical negation correctly.
|
LinearExpr | Arguments: IntVar var Constructs a linear expression from an integer variable.
|
LinearExpr | Arguments: int64_t constant Constructs a constant linear expression.
|
Sum | Return type: static LinearExpr Arguments: absl::Span<const IntVar> vars Constructs the sum of a list of variables.
|
Sum | Return type: static LinearExpr Arguments: absl::Span<const BoolVar> vars Constructs the sum of a list of Boolean variables.
|
Term | Return type: static LinearExpr Arguments: IntVar var, int64_t coefficient Constructs var * coefficient.
|
Term | Return type: static LinearExpr Arguments: BoolVar var, int64_t coefficient Constructs bool * coefficient.
|
variables | Return type: const std::vector<int>& Returns the vector of variable indices.
|
WeightedSum | Return type: static LinearExpr Arguments: absl::Span<const IntVar> vars,
absl::Span<const int64_t> coeffs Constructs the scalar product of variables and coefficients.
|
WeightedSum | Return type: static LinearExpr Arguments: absl::Span<const BoolVar> vars,
absl::Span<const int64_t> coeffs Constructs the scalar product of Boolean variables and coefficients.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-06 UTC.
[null,null,["Last updated 2024-08-06 UTC."],[[["`LinearExpr` represents a linear expression in the CP-SAT solver, which can be constructed from variables, constants, or combinations thereof."],["It provides methods for accessing the coefficients, variables, and constant term of the expression."],["Static methods like `Sum`, `Term`, and `WeightedSum` offer convenient ways to build complex linear expressions."],["`LinearExpr` objects can be converted to and from their protocol buffer representation using `FromProto` and `DebugString`."],["You can check if an expression is constant using `IsConstant`."]]],[]]