16#ifndef OR_TOOLS_MATH_OPT_CONSTRAINTS_SOS_SOS1_CONSTRAINT_H_
17#define OR_TOOLS_MATH_OPT_CONSTRAINTS_SOS_SOS1_CONSTRAINT_H_
24#include "absl/strings/string_view.h"
44 inline int64_t
id()
const;
46 inline Sos1ConstraintId
typed_id()
const;
47 inline const ModelStorage*
storage()
const;
53 inline absl::string_view
name()
const;
68 friend std::ostream&
operator<<(std::ostream& ostr,
72 const ModelStorage* storage_;
78inline std::ostream&
operator<<(std::ostream& ostr,
92 return storage_->constraint_data(id_).num_expressions();
96 return storage_->constraint_data(id_).has_weights();
100 return storage_->constraint_data(id_).weight(
index);
104 if (storage_->has_constraint(id_)) {
105 return storage_->constraint_data(id_).name();
115 return lhs.id_ == rhs.id_ && lhs.storage_ == rhs.storage_;
119 return !(lhs == rhs);
124 return H::combine(std::move(h), constraint.id_.value(), constraint.storage_);
131 ostr <<
"__sos1_con#" << constraint.
id() <<
"__";
139 if (storage_->has_constraint(id_)) {
146 const Sos1ConstraintId
id)
147 : storage_(storage), id_(id) {}
int64_t num_expressions() const
std::vector< Variable > NonzeroVariables() const
friend bool operator!=(const Sos1Constraint &lhs, const Sos1Constraint &rhs)
std::string ToString() const
Returns a detailed string description of the constraint.
friend bool operator==(const Sos1Constraint &lhs, const Sos1Constraint &rhs)
friend H AbslHashValue(H h, const Sos1Constraint &constraint)
const ModelStorage * storage() const
Sos1Constraint(const ModelStorage *storage, Sos1ConstraintId id)
absl::string_view name() const
double weight(int index) const
Sos1ConstraintId typed_id() const
Sos1ConstraintId IdType
The typed integer used for ids.
friend std::ostream & operator<<(std::ostream &ostr, const Sos1Constraint &constraint)
LinearExpression Expression(int index) 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)