18#include "absl/status/status.h"
21#include "ortools/math_opt/infeasible_subsystem.pb.h"
22#include "ortools/math_opt/result.pb.h"
30absl::Status CheckMapKeys(
31 const google::protobuf::Map<int64_t, ModelSubsetProto::Bounds>& bounds_map,
32 const IdNameBiMap& universe) {
33 for (
const auto& [
id, unused] : bounds_map) {
34 if (!universe.HasId(
id)) {
38 return absl::OkStatus();
41absl::Status CheckRepeatedIds(
42 const google::protobuf::RepeatedField<int64_t>& ids,
43 const IdNameBiMap& universe) {
46 return absl::OkStatus();
54 CheckMapKeys(model_subset.variable_bounds(), model_summary.
variables))
55 <<
"bad ModelSubsetProto.variable_bounds";
58 <<
"bad ModelSubsetProto.variable_integrality";
61 <<
"bad ModelSubsetProto.linear_constraints";
64 <<
"bad ModelSubsetProto.quadratic_constraints";
65 RETURN_IF_ERROR(CheckRepeatedIds(model_subset.second_order_cone_constraints(),
67 <<
"bad ModelSubsetProto.second_order_cone_constraints";
70 <<
"bad ModelSubsetProto.sos1_constraints";
73 <<
"bad ModelSubsetProto.sos2_constraints";
76 <<
"bad ModelSubsetProto.indicator_constraints";
77 return absl::OkStatus();
81 const ComputeInfeasibleSubsystemResultProto& result,
84 if (result.feasibility() == FEASIBILITY_STATUS_INFEASIBLE) {
88 return absl::OkStatus();
92 const ComputeInfeasibleSubsystemResultProto& result) {
94 <<
"bad ComputeInfeasibleSubsystemResultProto.feasibility";
95 if (result.feasibility() != FEASIBILITY_STATUS_INFEASIBLE) {
101 <<
"nonempty infeasible_subsystem with feasibility status: "
102 << FeasibilityStatusProto_Name(result.feasibility());
104 if (result.is_minimal()) {
106 <<
"is_minimal is true with feasibility status: "
107 << FeasibilityStatusProto_Name(result.feasibility());
110 return absl::OkStatus();
#define RETURN_IF_ERROR(expr)
An object oriented wrapper for quadratic constraints in ModelStorage.
absl::Status ValidateFeasibilityStatus(const FeasibilityStatusProto &status)
absl::Status ValidateModelSubset(const ModelSubsetProto &model_subset, const ModelSummary &model_summary)
absl::Status ValidateComputeInfeasibleSubsystemResult(const ComputeInfeasibleSubsystemResultProto &result, const ModelSummary &model_summary)
absl::Status CheckIdsSubset(absl::Span< const int64_t > ids, const IdNameBiMap &universe, std::optional< int64_t > upper_bound)
absl::Status ValidateComputeInfeasibleSubsystemResultNoModel(const ComputeInfeasibleSubsystemResultProto &result)
Validates the internal consistency of the fields.
absl::Status CheckIdsRangeAndStrictlyIncreasing(absl::Span< const int64_t > ids)
StatusBuilder InvalidArgumentErrorBuilder()
IdNameBiMap sos2_constraints
IdNameBiMap second_order_cone_constraints
IdNameBiMap linear_constraints
IdNameBiMap sos1_constraints
IdNameBiMap quadratic_constraints
IdNameBiMap indicator_constraints