14#ifndef ORTOOLS_MATH_OPT_ELEMENTAL_ATTRIBUTES_H_
15#define ORTOOLS_MATH_OPT_ELEMENTAL_ATTRIBUTES_H_
24#include "absl/strings/string_view.h"
46template <
typename ValueTypeT,
int n,
typename SymmetryT,
typename Impl>
71 static constexpr int NumAttrs() {
return Impl::kAttrDescriptors.size(); }
75 std::array<
typename Impl::AttrType,
NumAttrs()> result;
76 for (
int i = 0; i <
NumAttrs(); ++i) {
77 result[i] = {
static_cast<typename Impl::AttrType
>(i)};
85 static constexpr absl::string_view
kName =
"BoolAttr0";
90 {{.name =
"maximize", .default_value =
false, .key_types = {}}});
95 static constexpr absl::string_view
kName =
"BoolAttr1";
104 {{.name =
"variable_integer",
105 .default_value =
false,
107 {.name =
"auxiliary_objective_maximize",
108 .default_value =
false,
110 {.name =
"indicator_constraint_activate_on_zero",
111 .default_value =
false,
117 IntAttr0TypeDescriptor> {
118 static constexpr absl::string_view
kName =
"IntAttr0";
125 {.name =
"objective_priority", .default_value = 0, .key_types = {}},
131 IntAttr1TypeDescriptor> {
132 static constexpr absl::string_view
kName =
"IntAttr1";
139 {.name =
"auxiliary_objective_priority",
147 DoubleAttr0TypeDescriptor> {
148 static constexpr absl::string_view
kName =
"DoubleAttr0";
153 {{.name =
"objective_offset", .default_value = 0.0, .key_types = {}}});
158 DoubleAttr1TypeDescriptor> {
159 static constexpr absl::string_view
kName =
"DoubleAttr1";
175 {.name =
"variable_lower_bound",
176 .default_value = -std::numeric_limits<double>::infinity(),
178 {.name =
"variable_upper_bound",
179 .default_value = std::numeric_limits<double>::infinity(),
181 {.name =
"objective_linear_coefficient",
182 .default_value = 0.0,
184 {.name =
"linear_constraint_lower_bound",
185 .default_value = -std::numeric_limits<double>::infinity(),
187 {.name =
"linear_constraint_upper_bound",
188 .default_value = std::numeric_limits<double>::infinity(),
190 {.name =
"auxiliary_objective_offset",
191 .default_value = 0.0,
193 {.name =
"quadratic_constraint_lower_bound",
194 .default_value = -std::numeric_limits<double>::infinity(),
196 {.name =
"quadratic_constraint_upper_bound",
197 .default_value = std::numeric_limits<double>::infinity(),
199 {.name =
"indicator_constraint_lower_bound",
200 .default_value = -std::numeric_limits<double>::infinity(),
202 {.name =
"indicator_constraint_upper_bound",
203 .default_value = std::numeric_limits<double>::infinity(),
210 DoubleAttr2TypeDescriptor> {
211 static constexpr absl::string_view
kName =
"DoubleAttr2";
221 {.name =
"linear_constraint_coefficient",
222 .default_value = 0.0,
224 {.name =
"auxiliary_objective_linear_coefficient",
225 .default_value = 0.0,
227 {.name =
"quadratic_constraint_linear_coefficient",
228 .default_value = 0.0,
231 {.name =
"indicator_constraint_linear_coefficient",
232 .default_value = 0.0,
240 SymmetricDoubleAttr2TypeDescriptor> {
241 static constexpr absl::string_view
kName =
"SymmetricDoubleAttr2";
248 {.name =
"objective_quadratic_coefficient",
249 .default_value = 0.0,
258 SymmetricDoubleAttr3TypeDescriptor> {
259 static constexpr absl::string_view
kName =
"SymmetricDoubleAttr3";
266 {.name =
"quadratic_constraint_quadratic_coefficient",
267 .default_value = 0.0,
275 VariableAttr1TypeDescriptor> {
276 static constexpr absl::string_view
kName =
"VariableAttr1";
283 {.name =
"indicator_constraint_indicator",
312template <
typename AttrT>
317 return ((std::is_same_v<std::remove_cv_t<std::remove_reference_t<AttrT>>,
318 typename std::tuple_element_t<i, Tuple>::AttrType>
325template <
typename AttrT,
326 typename = std::enable_if_t<(GetIndexIfAttr<AttrT>() >= 0)>>
330 const int attr_index =
static_cast<int>(attr);
331 return Descriptor::kAttrDescriptors[attr_index].name;
334template <
typename Sink,
typename AttrT,
335 typename = std::enable_if_t<(GetIndexIfAttr<AttrT>() >= 0)>>
340template <
typename AttrT>
341std::enable_if_t<(GetIndexIfAttr<AttrT>() >= 0), std::ostream&>
operator<<(
342 std::ostream& ostr, AttrT attr) {
constexpr std::array< std::remove_cv_t< T >, N > to_array(T(&ts)[N])
constexpr decltype(auto) ApplyOnIndexRange(Fn &&fn)
SymmetricDoubleAttr2TypeDescriptor::AttrType SymmetricDoubleAttr2
DoubleAttr0TypeDescriptor::AttrType DoubleAttr0
BoolAttr1TypeDescriptor::AttrType BoolAttr1
VariableAttr1TypeDescriptor::AttrType VariableAttr1
IntAttr1TypeDescriptor::AttrType IntAttr1
ElementId< ElementType::kVariable > VariableId
void AbslStringify(Sink &sink, const RemoteStreamingSolveMode mode)
DoubleAttr1TypeDescriptor::AttrType DoubleAttr1
DoubleAttr2TypeDescriptor::AttrType DoubleAttr2
SymmetricDoubleAttr3TypeDescriptor::AttrType SymmetricDoubleAttr3
absl::string_view ToString(const AttrT attr)
std::tuple< BoolAttr0TypeDescriptor, BoolAttr1TypeDescriptor, IntAttr0TypeDescriptor, IntAttr1TypeDescriptor, DoubleAttr0TypeDescriptor, DoubleAttr1TypeDescriptor, DoubleAttr2TypeDescriptor, SymmetricDoubleAttr2TypeDescriptor, SymmetricDoubleAttr3TypeDescriptor, VariableAttr1TypeDescriptor > AllAttrTypeDescriptors
static constexpr int GetIndexIfAttr()
BoolAttr0TypeDescriptor::AttrType BoolAttr0
IntAttr0TypeDescriptor::AttrType IntAttr0
std::array< ElementType, n > key_types
static constexpr auto Enumerate()
static constexpr int kNumKeyElements
static constexpr int NumAttrs()
static constexpr absl::string_view kName
static constexpr auto kAttrDescriptors
static constexpr absl::string_view kName
static constexpr auto kAttrDescriptors
static constexpr auto kAttrDescriptors
static constexpr absl::string_view kName
static constexpr auto kAttrDescriptors
static constexpr absl::string_view kName
static constexpr auto kAttrDescriptors
static constexpr absl::string_view kName
static constexpr absl::string_view kName
static constexpr auto kAttrDescriptors
static constexpr auto kAttrDescriptors
static constexpr absl::string_view kName
static constexpr absl::string_view kName
static constexpr auto kAttrDescriptors
static constexpr auto kAttrDescriptors
static constexpr absl::string_view kName
static constexpr absl::string_view kName
static constexpr auto kAttrDescriptors