Skip to content

Commit 792ffee

Browse files
fix latent sign bug
1 parent fe1fff3 commit 792ffee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/math/lp/lar_solver.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,8 @@ namespace lp {
11831183
slack += coeff * (adj_sign < 0 ? get_upper_bound(j) : get_lower_bound(j));
11841184
}
11851185

1186-
bool is_pos = slack.is_pos();
1186+
#define get_sign(_x_) (_x_.is_pos() ? 1 : (_x_.is_neg() ? -1 : 0))
1187+
int sign = get_sign(slack);
11871188
#endif
11881189

11891190
for (auto& [coeff, j] : inf_row) {
@@ -1199,7 +1200,7 @@ namespace lp {
11991200
if (ul.previous_upper() != UINT_MAX) {
12001201
auto const& [_is_upper, _j, _bound, _column] = m_column_updates[ul.previous_upper()];
12011202
auto new_slack = slack + coeff * (_bound - get_upper_bound(j));
1202-
if (is_pos == new_slack.is_pos()) {
1203+
if (sign == get_sign(new_slack)) {
12031204
//verbose_stream() << "can weaken j" << j << " " << coeff << " " << get_upper_bound(j) << " " << _bound << "\n";
12041205
slack = new_slack;
12051206
bound_constr_i = _column.upper_bound_witness();
@@ -1210,7 +1211,7 @@ namespace lp {
12101211
if (ul.previous_lower() != UINT_MAX) {
12111212
auto const& [_is_upper, _j, _bound, _column] = m_column_updates[ul.previous_lower()];
12121213
auto new_slack = slack + coeff * (_bound - get_lower_bound(j));
1213-
if (is_pos == new_slack.is_pos()) {
1214+
if (sign == get_sign(new_slack)) {
12141215
//verbose_stream() << "can weaken j" << j << " " << coeff << " " << get_lower_bound(j) << " " << _bound << "\n";
12151216
slack = new_slack;
12161217
bound_constr_i = _column.lower_bound_witness();

0 commit comments

Comments
 (0)