16 #include "absl/container/flat_hash_set.h"
17 #include "absl/status/status.h"
21 #include "ortools/math_opt/model.pb.h"
22 #include "ortools/math_opt/sparse_containers.pb.h"
30 if (!constraint.weights().empty() &&
31 constraint.weights_size() != constraint.expressions_size()) {
33 <<
"Length mismatch between weights and expressions: "
34 << constraint.weights_size() <<
" vs. "
35 << constraint.expressions_size();
37 for (
const LinearExpressionProto& expression : constraint.expressions()) {
39 <<
"Invalid SOS expression";
42 absl::flat_hash_set<double> weights;
43 for (
const double weight : constraint.weights()) {
45 if (!weights.insert(
weight).second) {
47 <<
"SOS weights must be unique, but encountered duplicate weight: "
51 return absl::OkStatus();
#define RETURN_IF_ERROR(expr)
absl::Status ValidateConstraint(const IndicatorConstraintProto &constraint, const IdNameBiMap &variable_universe)
absl::Status CheckScalarNoNanNoInf(const double d)
absl::Status ValidateLinearExpression(const LinearExpressionProto &expression, const IdNameBiMap &variable_universe)
StatusBuilder InvalidArgumentErrorBuilder()