@@ -3907,25 +3907,32 @@ HPresolve::Result HPresolve::rowPresolve(HighsPostsolveStack& postsolve_stack,
39073907 // try Chvatal-Gomory strengthening
39083908 std::vector<HighsInt> complementedOrShifted;
39093909 complementedOrShifted.resize (rowCoefs.size ());
3910+
39103911 HighsInt direction =
39113912 model->row_upper_ [row] != kHighsInf ? HighsInt{1 } : HighsInt{-1 };
3912- double rhs =
3913+ HighsCDouble rhs =
39133914 direction > 0 ? model->row_upper_ [row] : -model->row_lower_ [row];
3914- for (size_t i = 0 ; i < rowCoefs.size (); ++i) {
3915- HighsInt col = rowIndex[i];
3916- double val = rowCoefs[i];
3917- if (direction * val < 0.0 && model->col_upper_ [col] != kHighsInf ) {
3918- rhs -= direction * val * model->col_upper_ [col];
3919- rowCoefs[i] = -rowCoefs[i];
3920- complementedOrShifted[i] = -1 ;
3921- } else if (direction * val > 0.0 &&
3922- model->col_lower_ [col] != -kHighsInf ) {
3923- rhs -= direction * val * model->col_lower_ [col];
3924- complementedOrShifted[i] = 1 ;
3925- } else {
3926- // no bounds
3927- break ;
3915+
3916+ auto complementOrShift = [&]() {
3917+ for (size_t i = 0 ; i < rowCoefs.size (); ++i) {
3918+ HighsInt col = rowIndex[i];
3919+ double val = direction * rowCoefs[i];
3920+ if (val < 0.0 && model->col_upper_ [col] != kHighsInf ) {
3921+ rhs -= val * static_cast <HighsCDouble>(model->col_upper_ [col]);
3922+ rowCoefs[i] = -rowCoefs[i];
3923+ complementedOrShifted[i] = -1 ;
3924+ } else if (val > 0.0 && model->col_lower_ [col] != -kHighsInf ) {
3925+ rhs -= val * static_cast <HighsCDouble>(model->col_lower_ [col]);
3926+ complementedOrShifted[i] = 1 ;
3927+ } else {
3928+ // unbounded variable; cannot shift or complement!
3929+ return false ;
3930+ }
39283931 }
3932+ return true ;
3933+ };
3934+
3935+ if (complementOrShift ()) {
39293936 }
39303937 }
39313938 }
0 commit comments