Skip to content

Commit 148c04c

Browse files
authored
Don't remove empty columns with infinite bounds (#287)
Dual simplex presolve had an assert to prevent it from removing an empty column with a variable with an infinite bounds. This PR removes the assert and just skips variables with infinite bounds. This fixes Issue #270 Authors: - Chris Maes (https://github.com/chris-maes) Approvers: - Akif ÇÖRDÜK (https://github.com/akifcorduk) URL: #287
1 parent 8cb305b commit 148c04c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

cpp/src/dual_simplex/presolve.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,23 @@ i_t remove_empty_cols(lp_problem_t<i_t, f_t>& problem,
165165
std::vector<i_t> col_marker(problem.num_cols);
166166
i_t new_cols = 0;
167167
for (i_t j = 0; j < problem.num_cols; ++j) {
168+
bool remove_var = false;
168169
if ((problem.A.col_start[j + 1] - problem.A.col_start[j]) == 0) {
169-
col_marker[j] = 1;
170-
presolve_info.removed_variables.push_back(j);
171-
presolve_info.removed_reduced_costs.push_back(problem.objective[j]);
172-
if (problem.objective[j] >= 0) {
170+
if (problem.objective[j] >= 0 && problem.lower[j] > -inf) {
173171
presolve_info.removed_values.push_back(problem.lower[j]);
174172
problem.obj_constant += problem.objective[j] * problem.lower[j];
175-
assert(problem.lower[j] > -inf);
176-
} else {
173+
remove_var = true;
174+
} else if (problem.objective[j] <= 0 && problem.upper[j] < inf) {
177175
presolve_info.removed_values.push_back(problem.upper[j]);
178176
problem.obj_constant += problem.objective[j] * problem.upper[j];
179-
assert(problem.upper[j] < inf);
177+
remove_var = true;
180178
}
179+
}
180+
181+
if (remove_var) {
182+
col_marker[j] = 1;
183+
presolve_info.removed_variables.push_back(j);
184+
presolve_info.removed_reduced_costs.push_back(problem.objective[j]);
181185
} else {
182186
col_marker[j] = 0;
183187
new_cols++;
@@ -751,7 +755,7 @@ i_t presolve(const lp_problem_t<i_t, f_t>& original,
751755
}
752756
}
753757
if (num_empty_cols > 0) {
754-
settings.log.printf("Presolve removing %d empty cols\n", num_empty_cols);
758+
settings.log.printf("Presolve attempt to remove %d empty cols\n", num_empty_cols);
755759
remove_empty_cols(problem, num_empty_cols, presolve_info);
756760
}
757761

0 commit comments

Comments
 (0)