20#include "absl/log/check.h"
31 for (
int i = 0;
i < 2; ++
i) {
45 for (
int i = 0;
i < 2; ++
i) {
60 const uint64_t gcd = std::gcd(
coeffs[0].value(),
coeffs[1].value());
64 return IntegerValue(gcd);
66 return IntegerValue(1);
84 bool allow_negation) {
101 const uint64_t gcd = std::gcd(
coeffs[0].value(),
coeffs[1].value());
116 if (expr.
coeffs[0] == 0 || expr.
coeffs[1] == 0)
return false;
118 auto [it, inserted] = best_bounds_.insert({expr, {lb, ub}});
119 if (inserted)
return true;
121 const auto [known_lb, known_ub] = it->second;
122 bool restricted =
false;
124 it->second.first = lb;
128 it->second.second = ub;
136 IntegerValue ub)
const {
142 const auto it = best_bounds_.find(expr);
143 if (it != best_bounds_.end()) {
144 const auto [known_lb, known_ub] = it->second;
156 const auto it = best_bounds_.find(expr);
157 if (it != best_bounds_.end()) {
158 const auto [known_lb, known_ub] = it->second;
IntegerValue GetUpperBound(LinearExpression2 expr) const
bool Add(LinearExpression2 expr, IntegerValue lb, IntegerValue ub)
RelationStatus GetStatus(LinearExpression2 expr, IntegerValue lb, IntegerValue ub) const
Returns the known status of expr <= bound.
IntegerValue FloorRatio(IntegerValue dividend, IntegerValue positive_divisor)
constexpr IntegerValue kMaxIntegerValue(std::numeric_limits< IntegerValue::ValueType >::max() - 1)
IntegerValue CeilRatio(IntegerValue dividend, IntegerValue positive_divisor)
std::vector< IntegerVariable > NegationOf(absl::Span< const IntegerVariable > vars)
Returns the vector of the negated variables.
constexpr IntegerValue kMinIntegerValue(-kMaxIntegerValue.value())
const IntegerVariable kNoIntegerVariable(-1)
IntegerVariable PositiveVariable(IntegerVariable i)
bool VariableIsPositive(IntegerVariable i)
IntegerValue CapProdI(IntegerValue a, IntegerValue b)
Overflows and saturated arithmetic.
bool NegateForCanonicalization()
void CanonicalizeAndUpdateBounds(IntegerValue &lb, IntegerValue &ub, bool allow_negation=false)
IntegerValue DivideByGcd()
void Negate()
Take the negation of this expression.
void SimpleCanonicalization()