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

#include <quadratic_constraint.h>

Public Types

using IdType = QuadraticConstraintId
 The typed integer used for ids.
 

Public Member Functions

 QuadraticConstraint (const ModelStorage *storage, QuadraticConstraintId id)
 
int64_t id () const
 
QuadraticConstraintId typed_id () const
 
const ModelStorage * storage () const
 
double lower_bound () const
 
double upper_bound () const
 
absl::string_view name () const
 
bool is_linear_coefficient_nonzero (Variable variable) const
 
bool is_quadratic_coefficient_nonzero (Variable first_variable, Variable second_variable) const
 
double linear_coefficient (Variable variable) const
 
double quadratic_coefficient (Variable first_variable, Variable second_variable) const
 
std::vector< VariableNonzeroVariables () const
 
BoundedQuadraticExpression AsBoundedQuadraticExpression () const
 
std::string ToString () const
 

Friends

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

Detailed Description

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

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

Definition at line 43 of file quadratic_constraint.h.

Member Typedef Documentation

◆ IdType

The typed integer used for ids.

Definition at line 46 of file quadratic_constraint.h.

Constructor & Destructor Documentation

◆ QuadraticConstraint()

operations_research::math_opt::QuadraticConstraint::QuadraticConstraint ( const ModelStorage * storage,
QuadraticConstraintId id )
inline

Definition at line 206 of file quadratic_constraint.h.

Member Function Documentation

◆ AsBoundedQuadraticExpression()

BoundedQuadraticExpression operations_research::math_opt::QuadraticConstraint::AsBoundedQuadraticExpression ( ) const

Returns the constraints as a bounded quadratic expression.

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

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

///< Here e will contain 3.2 - 1.0 <= x*x <= 4.2 - 1.0. const BoundedQuadraticExpression e = c.AsBoundedQuadraticExpression();

Definition at line 26 of file quadratic_constraint.cc.

◆ id()

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

Inline function implementations

Definition at line 118 of file quadratic_constraint.h.

◆ is_linear_coefficient_nonzero()

bool operations_research::math_opt::QuadraticConstraint::is_linear_coefficient_nonzero ( Variable variable) const
inline

Definition at line 139 of file quadratic_constraint.h.

◆ is_quadratic_coefficient_nonzero()

bool operations_research::math_opt::QuadraticConstraint::is_quadratic_coefficient_nonzero ( Variable first_variable,
Variable second_variable ) const
inline

Definition at line 144 of file quadratic_constraint.h.

◆ linear_coefficient()

double operations_research::math_opt::QuadraticConstraint::linear_coefficient ( Variable variable) const
inline

Returns 0.0 if the variable does not appear in the linear part of the constraint.

Definition at line 149 of file quadratic_constraint.h.

◆ lower_bound()

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

Definition at line 124 of file quadratic_constraint.h.

◆ name()

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

Definition at line 132 of file quadratic_constraint.h.

◆ NonzeroVariables()

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

All variables that appear in the quadratic constraint with a nonzero coefficient: in the linear terms, the quadratic terms, or both. Order is not defined.

Definition at line 165 of file quadratic_constraint.h.

◆ quadratic_coefficient()

double operations_research::math_opt::QuadraticConstraint::quadratic_coefficient ( Variable first_variable,
Variable second_variable ) const
inline

Returns 0.0 if the variable does not appear in the quadratic part of the constraint.

Definition at line 155 of file quadratic_constraint.h.

◆ storage()

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

Definition at line 122 of file quadratic_constraint.h.

◆ ToString()

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

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

Definition at line 169 of file quadratic_constraint.h.

◆ typed_id()

QuadraticConstraintId operations_research::math_opt::QuadraticConstraint::typed_id ( ) const
inline

Definition at line 120 of file quadratic_constraint.h.

◆ upper_bound()

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

Definition at line 128 of file quadratic_constraint.h.

Friends And Related Symbol Documentation

◆ AbslHashValue

template<typename H >
H AbslHashValue ( H h,
const QuadraticConstraint & quadratic_constraint )
friend

Definition at line 189 of file quadratic_constraint.h.

◆ operator!=

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

Definition at line 183 of file quadratic_constraint.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & ostr,
const QuadraticConstraint & quadratic_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 194 of file quadratic_constraint.h.

◆ operator==

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

Definition at line 178 of file quadratic_constraint.h.


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