mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 21:38:44 +00:00
perf in branching (#4719)
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
a414480274
commit
4e74c4cdd4
|
@ -25,7 +25,8 @@ namespace lp {
|
||||||
int_branch::int_branch(int_solver& lia):lia(lia), lra(lia.lra) {}
|
int_branch::int_branch(int_solver& lia):lia(lia), lra(lia.lra) {}
|
||||||
|
|
||||||
lia_move int_branch::operator()() {
|
lia_move int_branch::operator()() {
|
||||||
int j = find_inf_int_column();
|
lra.move_non_basic_columns_to_bounds(true);
|
||||||
|
int j = find_inf_int_base_column();
|
||||||
return j == -1? lia_move::sat : create_branch_on_column(j);
|
return j == -1? lia_move::sat : create_branch_on_column(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ lia_move int_branch::create_branch_on_column(int j) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int int_branch::find_inf_int_column() {
|
int int_branch::find_inf_int_base_column() {
|
||||||
int result = -1;
|
int result = -1;
|
||||||
mpq range;
|
mpq range;
|
||||||
mpq new_range;
|
mpq new_range;
|
||||||
|
@ -58,16 +59,19 @@ int int_branch::find_inf_int_column() {
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
lar_core_solver & lcs = lra.m_mpq_lar_core_solver;
|
lar_core_solver & lcs = lra.m_mpq_lar_core_solver;
|
||||||
unsigned prev_usage = 0; // to quiet down the compile
|
unsigned prev_usage = 0; // to quiet down the compile
|
||||||
|
unsigned k = 0;
|
||||||
unsigned usage;
|
unsigned usage;
|
||||||
unsigned j = 0;
|
unsigned j;
|
||||||
// this loop looks for a column with the most usages, but breaks when
|
// this loop looks for a column with the most usages, but breaks when
|
||||||
// a column with a small span of bounds is found
|
// a column with a small span of bounds is found
|
||||||
for (; j < lra.column_count(); j++) {
|
for (; k < lra.r_basis().size(); k++) {
|
||||||
|
j = lra.r_basis()[k];
|
||||||
if (!lia.column_is_int_inf(j))
|
if (!lia.column_is_int_inf(j))
|
||||||
continue;
|
continue;
|
||||||
usage = lra.usage_in_terms(j);
|
usage = lra.usage_in_terms(j);
|
||||||
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) {
|
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) {
|
||||||
result = j++;
|
result = j;
|
||||||
|
k++;
|
||||||
n = 1;
|
n = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -79,11 +83,13 @@ int int_branch::find_inf_int_column() {
|
||||||
result = j;
|
result = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SASSERT(k == lra.r_basis().size() || n == 1);
|
||||||
// this loop looks for boxed columns with a small span
|
// this loop looks for boxed columns with a small span
|
||||||
for (; j < lra.column_count(); j++) {
|
for (; k < lra.r_basis().size(); k++) {
|
||||||
|
j = lra.r_basis()[k];
|
||||||
if (!lia.column_is_int_inf(j) || !lia.is_boxed(j))
|
if (!lia.column_is_int_inf(j) || !lia.is_boxed(j))
|
||||||
continue;
|
continue;
|
||||||
|
SASSERT(!lia.is_fixed(j));
|
||||||
usage = lra.usage_in_terms(j);
|
usage = lra.usage_in_terms(j);
|
||||||
new_range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x - rational(2*usage);
|
new_range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x - rational(2*usage);
|
||||||
if (new_range < range) {
|
if (new_range < range) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace lp {
|
||||||
class int_solver& lia;
|
class int_solver& lia;
|
||||||
class lar_solver& lra;
|
class lar_solver& lra;
|
||||||
lia_move create_branch_on_column(int j);
|
lia_move create_branch_on_column(int j);
|
||||||
int find_inf_int_column();
|
int find_inf_int_base_column();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int_branch(int_solver& lia);
|
int_branch(int_solver& lia);
|
||||||
|
|
Loading…
Reference in a new issue