Google OR-Tools v9.9
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::LinearConstraint Class Reference

#include <linear_constraint.h>

Public Types

using IdType = LinearConstraintId
 The typed integer used for ids.
 

Public Member Functions

 LinearConstraint (const ModelStorage *storage, LinearConstraintId id)
 
int64_t id () const
 
LinearConstraintId typed_id () const
 
const ModelStorage * storage () const
 
double lower_bound () const
 
double upper_bound () const
 
absl::string_view name () const
 
bool is_coefficient_nonzero (Variable variable) const
 
double coefficient (Variable variable) const
 Returns 0.0 if the variable is not used in the constraint.
 
BoundedLinearExpression AsBoundedLinearExpression () const
 
std::string ToString () const
 

Friends

bool operator== (const LinearConstraint &lhs, const LinearConstraint &rhs)
 
bool operator!= (const LinearConstraint &lhs, const LinearConstraint &rhs)
 
template<typename H >
AbslHashValue (H h, const LinearConstraint &linear_constraint)
 
std::ostream & operator<< (std::ostream &ostr, const LinearConstraint &linear_constraint)
 

Detailed Description

A value type that references a linear constraint from ModelStorage. Usually this type is passed by copy.

Definition at line 41 of file linear_constraint.h.

Member Typedef Documentation

◆ IdType

The typed integer used for ids.

Definition at line 44 of file linear_constraint.h.

Constructor & Destructor Documentation

◆ LinearConstraint()

operations_research::math_opt::LinearConstraint::LinearConstraint ( const ModelStorage * storage,
LinearConstraintId id )
inline

Definition at line 187 of file linear_constraint.h.

Member Function Documentation

◆ AsBoundedLinearExpression()

BoundedLinearExpression operations_research::math_opt::LinearConstraint::AsBoundedLinearExpression ( ) const
inline

Returns the constraints as a bounded linear expression.

The linear expression will have a zero offset, even if the constraint was created with a non-zero one. For example:

const LinearConstraint c = model.AddLinearConstraint(3.2 <= x + 1.0 <= 4.2);

///< Here e will contain 3.2 - 1.0 <= x <= 4.2 - 1.0. const BoundedLinearExpression e = c.AsBoundedLinearExpression();

Definition at line 140 of file linear_constraint.h.

◆ coefficient()

double operations_research::math_opt::LinearConstraint::coefficient ( Variable variable) const
inline

Returns 0.0 if the variable is not used in the constraint.

Definition at line 134 of file linear_constraint.h.

◆ id()

int64_t operations_research::math_opt::LinearConstraint::id ( ) const
inline

Inline function implementations

Definition at line 106 of file linear_constraint.h.

◆ is_coefficient_nonzero()

bool operations_research::math_opt::LinearConstraint::is_coefficient_nonzero ( Variable variable) const
inline

Definition at line 127 of file linear_constraint.h.

◆ lower_bound()

double operations_research::math_opt::LinearConstraint::lower_bound ( ) const
inline

Definition at line 112 of file linear_constraint.h.

◆ name()

absl::string_view operations_research::math_opt::LinearConstraint::name ( ) const
inline

Definition at line 120 of file linear_constraint.h.

◆ storage()

const ModelStorage * operations_research::math_opt::LinearConstraint::storage ( ) const
inline

Definition at line 110 of file linear_constraint.h.

◆ ToString()

std::string operations_research::math_opt::LinearConstraint::ToString ( ) const
inline

Returns a detailed string description of the contents of the constraint (not its name, use << for that instead).

Definition at line 152 of file linear_constraint.h.

◆ typed_id()

LinearConstraintId operations_research::math_opt::LinearConstraint::typed_id ( ) const
inline

Definition at line 108 of file linear_constraint.h.

◆ upper_bound()

double operations_research::math_opt::LinearConstraint::upper_bound ( ) const
inline

Definition at line 116 of file linear_constraint.h.

Friends And Related Symbol Documentation

◆ AbslHashValue

template<typename H >
H AbslHashValue ( H h,
const LinearConstraint & linear_constraint )
friend

Definition at line 170 of file linear_constraint.h.

◆ operator!=

bool operator!= ( const LinearConstraint & lhs,
const LinearConstraint & rhs )
friend

Definition at line 165 of file linear_constraint.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & ostr,
const LinearConstraint & linear_constraint )
friend

Streams the name of the constraint, as registered upon constraint creation, or a short default if none was provided.

Todo
(b/170992529): handle quoting of invalid characters in the name.

Definition at line 175 of file linear_constraint.h.

◆ operator==

bool operator== ( const LinearConstraint & lhs,
const LinearConstraint & rhs )
friend

Definition at line 161 of file linear_constraint.h.


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