| 2067 | } |
| 2068 | |
| 2069 | void HPresolve::addToMatrix(const HighsInt row, const HighsInt col, |
| 2070 | const double val) { |
| 2071 | HighsInt pos = findNonzero(row, col); |
| 2072 | |
| 2073 | markChangedRow(row); |
| 2074 | markChangedCol(col); |
| 2075 | |
| 2076 | if (pos == -1) { |
| 2077 | if (freeslots.empty()) { |
| 2078 | pos = static_cast<HighsInt>(Avalue.size()); |
| 2079 | Avalue.push_back(val); |
| 2080 | Arow.push_back(row); |
| 2081 | Acol.push_back(col); |
| 2082 | Anext.push_back(-1); |
| 2083 | Aprev.push_back(-1); |
| 2084 | ARleft.push_back(-1); |
| 2085 | ARright.push_back(-1); |
| 2086 | } else { |
| 2087 | pos = freeslots.back(); |
| 2088 | freeslots.pop_back(); |
| 2089 | Avalue[pos] = val; |
| 2090 | Arow[pos] = row; |
| 2091 | Acol[pos] = col; |
| 2092 | Aprev[pos] = -1; |
| 2093 | } |
| 2094 | |
| 2095 | link(pos); |
| 2096 | |
| 2097 | // remove implied bounds on row duals that where implied by this column's |
| 2098 | // dual constraint |
| 2099 | resetRowDualImpliedBoundsDerivedFromCol(col); |
| 2100 | |
| 2101 | // remove implied bounds on columns that where implied by this row |
| 2102 | resetColImpliedBoundsDerivedFromRow(row); |
| 2103 | |
| 2104 | // modifications to row invalidate lifting opportunities |
| 2105 | clearLiftingOpportunities(row); |
| 2106 | |
| 2107 | } else { |
| 2108 | double sum = Avalue[pos] + val; |
| 2109 | if (std::abs(sum) <= options->small_matrix_value) { |
| 2110 | unlink(pos); |
| 2111 | } else { |
| 2112 | // remove implied bounds on row duals that where implied by this column's |
| 2113 | // dual constraint |
| 2114 | resetRowDualImpliedBoundsDerivedFromCol(col); |
| 2115 | |
| 2116 | // remove implied bounds on columns that where implied by this row |
| 2117 | resetColImpliedBoundsDerivedFromRow(row); |
| 2118 | |
| 2119 | // modifications to row invalidate lifting opportunities |
| 2120 | clearLiftingOpportunities(row); |
| 2121 | |
| 2122 | // remove the locks and contribution to implied (dual) row bounds, then |
| 2123 | // add then again |
| 2124 | impliedRowBounds.remove(row, col, Avalue[pos]); |
| 2125 | impliedDualRowBounds.remove(col, row, Avalue[pos]); |
| 2126 | Avalue[pos] = sum; |