14 #ifndef OR_TOOLS_MATH_OPT_CONSTRAINTS_UTIL_MODEL_UTIL_H_
15 #define OR_TOOLS_MATH_OPT_CONSTRAINTS_UTIL_MODEL_UTIL_H_
20 #include "absl/algorithm/container.h"
21 #include "absl/strings/string_view.h"
31 "[constraint deleted from model]";
43 template <
typename IdType>
46 const std::vector<VariableId> raw_vars =
48 std::vector<Variable> vars;
49 vars.reserve(raw_vars.size());
50 for (
const VariableId raw_var : raw_vars) {
51 vars.push_back(
Variable(&storage, raw_var));
58 template <
typename Constra
intType>
60 using IdType =
typename ConstraintType::IdType;
61 std::vector<ConstraintType> result;
63 for (
const IdType con_id : storage.
Constraints<IdType>()) {
64 result.push_back(ConstraintType(&storage, con_id));
70 template <
typename Constra
intType>
73 std::vector<ConstraintType> constraints =
74 AtomicConstraints<ConstraintType>(storage);
75 absl::c_sort(constraints,
76 [](
const ConstraintType& l,
const ConstraintType& r) {
77 return l.typed_id() < r.typed_id();
const AtomicConstraintTraits< IdType >::ConstraintData & constraint_data(IdType id) const
std::vector< IdType > Constraints() const
int64_t num_constraints() const
LinearExpression ToLinearExpression(const ModelStorage &storage, const SparseCoefficientMap &coeffs, const double offset)
std::vector< ConstraintType > AtomicConstraints(const ModelStorage &storage)
std::vector< Variable > AtomicConstraintNonzeroVariables(const ModelStorage &storage, const IdType id)
constexpr absl::string_view kDeletedConstraintDefaultDescription
std::vector< ConstraintType > SortedAtomicConstraints(const ModelStorage &storage)
std::pair< SparseCoefficientMap, double > FromLinearExpression(const LinearExpression &expression)