Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <affine_relation.h>
Classes | |
struct | Relation |
Public Member Functions | |
AffineRelation () | |
int | NumRelations () const |
Returns the number of relations added to the class and not ignored. | |
bool | TryAdd (int x, int y, int64_t coeff, int64_t offset) |
bool | TryAdd (int x, int y, int64_t coeff, int64_t offset, bool allow_rep_x, bool allow_rep_y) |
Relation | Get (int x) const |
void | IgnoreFromClassSize (int x) |
int | ClassSize (int x) const |
Returns the size of the class of x. | |
Union-Find algorithm to maintain "representative" for relations of the form: x = coeff * y + offset, where "coeff" and "offset" are integers. The variable x and y are represented by non-negative integer indices. The idea is to express variables in affine relation using as little different variables as possible (the representatives).
IMPORTANT: If there are relations with std::abs(coeff) != 1, then some relations might be ignored. See TryAdd() for more details.
Definition at line 37 of file affine_relation.h.
|
inline |
Definition at line 39 of file affine_relation.h.
|
inline |
Returns the size of the class of x.
Definition at line 111 of file affine_relation.h.
|
inline |
Definition at line 215 of file affine_relation.h.
|
inline |
Advanced usage. This is a bit hacky and will just decrease the class size of a variable without any extra checks. Use with care. In particular when this is called, then x should never be used anymore in any of the non const calls of this class.
Definition at line 97 of file affine_relation.h.
|
inline |
Returns the number of relations added to the class and not ignored.
Definition at line 42 of file affine_relation.h.
|
inline |
Adds the relation x = coeff * y + offset to the class. Returns true if it wasn't ignored.
This relation will only be taken into account if the representative of x and the one of y are different and if the relation can be transformed into a similar relation with integer coefficient between the two representatives.
That is, given that:
Checked preconditions: x >=0, y >= 0, coeff != 0 and x != y.
IMPORTANT: we do not check for integer overflow, but that could be added if it is needed.
Definition at line 168 of file affine_relation.h.
|
inline |
Same as TryAdd() with the option to disallow the use of a given representative.
Definition at line 173 of file affine_relation.h.