Skip to content

Commit b14bbe1

Browse files
committed
Solves adlittle with slack removed
1 parent d5ffacc commit b14bbe1

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

src/presolve/HPresolve.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,17 +4404,13 @@ HPresolve::Result HPresolve::removeSlacks(HighsPostsolveStack& postsolve_stack)
44044404
assert(coeff);
44054405
// Slack is s = (rhs - a^Tx)/coeff
44064406
//
4407-
if (coeff > 0) {
4408-
// Constraint bounds become [rhs - coeff * lower, rhs - coeff *
4409-
// upper]
4410-
model->col_lower_[iCol] = rhs - coeff * lower;
4411-
model->col_upper_[iCol] = rhs - coeff * upper;
4412-
} else {
4413-
// Constraint bounds become [rhs - coeff * upper, rhs - coeff *
4414-
// lower]
4415-
model->col_lower_[iCol] = rhs - coeff * upper;
4416-
model->col_upper_[iCol] = rhs - coeff * lower;
4417-
}
4407+
// Constraint bounds become:
4408+
//
4409+
// For coeff > 0 [rhs - coeff * upper, rhs - coeff * lower]
4410+
//
4411+
// For coeff < 0 [rhs - coeff * lower, rhs - coeff * upper]
4412+
model->row_lower_[iRow] = coeff > 0 ? rhs - coeff * upper : rhs - coeff * lower;
4413+
model->row_upper_[iRow] = coeff > 0 ? rhs - coeff * lower : rhs - coeff * upper;
44184414
if (cost) {
44194415
// Cost is (cost * rhs / coeff) + (col_cost - (cost/coeff) row_values)^Tx
44204416
double multiplier = cost / coeff;
@@ -4426,8 +4422,9 @@ HPresolve::Result HPresolve::removeSlacks(HighsPostsolveStack& postsolve_stack)
44264422
model->offset_ += multiplier * rhs;
44274423
}
44284424
//
4429-
postsolve_stack.slackColSubstitution(iRow, iCol, rhs, cost, lower, upper, coeff,
4430-
getColumnVector(iCol));
4425+
postsolve_stack.slackColSubstitution(iRow, iCol, rhs, cost, lower, upper, //coeff,
4426+
getRowVector(iRow),
4427+
getColumnVector(iCol));
44314428
markColDeleted(iCol);
44324429

44334430
unlink(coliter);

src/presolve/HighsPostsolveStack.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,11 +1356,14 @@ void HighsPostsolveStack::SlackColSubstitution::undo(
13561356
const std::vector<Nonzero>& colValues, HighsSolution& solution,
13571357
HighsBasis& basis) {
13581358

1359-
assert(111==222);
1360-
1361-
1362-
1359+
// Taken from HighsPostsolveStack::FreeColSubstitution::undo(
1360+
//
13631361
// a (removed) cut may have been used in this reduction.
1362+
//
1363+
// May have to determine row dual and basis status unless doing
1364+
// primal-only transformation in MIP solver, in which case row may
1365+
// no longer exist if it corresponds to a removed cut, so have to
1366+
// avoid exceeding array bounds of solution.row_value
13641367
bool isModelRow = static_cast<size_t>(row) < solution.row_value.size();
13651368

13661369
// compute primal values
@@ -1375,9 +1378,9 @@ void HighsPostsolveStack::SlackColSubstitution::undo(
13751378

13761379
assert(colCoef != 0);
13771380
// Row values aren't fully postsolved, so why do this?
1378-
if (isModelRow)
1379-
solution.row_value[row] =
1381+
if (isModelRow) solution.row_value[row] =
13801382
double(rowValue + colCoef * solution.col_value[col]);
1383+
printf("HighsPostsolveStack::SlackColSubstitution::undo rowValue = %g\n", double(rowValue));
13811384
solution.col_value[col] = double((rhs - rowValue) / colCoef);
13821385

13831386
// if no dual values requested, return here

src/presolve/HighsPostsolveStack.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class HighsPostsolveStack {
224224
double colCost;
225225
double colLower;
226226
double colUpper;
227-
double colCoeff;
227+
// double colCoeff;
228228
HighsInt row;
229229
HighsInt col;
230230

@@ -339,16 +339,22 @@ class HighsPostsolveStack {
339339
reductionAdded(ReductionType::kFreeColSubstitution);
340340
}
341341

342-
template <typename ColStorageFormat>
342+
template <typename RowStorageFormat, typename ColStorageFormat>
343343
void slackColSubstitution(HighsInt row, HighsInt col, double rhs,
344-
double colCost, double colLower, double colUpper, double colCoeff,
344+
double colCost, double colLower, double colUpper, //double colCoeff,
345+
const HighsMatrixSlice<RowStorageFormat>& rowVec,
345346
const HighsMatrixSlice<ColStorageFormat>& colVec) {
347+
rowValues.clear();
348+
for (const HighsSliceNonzero& rowVal : rowVec)
349+
rowValues.emplace_back(origColIndex[rowVal.index()], rowVal.value());
350+
346351
colValues.clear();
347352
for (const HighsSliceNonzero& colVal : colVec)
348353
colValues.emplace_back(origRowIndex[colVal.index()], colVal.value());
349354

350-
reductionValues.push(SlackColSubstitution{rhs, colCost, colLower, colUpper, colCoeff, origRowIndex[row],
351-
origColIndex[col]});
355+
reductionValues.push(SlackColSubstitution{rhs, colCost, colLower, colUpper, //colCoeff,
356+
origRowIndex[row],
357+
origColIndex[col]});
352358
reductionValues.push(rowValues);
353359
reductionValues.push(colValues);
354360
reductionAdded(ReductionType::kSlackColSubstitution);

0 commit comments

Comments
 (0)