Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::Sos2Constraint Class Referencefinal

Detailed Description

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

This type implements https://abseil.io/docs/cpp/guides/hash.

Definition at line 38 of file sos2_constraint.h.

#include <sos2_constraint.h>

Inheritance diagram for operations_research::math_opt::Sos2Constraint:
operations_research::math_opt::ModelStorageItem

Public Types

using IdType = Sos2ConstraintId
 The typed integer used for ids.

Public Member Functions

 Sos2Constraint (ModelStorageCPtr storage, Sos2ConstraintId id)
int64_t id () const
Sos2ConstraintId typed_id () const
int64_t num_expressions () const
LinearExpression Expression (int index) const
bool has_weights () const
double weight (int index) const
absl::string_view name () const
std::vector< VariableNonzeroVariables () const
std::string ToString () const
Public Member Functions inherited from operations_research::math_opt::ModelStorageItem
ModelStorageCPtr storage () const

Friends

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

Additional Inherited Members

Protected Member Functions inherited from operations_research::math_opt::ModelStorageItem
 ModelStorageItem (ModelStorageCPtr storage)
 ModelStorageItem (const ModelStorageItem &)=default
ModelStorageItemoperator= (const ModelStorageItem &)=default
 ModelStorageItem (ModelStorageItem &&)=default
ModelStorageItemoperator= (ModelStorageItem &&)=default
 ~ModelStorageItem ()=default

Member Typedef Documentation

◆ IdType

The typed integer used for ids.

Definition at line 41 of file sos2_constraint.h.

Constructor & Destructor Documentation

◆ Sos2Constraint()

operations_research::math_opt::Sos2Constraint::Sos2Constraint ( ModelStorageCPtr storage,
Sos2ConstraintId id )
inline

Definition at line 145 of file sos2_constraint.h.

Member Function Documentation

◆ Expression()

LinearExpression operations_research::math_opt::Sos2Constraint::Expression ( int index) const

Definition at line 24 of file sos2_constraint.cc.

◆ has_weights()

bool operations_research::math_opt::Sos2Constraint::has_weights ( ) const
inline

Definition at line 95 of file sos2_constraint.h.

◆ id()

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

Inline function implementations

Definition at line 87 of file sos2_constraint.h.

◆ name()

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

Definition at line 103 of file sos2_constraint.h.

◆ NonzeroVariables()

std::vector< Variable > operations_research::math_opt::Sos2Constraint::NonzeroVariables ( ) const
inline

All variables that appear in the SOS2 constraint with a nonzero coefficient in any of the expressions. Order is not defined.

Definition at line 110 of file sos2_constraint.h.

◆ num_expressions()

int64_t operations_research::math_opt::Sos2Constraint::num_expressions ( ) const
inline

Definition at line 91 of file sos2_constraint.h.

◆ ToString()

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

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

Definition at line 138 of file sos2_constraint.h.

◆ typed_id()

Sos2ConstraintId operations_research::math_opt::Sos2Constraint::typed_id ( ) const
inline

Definition at line 89 of file sos2_constraint.h.

◆ weight()

double operations_research::math_opt::Sos2Constraint::weight ( int index) const
inline

Definition at line 99 of file sos2_constraint.h.

◆ AbslHashValue

template<typename H>
H AbslHashValue ( H h,
const Sos2Constraint & constraint )
friend

Definition at line 123 of file sos2_constraint.h.

◆ operator!=

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

Definition at line 118 of file sos2_constraint.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & ostr,
const Sos2Constraint & 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 127 of file sos2_constraint.h.

◆ operator==

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

Definition at line 114 of file sos2_constraint.h.


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