mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
some fixes in branching
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
029edcfabd
commit
0499b6b64a
|
@ -34,7 +34,6 @@ namespace lp {
|
||||||
return j != -1 ? j : find_inf_int_nbasis_column();
|
return j != -1 ? j : find_inf_int_nbasis_column();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lia_move int_branch::create_branch_on_column(int j) {
|
lia_move int_branch::create_branch_on_column(int j) {
|
||||||
TRACE("check_main_int", tout << "branching" << std::endl;);
|
TRACE("check_main_int", tout << "branching" << std::endl;);
|
||||||
lp_assert(lia.m_t.is_empty());
|
lp_assert(lia.m_t.is_empty());
|
||||||
|
@ -55,61 +54,61 @@ namespace lp {
|
||||||
return lia_move::branch;
|
return lia_move::branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
int int_branch::find_inf_int_base_column() {
|
|
||||||
unsigned inf_int_count = 0;
|
|
||||||
int j = find_inf_int_boxed_base_column_with_smallest_range(inf_int_count);
|
|
||||||
if (j != -1) {
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
if (inf_int_count == 0)
|
|
||||||
return -1;
|
|
||||||
unsigned k = lia.random() % inf_int_count;
|
|
||||||
return get_kth_inf_int(k);
|
|
||||||
}
|
|
||||||
|
|
||||||
int int_branch::get_kth_inf_int(unsigned k) const {
|
|
||||||
for (unsigned j : lra.r_basis())
|
|
||||||
if (lia.column_is_int_inf(j) && k-- == 0)
|
|
||||||
return j;
|
|
||||||
lp_assert(false);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int int_branch::find_inf_int_nbasis_column() const {
|
int int_branch::find_inf_int_nbasis_column() const {
|
||||||
|
unsigned n = 0;
|
||||||
for (unsigned j : lra.r_nbasis())
|
int r = -1;
|
||||||
|
for (unsigned j : lra.r_nbasis()) {
|
||||||
|
SASSERT(!lia.column_is_int_inf(j) || !lia.is_fixed(j));
|
||||||
if (lia.column_is_int_inf(j)) {
|
if (lia.column_is_int_inf(j)) {
|
||||||
return j;
|
if (n == 0) {
|
||||||
|
r = j;
|
||||||
|
n = 1;
|
||||||
|
} else if (lia.random() % (++n) == 0) {
|
||||||
|
r = j;
|
||||||
}
|
}
|
||||||
return -1;
|
}
|
||||||
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int int_branch::find_inf_int_boxed_base_column_with_smallest_range(unsigned & inf_int_count) {
|
int int_branch::find_inf_int_base_column() {
|
||||||
inf_int_count = 0;
|
|
||||||
int result = -1;
|
int result = -1;
|
||||||
mpq range;
|
mpq range;
|
||||||
mpq new_range;
|
mpq new_range;
|
||||||
mpq small_range_thresold(1024);
|
mpq small_range_thresold(1024);
|
||||||
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;
|
||||||
|
bool small = false;
|
||||||
for (unsigned j : lra.r_basis()) {
|
for (unsigned j : lra.r_basis()) {
|
||||||
|
SASSERT(!lia.column_is_int_inf(j) || !lia.is_fixed(j));
|
||||||
if (!lia.column_is_int_inf(j))
|
if (!lia.column_is_int_inf(j))
|
||||||
continue;
|
continue;
|
||||||
inf_int_count++;
|
bool boxed = lia.is_boxed(j);
|
||||||
if (!lia.is_boxed(j))
|
if (small) {
|
||||||
|
if (!boxed)
|
||||||
continue;
|
continue;
|
||||||
lp_assert(!lia.is_fixed(j));
|
|
||||||
new_range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x;
|
new_range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x;
|
||||||
if (new_range > small_range_thresold)
|
if (new_range <= small_range_thresold) {
|
||||||
continue;
|
if (new_range < range) {
|
||||||
if (result == -1 || new_range < range) {
|
n = 1;
|
||||||
|
result = j;
|
||||||
|
range = new_range;
|
||||||
|
} else if (new_range == range && lia.random() % (++n) == 0) {
|
||||||
|
result = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (boxed &&
|
||||||
|
(new_range = lcs.m_r_upper_bounds()[j].x - lcs.m_r_lower_bounds()[j].x)
|
||||||
|
<= small_range_thresold) {
|
||||||
|
small = true;
|
||||||
result = j;
|
result = j;
|
||||||
range = new_range;
|
range = new_range;
|
||||||
n = 1;
|
n = 1;
|
||||||
}
|
} else if (result == -1) {
|
||||||
else if (new_range == range && lia.random() % (++n) == 0) {
|
result = j;
|
||||||
lp_assert(n > 1);
|
n = 1;
|
||||||
|
} else if (lia.random() % (++n) == 0) {
|
||||||
result = j;
|
result = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,8 @@ namespace lp {
|
||||||
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_base_column();
|
int find_inf_int_base_column();
|
||||||
int get_kth_inf_int(unsigned k) const;
|
|
||||||
int find_inf_int_nbasis_column() const;
|
int find_inf_int_nbasis_column() const;
|
||||||
int find_any_inf_int_column_basis_first();
|
int find_any_inf_int_column_basis_first();
|
||||||
int find_inf_int_boxed_base_column_with_smallest_range(unsigned & inf_int_count);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int_branch(int_solver& lia);
|
int_branch(int_solver& lia);
|
||||||
|
|
Loading…
Reference in a new issue