Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
Helper class to express a product as a linear constraint. More...
#include <implied_bounds.h>
Public Member Functions | |
ProductDecomposer (Model *model) | |
std::vector< LiteralValueValue > | TryToDecompose (const AffineExpression &left, const AffineExpression &right) |
bool | TryToLinearize (const AffineExpression &left, const AffineExpression &right, LinearConstraintBuilder *builder) |
Helper class to express a product as a linear constraint.
Definition at line 210 of file implied_bounds.h.
|
inlineexplicit |
Definition at line 212 of file implied_bounds.h.
std::vector< LiteralValueValue > operations_research::sat::ProductDecomposer::TryToDecompose | ( | const AffineExpression & | left, |
const AffineExpression & | right ) |
Tries to decompose a product left * right in a list of constant alternative left_value * right_value controlled by literals in an exactly one relationship. We construct this by using literals from the full encoding or element encodings of the variables of the two affine expressions. If it fails, it returns an empty vector.
Fill in the encodings for the left variable.
Fill in the encodings for the right variable.
Select the compatible encoding with the minimum index.
By construction, encodings follow the order of literals in the exactly_one constraint.
Build decomposition of the product.
Definition at line 347 of file implied_bounds.cc.
bool operations_research::sat::ProductDecomposer::TryToLinearize | ( | const AffineExpression & | left, |
const AffineExpression & | right, | ||
LinearConstraintBuilder * | builder ) |
Looks at value encodings and detects if the product of two variables can be linearized.
On true, the builder will be cleared to contain the linearization. On false, it might be in an undefined state.
In the returned encoding, note that all the literals will be unique and in exactly one relation, and that the values can be duplicated. This is what we call an "element" encoding. The expressions will also be canonical.
Linearization is possible if both left and right have the same Boolean variable.
Definition at line 430 of file implied_bounds.cc.