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

#include <indicator_constraint.h>

Public Types

using IdType = IndicatorConstraintId
 The typed integer used for ids.
 

Public Member Functions

 IndicatorConstraint (const ModelStorage *storage, IndicatorConstraintId id)
 
int64_t id () const
 
IndicatorConstraintId typed_id () const
 
const ModelStorage * storage () const
 
absl::string_view name () const
 
std::optional< Variableindicator_variable () const
 
bool activate_on_zero () const
 The value the indicator variable takes to activate the implied constraint.
 
BoundedLinearExpression ImpliedConstraint () const
 
std::vector< VariableNonzeroVariables () const
 
std::string ToString () const
 

Friends

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

Detailed Description

A value type that references an indicator constraint from ModelStorage. Usually this type is passed by copy.

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

Definition at line 37 of file indicator_constraint.h.

Member Typedef Documentation

◆ IdType

The typed integer used for ids.

Definition at line 40 of file indicator_constraint.h.

Constructor & Destructor Documentation

◆ IndicatorConstraint()

operations_research::math_opt::IndicatorConstraint::IndicatorConstraint ( const ModelStorage * storage,
IndicatorConstraintId id )
inline

Definition at line 151 of file indicator_constraint.h.

Member Function Documentation

◆ activate_on_zero()

bool operations_research::math_opt::IndicatorConstraint::activate_on_zero ( ) const
inline

The value the indicator variable takes to activate the implied constraint.

Definition at line 116 of file indicator_constraint.h.

◆ id()

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

Inline function implementations

Definition at line 94 of file indicator_constraint.h.

◆ ImpliedConstraint()

BoundedLinearExpression operations_research::math_opt::IndicatorConstraint::ImpliedConstraint ( ) const
Note
The following makes a copy of data.linear_terms. This can be made more efficient if the need arises.

Definition at line 29 of file indicator_constraint.cc.

◆ indicator_variable()

std::optional< Variable > operations_research::math_opt::IndicatorConstraint::indicator_variable ( ) const
inline

Returns nullopt if the indicator variable is unset (this is a valid state, in which the constraint is functionally ignored).

Definition at line 107 of file indicator_constraint.h.

◆ name()

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

Definition at line 100 of file indicator_constraint.h.

◆ NonzeroVariables()

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

Returns all variables that appear in the indicator constraint with a nonzero coefficient. Order is not defined.

Definition at line 120 of file indicator_constraint.h.

◆ storage()

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

Definition at line 98 of file indicator_constraint.h.

◆ ToString()

std::string operations_research::math_opt::IndicatorConstraint::ToString ( ) const

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

Definition at line 38 of file indicator_constraint.cc.

◆ typed_id()

IndicatorConstraintId operations_research::math_opt::IndicatorConstraint::typed_id ( ) const
inline

Definition at line 96 of file indicator_constraint.h.

Friends And Related Symbol Documentation

◆ AbslHashValue

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

Definition at line 135 of file indicator_constraint.h.

◆ operator!=

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

Definition at line 129 of file indicator_constraint.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & ostr,
const IndicatorConstraint & 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 139 of file indicator_constraint.h.

◆ operator==

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

Definition at line 124 of file indicator_constraint.h.


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