@@ -50,7 +50,7 @@ lia_move int_branch::create_branch_on_column(int j) {
50
50
return lia_move::branch;
51
51
}
52
52
53
-
53
+
54
54
55
55
int int_branch::find_inf_int_base_column () {
56
56
int result = -1 ;
@@ -59,39 +59,46 @@ int int_branch::find_inf_int_base_column() {
59
59
mpq small_range_thresold (1024 );
60
60
unsigned n = 0 ;
61
61
lar_core_solver & lcs = lra.m_mpq_lar_core_solver ;
62
- bool small = false ;
63
62
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];
66
70
if (!lia.column_is_int_inf (j))
67
71
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) {
87
74
result = j;
75
+ k++;
88
76
n = 1 ;
89
- } else if (result == -1 || prev_usage < usage) {
77
+ break ;
78
+ }
79
+ if (n == 0 || usage > prev_usage) {
90
80
result = j;
91
81
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 ;
94
98
result = j;
99
+ range = new_range;
100
+ } else if (new_range == range && (lia.random () % (++n) == 0 )) {
101
+ result = j;
95
102
}
96
103
}
97
104
return result;
0 commit comments