![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
One linear constraint on a set of Integer variables. Important: there should be no duplicate variables.
We also assume that we never have integer overflow when evaluating such constraint at the ROOT node. This should be enforced by the checker for user given constraints, and we must enforce it ourselves for the newly created constraint. See ValidateLinearConstraintForOverflow().
Definition at line 48 of file linear_constraint.h.
#include <linear_constraint.h>
Public Member Functions | |
LinearConstraint ()=default | |
LinearConstraint (IntegerValue _lb, IntegerValue _ub) | |
double | NormalizedViolation (const util_intops::StrongVector< IntegerVariable, double > &lp_values) const |
void | resize (int size) |
std::string | DebugString () const |
bool | IsEqualIgnoringBounds (const LinearConstraint &other) const |
bool | operator== (const LinearConstraint &other) const |
absl::Span< const IntegerVariable > | VarsAsSpan () const |
absl::Span< const IntegerValue > | CoeffsAsSpan () const |
Public Attributes | |
IntegerValue | lb |
IntegerValue | ub |
int | num_terms = 0 |
std::unique_ptr< IntegerVariable[]> | vars |
std::unique_ptr< IntegerValue[]> | coeffs |
|
default |
|
inline |
Definition at line 67 of file linear_constraint.h.
|
inline |
Definition at line 130 of file linear_constraint.h.
|
inline |
Definition at line 91 of file linear_constraint.h.
|
inline |
Definition at line 106 of file linear_constraint.h.
double operations_research::sat::LinearConstraint::NormalizedViolation | ( | const util_intops::StrongVector< IntegerVariable, double > & | lp_values | ) | const |
Compute the normalized violation of the constraint. For a cut, this is the usual definition of its efficacy.
Definition at line 174 of file linear_constraint.cc.
|
inline |
Definition at line 120 of file linear_constraint.h.
|
inline |
Resize the LinearConstraint to have space for num_terms. We always re-allocate if the size is different to always be tight in memory.
Definition at line 77 of file linear_constraint.h.
|
inline |
Definition at line 126 of file linear_constraint.h.
std::unique_ptr<IntegerValue[]> operations_research::sat::LinearConstraint::coeffs |
Definition at line 64 of file linear_constraint.h.
IntegerValue operations_research::sat::LinearConstraint::lb |
Definition at line 49 of file linear_constraint.h.
int operations_research::sat::LinearConstraint::num_terms = 0 |
Rather than using two std::vector<> this class is optimized for memory consumption, given that most of our LinearConstraint are constructed once and for all.
It is however up to clients to maintain the invariants that both vars and coeffs are properly allocated and of size num_terms.
Also note that we did not add a copy constructor, to make sure that this is moved as often as possible. This allowed to optimize a few call site and so far we never copy this.
Definition at line 62 of file linear_constraint.h.
IntegerValue operations_research::sat::LinearConstraint::ub |
Definition at line 50 of file linear_constraint.h.
std::unique_ptr<IntegerVariable[]> operations_research::sat::LinearConstraint::vars |
Definition at line 63 of file linear_constraint.h.