MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / removeRowsOfCountOne

Function removeRowsOfCountOne

highs/lp_data/HighsLpUtils.cpp:3367–3469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3365}
3366
3367void removeRowsOfCountOne(const HighsLogOptions& log_options, HighsLp& lp) {
3368 vector<HighsInt>& a_start = lp.a_matrix_.start_;
3369 vector<HighsInt>& a_index = lp.a_matrix_.index_;
3370 vector<double>& a_value = lp.a_matrix_.value_;
3371 vector<HighsInt> a_count;
3372 vector<HighsInt> ar_count;
3373 vector<HighsInt> ar_start;
3374 vector<HighsInt> ar_index;
3375 vector<double> ar_value;
3376 const bool have_name = lp.row_names_.size() > 0;
3377 HighsInt num_nz = a_start[lp.num_col_];
3378 const HighsInt original_num_nz = num_nz;
3379 const HighsInt original_num_row = lp.num_row_;
3380 HighsInt num_row_count_1 = 0;
3381 ar_count.assign(lp.num_row_, 0);
3382 for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++) {
3383 for (HighsInt iEl = a_start[iCol]; iEl < a_start[iCol + 1]; iEl++)
3384 ar_count[a_index[iEl]]++;
3385 }
3386 ar_start.push_back(0);
3387 for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++) {
3388 ar_start.push_back(ar_start[iRow] + ar_count[iRow]);
3389 ar_count[iRow] = ar_start[iRow];
3390 }
3391 ar_index.resize(num_nz);
3392 ar_value.resize(num_nz);
3393 for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++) {
3394 for (HighsInt iEl = a_start[iCol]; iEl < a_start[iCol + 1]; iEl++) {
3395 HighsInt iRow = a_index[iEl];
3396 ar_index[ar_count[iRow]] = iCol;
3397 ar_value[ar_count[iRow]] = a_value[iEl];
3398 ar_count[iRow]++;
3399 }
3400 }
3401 HighsInt newRow = 0;
3402 HighsInt newEl = 0;
3403 for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++) {
3404 const HighsInt row_count = ar_start[iRow + 1] - ar_start[iRow];
3405 if (row_count == 1) {
3406 HighsInt iCol = ar_index[ar_start[iRow]];
3407 double value = ar_value[ar_start[iRow]];
3408 assert(value);
3409 if (value > 0) {
3410 if (lp.row_lower_[iRow] > -kHighsInf)
3411 lp.col_lower_[iCol] =
3412 std::max(lp.row_lower_[iRow] / value, lp.col_lower_[iCol]);
3413 if (lp.row_upper_[iRow] < kHighsInf)
3414 lp.col_upper_[iCol] =
3415 std::min(lp.row_upper_[iRow] / value, lp.col_upper_[iCol]);
3416 } else {
3417 if (lp.row_lower_[iRow] > -kHighsInf)
3418 lp.col_upper_[iCol] =
3419 std::min(lp.row_lower_[iRow] / value, lp.col_upper_[iCol]);
3420 if (lp.row_upper_[iRow] < kHighsInf)
3421 lp.col_lower_[iCol] =
3422 std::max(lp.row_upper_[iRow] / value, lp.col_lower_[iCol]);
3423 }
3424 num_row_count_1++;

Callers 1

readModelMethod · 0.85

Calls 4

highsLogUserFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected