20#include "absl/status/status.h"
21#include "absl/strings/str_cat.h"
22#include "absl/types/span.h"
31 const bool enforce_upper_triangular) {
35 <<
"Expected row_id.size=" << nnz
40 <<
"Expected row_id.size=" << nnz
43 int64_t previous_row = -1;
44 int64_t previous_col = -1;
45 for (
int i = 0; i < nnz; ++i) {
46 const int64_t row = matrix.
row_ids(i);
49 <<
"row_ids should be nonnegative, but found id: " << row
50 <<
" (at index: " << i <<
")";
55 <<
"column_ids should be nonnegative, but found id: " << col
56 <<
" (at index: " << i <<
")";
58 if (enforce_upper_triangular && row > col) {
60 <<
"lower triangular entry at [" << row <<
", " << col
61 <<
"] (at index: " << i <<
")";
63 if (row < previous_row) {
65 <<
"row_ids should be nondecreasing, but found ids ["
66 << previous_row <<
", " << row <<
"] at indices [" << i - 1 <<
", "
68 }
else if (row == previous_row) {
69 if (previous_col >= col) {
71 <<
"column_ids should be strictly increasing within a row, but "
73 << row <<
" found [" << previous_col <<
", " << col
74 <<
"] at indices, [" << i - 1 <<
", " << i <<
"]";
80 <<
"Expected finite coefficients without NaN, but at row_id: "
81 << row <<
", column_id: " << col
83 <<
" (at index: " << i <<
")";
88 return absl::OkStatus();
97 <<
"Unknown column_id";
98 return absl::OkStatus();
#define RETURN_IF_ERROR(expr)
double coefficients(int index) const
int column_ids_size() const
repeated int64 column_ids = 2;
::int64_t row_ids(int index) const
int coefficients_size() const
repeated double coefficients = 3;
int row_ids_size() const
repeated int64 row_ids = 1;
::int64_t column_ids(int index) const
An object oriented wrapper for quadratic constraints in ModelStorage.
absl::Status SparseMatrixIdsAreKnown(const SparseDoubleMatrixProto &matrix, const IdNameBiMap &row_ids, const IdNameBiMap &column_ids)
absl::Status CheckIdsSubset(absl::Span< const int64_t > ids, const IdNameBiMap &universe, std::optional< int64_t > upper_bound)
absl::Status SparseMatrixValid(const SparseDoubleMatrixProto &matrix, const bool enforce_upper_triangular)
StatusBuilder InvalidArgumentErrorBuilder()