Skip to content

Commit a51276e

Browse files
committed
for conflict graph construction remove fixed variables and upate rhs
1 parent 6390d99 commit a51276e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/CoinDynamicConflictGraph.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ CoinDynamicConflictGraph::CoinDynamicConflictGraph (
151151
smallCliques = new CoinCliqueList( 4096, 3276 );
152152
std::vector<size_t> tmpClq(size_);
153153

154+
// inspecting all rows, compute two largest and smallest values to check if
155+
// constraint is worth deeper inspection
154156
for (size_t idxRow = 0; idxRow < (size_t)matrixByRow->getNumRows(); idxRow++) {
155157
const char rowSense = sense[idxRow];
156158

@@ -161,17 +163,29 @@ CoinDynamicConflictGraph::CoinDynamicConflictGraph (
161163
double rhs = mult * rowRHS[idxRow];
162164
bool onlyBinaryVars = true;
163165

166+
// discount fixed variables from RHS
167+
for (size_t j = start[idxRow]; j < (size_t)start[idxRow] + length[idxRow]; j++) {
168+
const size_t idxCol = idxs[j];
169+
if (colLB[idxCol] == colUB[idxCol]) {
170+
const double coefCol = coefs[j] * mult;
171+
rhs -= coefCol * colLB[idxCol];
172+
}
173+
}
174+
164175
size_t nz = 0;
165176
double twoLargest[2] = { -(std::numeric_limits< double >::max() / 10.0), -(std::numeric_limits< double >::max() / 10.0) };
166177
double twoSmallest[2] = { std::numeric_limits< double >::max() / 10.0, std::numeric_limits< double >::max() / 10.0};
167178
for (size_t j = start[idxRow]; j < (size_t)start[idxRow] + length[idxRow]; j++) {
168179
const size_t idxCol = idxs[j];
169-
const double coefCol = coefs[j] * mult;
170180

181+
if (colLB[idxCol] == colUB[idxCol]) { // already considered in RHS
182+
continue;
183+
}
171184
if (colType[idxCol] != CoinColumnType::Binary) {
172185
onlyBinaryVars = false;
173186
break;
174187
}
188+
const double coefCol = coefs[j] * mult;
175189

176190
if (coefCol >= 0.0) {
177191
columns[nz].first = idxCol;

0 commit comments

Comments
 (0)