16#ifndef OR_TOOLS_MATH_OPT_CONSTRAINTS_SOS_SOS2_CONSTRAINT_H_
17#define OR_TOOLS_MATH_OPT_CONSTRAINTS_SOS_SOS2_CONSTRAINT_H_
24#include "absl/strings/string_view.h"
44 inline int64_t
id()
const;
46 inline Sos2ConstraintId
typed_id()
const;
47 inline const ModelStorage*
storage()
const;
53 inline absl::string_view
name()
const;
69 friend std::ostream&
operator<<(std::ostream& ostr,
73 const ModelStorage* storage_;
79inline std::ostream&
operator<<(std::ostream& ostr,
93 return storage_->constraint_data(id_).num_expressions();
97 return storage_->constraint_data(id_).has_weights();
101 return storage_->constraint_data(id_).weight(
index);
105 if (storage_->has_constraint(id_)) {
106 return storage_->constraint_data(id_).name();
116 return lhs.id_ == rhs.id_ && lhs.storage_ == rhs.storage_;
120 return !(lhs == rhs);
125 return H::combine(std::move(h), constraint.id_.value(), constraint.storage_);
132 ostr <<
"__sos2_con#" << constraint.
id() <<
"__";
140 if (storage_->has_constraint(id_)) {
147 const Sos2ConstraintId
id)
148 : storage_(storage), id_(id) {}
friend bool operator==(const Sos2Constraint &lhs, const Sos2Constraint &rhs)
const ModelStorage * storage() const
friend H AbslHashValue(H h, const Sos2Constraint &constraint)
friend bool operator!=(const Sos2Constraint &lhs, const Sos2Constraint &rhs)
int64_t num_expressions() const
double weight(int index) const
Sos2Constraint(const ModelStorage *storage, Sos2ConstraintId id)
std::string ToString() const
LinearExpression Expression(int index) const
absl::string_view name() const
Sos2ConstraintId typed_id() const
friend std::ostream & operator<<(std::ostream &ostr, const Sos2Constraint &constraint)
Sos2ConstraintId IdType
The typed integer used for ids.
std::vector< Variable > NonzeroVariables() const
const std::string name
A name for logging purposes.
std::string SosConstraintToString(SosConstraint constraint, absl::string_view sos_type_name)
An object oriented wrapper for quadratic constraints in ModelStorage.
constexpr absl::string_view kDeletedConstraintDefaultDescription
std::ostream & operator<<(std::ostream &ostr, const IndicatorConstraint &constraint)
bool operator==(const IndicatorConstraint &lhs, const IndicatorConstraint &rhs)
bool operator!=(const IndicatorConstraint &lhs, const IndicatorConstraint &rhs)
std::vector< Variable > AtomicConstraintNonzeroVariables(const ModelStorage &storage, const IdType id)
H AbslHashValue(H h, const IndicatorConstraint &constraint)