Skip to content

Commit 35e3df4

Browse files
committed
cosmitic changes in int_branch.cpp
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent d5162d9 commit 35e3df4

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

src/math/lp/int_branch.cpp

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ lia_move int_branch::create_branch_on_column(int j) {
5050
return lia_move::branch;
5151
}
5252

53-
53+
5454

5555
int int_branch::find_inf_int_base_column() {
5656
int result = -1;
@@ -59,39 +59,46 @@ int int_branch::find_inf_int_base_column() {
5959
mpq small_range_thresold(1024);
6060
unsigned n = 0;
6161
lar_core_solver & lcs = lra.m_mpq_lar_core_solver;
62-
bool small = false;
6362
unsigned prev_usage;
64-
for (unsigned j : lra.r_basis()) {
65-
SASSERT(!lia.column_is_int_inf(j) || !lia.is_fixed(j));
63+
unsigned k = 0;
64+
unsigned usage;
65+
unsigned j;
66+
// this loop looks for a column with the most usages, but breaks when
67+
// a column with a small span of bounds is found
68+
for (; k < lra.r_basis().size(); k++) {
69+
j = lra.r_basis()[k];
6670
if (!lia.column_is_int_inf(j))
6771
continue;
68-
bool boxed = lia.is_boxed(j);
69-
unsigned usage = 2 * lra.usage_in_terms(j);
70-
if (small) {
71-
if (!boxed)
72-
continue;
73-
new_range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x - rational(usage);
74-
if (new_range <= small_range_thresold) {
75-
if (new_range < range) {
76-
n = 1;
77-
result = j;
78-
range = new_range;
79-
} else if (new_range == range && lia.random() % (++n) == 0) {
80-
result = j;
81-
}
82-
}
83-
} else if (boxed && (
84-
(range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x - rational(usage))
85-
<= small_range_thresold)) {
86-
small = true;
72+
usage = lra.usage_in_terms(j);
73+
if (lia.is_boxed(j) && (range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x - rational(2*usage)) <= small_range_thresold) {
8774
result = j;
75+
k++;
8876
n = 1;
89-
} else if (result == -1 || prev_usage < usage) {
77+
break;
78+
}
79+
if (n == 0 || usage > prev_usage) {
9080
result = j;
9181
prev_usage = usage;
92-
n = 1;
93-
} else if (prev_usage == usage && lia.random() % (++n) == 0) {
82+
n = 1;
83+
} else if (usage == prev_usage && (lia.random() % (++n) == 0)) {
84+
result = j;
85+
}
86+
}
87+
SASSERT(k == lra.r_basis().size() || n == 1);
88+
// this loop looks for boxed columns with a small span
89+
for (; k < lra.r_basis().size(); k++) {
90+
j = lra.r_basis()[k];
91+
usage = lra.usage_in_terms(j);
92+
if (!lia.column_is_int_inf(j) || !lia.is_boxed(j))
93+
continue;
94+
SASSERT(!lia.is_fixed(j));
95+
new_range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x - rational(2*usage);
96+
if (new_range < range) {
97+
n = 1;
9498
result = j;
99+
range = new_range;
100+
} else if (new_range == range && (lia.random() % (++n) == 0)) {
101+
result = j;
95102
}
96103
}
97104
return result;

0 commit comments

Comments
 (0)