Skip to content

Commit dc56ca7

Browse files
Fix assertion bounds in tableau update: ensure variable limits are checked against the correct variable.
1 parent 17e1a59 commit dc56ca7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/linspire.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ namespace linspire
284284
assert(is_basic(x_i));
285285
assert(!is_basic(x_j));
286286
assert(tableau.at(x_i).vars.count(x_j));
287-
assert(v >= lb(x_j) && v <= ub(x_j));
287+
assert(v >= lb(x_i) && v <= ub(x_i));
288288

289289
const auto theta = (v - val(x_i)) / tableau.at(x_i).vars.at(x_j);
290290
LOG_TRACE("x" << std::to_string(x_i) << " = " << utils::to_string(val(x_i)) << " -> " << utils::to_string(v) << " [" << utils::to_string(lb(x_i)) << ", " << utils::to_string(ub(x_i)) << "]");
@@ -294,6 +294,7 @@ namespace linspire
294294
LOG_TRACE("x" << std::to_string(x_j) << " = " << utils::to_string(val(x_j)) << " -> " << utils::to_string(val(x_j) + theta) << " [" << utils::to_string(lb(x_j)) << ", " << utils::to_string(ub(x_j)) << "]");
295295
// x_j += theta
296296
vars[x_j].val += theta;
297+
assert(vars[x_j].val >= lb(x_j) && vars[x_j].val <= ub(x_j));
297298
FIRE_ON_VALUE_CHANGED(x_j);
298299

299300
// the tableau rows containing `x_j` as a non-basic variable..

0 commit comments

Comments
 (0)