Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::sat::LinearConstraint Struct Reference

#include <linear_constraint.h>

Public Member Functions

 LinearConstraint ()=default
 
 LinearConstraint (IntegerValue _lb, IntegerValue _ub)
 
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
 

Detailed Description

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 43 of file linear_constraint.h.

Constructor & Destructor Documentation

◆ LinearConstraint() [1/2]

operations_research::sat::LinearConstraint::LinearConstraint ( )
default

◆ LinearConstraint() [2/2]

operations_research::sat::LinearConstraint::LinearConstraint ( IntegerValue _lb,
IntegerValue _ub )
inline

Definition at line 62 of file linear_constraint.h.

Member Function Documentation

◆ CoeffsAsSpan()

absl::Span< const IntegerValue > operations_research::sat::LinearConstraint::CoeffsAsSpan ( ) const
inline

Definition at line 119 of file linear_constraint.h.

◆ DebugString()

std::string operations_research::sat::LinearConstraint::DebugString ( ) const
inline

Definition at line 80 of file linear_constraint.h.

◆ IsEqualIgnoringBounds()

bool operations_research::sat::LinearConstraint::IsEqualIgnoringBounds ( const LinearConstraint & other) const
inline

Definition at line 95 of file linear_constraint.h.

◆ operator==()

bool operations_research::sat::LinearConstraint::operator== ( const LinearConstraint & other) const
inline

Definition at line 109 of file linear_constraint.h.

◆ resize()

void operations_research::sat::LinearConstraint::resize ( int size)
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 66 of file linear_constraint.h.

◆ VarsAsSpan()

absl::Span< const IntegerVariable > operations_research::sat::LinearConstraint::VarsAsSpan ( ) const
inline

Definition at line 115 of file linear_constraint.h.

Member Data Documentation

◆ coeffs

std::unique_ptr<IntegerValue[]> operations_research::sat::LinearConstraint::coeffs

Definition at line 59 of file linear_constraint.h.

◆ lb

IntegerValue operations_research::sat::LinearConstraint::lb

Definition at line 44 of file linear_constraint.h.

◆ num_terms

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 57 of file linear_constraint.h.

◆ ub

IntegerValue operations_research::sat::LinearConstraint::ub

Definition at line 45 of file linear_constraint.h.

◆ vars

std::unique_ptr<IntegerVariable[]> operations_research::sat::LinearConstraint::vars

Definition at line 58 of file linear_constraint.h.


The documentation for this struct was generated from the following file: