Skip to content

Commit b58edfc

Browse files
committed
fix stale values on crushing the solution again. there might be some zero slack values left in the previous solution
1 parent 84e344a commit b58edfc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cpp/src/dual_simplex/presolve.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,9 @@ void crush_primal_solution(const user_problem_t<i_t, f_t>& user_problem,
11631163
const std::vector<i_t>& new_slacks,
11641164
std::vector<f_t>& solution)
11651165
{
1166-
solution.resize(problem.num_cols, 0.0);
1166+
// Re-crush can be called with a reused output vector; make sure all entries,
1167+
// including previously added slacks, are reset before writing new values.
1168+
solution.assign(problem.num_cols, 0.0);
11671169
for (i_t j = 0; j < user_problem.num_cols; j++) {
11681170
solution[j] = user_solution[j];
11691171
}
@@ -1202,7 +1204,8 @@ void crush_primal_solution_with_slack(const user_problem_t<i_t, f_t>& user_probl
12021204
const std::vector<i_t>& new_slacks,
12031205
std::vector<f_t>& solution)
12041206
{
1205-
solution.resize(problem.num_cols, 0.0);
1207+
// Re-crush can be called with a reused output vector; clear stale entries first.
1208+
solution.assign(problem.num_cols, 0.0);
12061209
for (i_t j = 0; j < user_problem.num_cols; j++) {
12071210
solution[j] = user_solution[j];
12081211
}

0 commit comments

Comments
 (0)