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

#include <integer.h>

Public Member Functions

 AffineExpression ()=default
 Helper to construct an AffineExpression.
 
 AffineExpression (IntegerValue cst)
 
 AffineExpression (IntegerVariable v)
 
 AffineExpression (IntegerVariable v, IntegerValue c)
 
 AffineExpression (IntegerVariable v, IntegerValue c, IntegerValue cst)
 
IntegerLiteral GreaterOrEqual (IntegerValue bound) const
 var * coeff + constant >= bound.
 
IntegerLiteral LowerOrEqual (IntegerValue bound) const
 var * coeff + constant <= bound.
 
AffineExpression Negated () const
 
AffineExpression MultipliedBy (IntegerValue multiplier) const
 
bool operator== (AffineExpression o) const
 
IntegerValue ValueAt (IntegerValue var_value) const
 Returns the value of this affine expression given its variable value.
 
double LpValue (const util_intops::StrongVector< IntegerVariable, double > &lp_values) const
 Returns the affine expression value under a given LP solution.
 
bool IsConstant () const
 
std::string DebugString () const
 

Public Attributes

IntegerVariable var = kNoIntegerVariable
 
IntegerValue coeff = IntegerValue(0)
 
IntegerValue constant = IntegerValue(0)
 

Detailed Description

Represents [coeff * variable + constant] or just a [constant].

In some places it is useful to manipulate such expression instead of having to create an extra integer variable. This is mainly used for scheduling related constraints.

Definition at line 295 of file integer.h.

Constructor & Destructor Documentation

◆ AffineExpression() [1/5]

operations_research::sat::AffineExpression::AffineExpression ( )
default

Helper to construct an AffineExpression.

◆ AffineExpression() [2/5]

operations_research::sat::AffineExpression::AffineExpression ( IntegerValue cst)
inline

Definition at line 298 of file integer.h.

◆ AffineExpression() [3/5]

operations_research::sat::AffineExpression::AffineExpression ( IntegerVariable v)
inline

Definition at line 300 of file integer.h.

◆ AffineExpression() [4/5]

operations_research::sat::AffineExpression::AffineExpression ( IntegerVariable v,
IntegerValue c )
inline

Definition at line 302 of file integer.h.

◆ AffineExpression() [5/5]

operations_research::sat::AffineExpression::AffineExpression ( IntegerVariable v,
IntegerValue c,
IntegerValue cst )
inline

Definition at line 304 of file integer.h.

Member Function Documentation

◆ DebugString()

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

Definition at line 343 of file integer.h.

◆ GreaterOrEqual()

IntegerLiteral operations_research::sat::AffineExpression::GreaterOrEqual ( IntegerValue bound) const
inline

var * coeff + constant >= bound.

Returns the integer literal corresponding to expression >= value or expression <= value.

On constant expressions, they will return IntegerLiteral::TrueLiteral() or IntegerLiteral::FalseLiteral().

Definition at line 1696 of file integer.h.

◆ IsConstant()

bool operations_research::sat::AffineExpression::IsConstant ( ) const
inline

Definition at line 341 of file integer.h.

◆ LowerOrEqual()

IntegerLiteral operations_research::sat::AffineExpression::LowerOrEqual ( IntegerValue bound) const
inline

var * coeff + constant <= bound.

Definition at line 1708 of file integer.h.

◆ LpValue()

double operations_research::sat::AffineExpression::LpValue ( const util_intops::StrongVector< IntegerVariable, double > & lp_values) const
inline

Returns the affine expression value under a given LP solution.

Definition at line 335 of file integer.h.

◆ MultipliedBy()

AffineExpression operations_research::sat::AffineExpression::MultipliedBy ( IntegerValue multiplier) const
inline
Note
this also works if multiplier is negative.

Definition at line 320 of file integer.h.

◆ Negated()

AffineExpression operations_research::sat::AffineExpression::Negated ( ) const
inline

Definition at line 315 of file integer.h.

◆ operator==()

bool operations_research::sat::AffineExpression::operator== ( AffineExpression o) const
inline

Definition at line 325 of file integer.h.

◆ ValueAt()

IntegerValue operations_research::sat::AffineExpression::ValueAt ( IntegerValue var_value) const
inline

Returns the value of this affine expression given its variable value.

Definition at line 330 of file integer.h.

Member Data Documentation

◆ coeff

IntegerValue operations_research::sat::AffineExpression::coeff = IntegerValue(0)

Definition at line 358 of file integer.h.

◆ constant

IntegerValue operations_research::sat::AffineExpression::constant = IntegerValue(0)

Definition at line 359 of file integer.h.

◆ var

IntegerVariable operations_research::sat::AffineExpression::var = kNoIntegerVariable

The coefficient MUST be positive. Use NegationOf(var) if needed.

Todo
(user): Make this private to enforce the invariant that coeff cannot be negative.

Definition at line 357 of file integer.h.


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