Skip to content

Commit 3ce0055

Browse files
committed
Add overflow check for Metis matrix
1 parent 6fea28b commit 3ce0055

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

highs/ipm/hipo/factorhighs/Analyse.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Int64 Analyse::getPermutation(bool metis_no2hop) {
7676
// element is skipped.
7777

7878
std::vector<Int> work(n_, 0);
79+
Int64 total_nz = 0;
7980

8081
// go through the columns to count nonzeros
8182
for (Int64 j = 0; j < n_; ++j) {
@@ -90,9 +91,16 @@ Int64 Analyse::getPermutation(bool metis_no2hop) {
9091

9192
// duplicated on the lower part of column i
9293
++work[i];
94+
95+
total_nz += 2;
9396
}
9497
}
9598

99+
if (total_nz > kHighsIInf) {
100+
if (log_) log_->printe("Integer overflow while preparing Metis\n");
101+
return kRetIntOverflow;
102+
}
103+
96104
// compute column pointers from column counts
97105
std::vector<Int> temp_ptr(n_ + 1, 0);
98106
counts2Ptr(temp_ptr, work);

0 commit comments

Comments
 (0)