mirror of
https://github.com/Z3Prover/z3
synced 2025-06-27 00:18:45 +00:00
formatting hygiene
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
a7966dc436
commit
a6ab0a7d49
2 changed files with 506 additions and 545 deletions
|
@ -61,7 +61,6 @@ namespace lp {
|
||||||
// + a1*(delta/t) is integral. Taking into account that t and a1 are
|
// + a1*(delta/t) is integral. Taking into account that t and a1 are
|
||||||
// coprime we have delta = t*k, where k is an integer.
|
// coprime we have delta = t*k, where k is an integer.
|
||||||
rational t = a2 / x2;
|
rational t = a2 / x2;
|
||||||
// std::cout << "t = " << t << std::endl;
|
|
||||||
// Now we have x1/x2 + (a1/x2)*k is integral, or (x1 + a1*k)/x2 is integral.
|
// Now we have x1/x2 + (a1/x2)*k is integral, or (x1 + a1*k)/x2 is integral.
|
||||||
// It is equivalent to x1 + a1*k = x2*m, where m is an integer
|
// It is equivalent to x1 + a1*k = x2*m, where m is an integer
|
||||||
// We know that a2 and a1 are coprime, and x2 divides a2, so x2 and a1 are
|
// We know that a2 and a1 are coprime, and x2 divides a2, so x2 and a1 are
|
||||||
|
@ -69,10 +68,6 @@ namespace lp {
|
||||||
rational u, v;
|
rational u, v;
|
||||||
gcd(a1, x2, u, v);
|
gcd(a1, x2, u, v);
|
||||||
lp_assert(gcd(a1, x2, u, v).is_one());
|
lp_assert(gcd(a1, x2, u, v).is_one());
|
||||||
// std::cout << "u = " << u << ", v = " << v << std::endl;
|
|
||||||
// std::cout << "x= " << (x1 / x2) << std::endl;
|
|
||||||
// std::cout << "x + (a1 / a2) * (-u * t) * x1 = "
|
|
||||||
// << x + (a1 / a2) * (-u * t) * x1 << std::endl;
|
|
||||||
lp_assert((x + (a1 / a2) * (-u * t) * x1).is_int());
|
lp_assert((x + (a1 / a2) * (-u * t) * x1).is_int());
|
||||||
// 1 = (u- l*x2 ) * a1 + (v + l*a1)*x2, for every integer l.
|
// 1 = (u- l*x2 ) * a1 + (v + l*a1)*x2, for every integer l.
|
||||||
rational d = u * t * x1;
|
rational d = u * t * x1;
|
||||||
|
@ -103,14 +98,13 @@ namespace lp {
|
||||||
if (!get_patching_deltas(r, a, delta_plus, delta_minus))
|
if (!get_patching_deltas(r, a, delta_plus, delta_minus))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (lia.random() % 2) {
|
if (lia.random() % 2)
|
||||||
return try_patch_column(v, c.var(), delta_plus) ||
|
return try_patch_column(v, c.var(), delta_plus) ||
|
||||||
try_patch_column(v, c.var(), delta_minus);
|
try_patch_column(v, c.var(), delta_minus);
|
||||||
} else {
|
else
|
||||||
return try_patch_column(v, c.var(), delta_minus) ||
|
return try_patch_column(v, c.var(), delta_minus) ||
|
||||||
try_patch_column(v, c.var(), delta_plus);
|
try_patch_column(v, c.var(), delta_plus);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool int_solver::patcher::try_patch_column(unsigned v, unsigned j, mpq const& delta) {
|
bool int_solver::patcher::try_patch_column(unsigned v, unsigned j, mpq const& delta) {
|
||||||
const auto & A = lra.A_r();
|
const auto & A = lra.A_r();
|
||||||
|
@ -315,12 +309,10 @@ bool int_solver::should_hnf_cut() {
|
||||||
|
|
||||||
lia_move int_solver::hnf_cut() {
|
lia_move int_solver::hnf_cut() {
|
||||||
lia_move r = m_hnf_cutter.make_hnf_cut();
|
lia_move r = m_hnf_cutter.make_hnf_cut();
|
||||||
if (r == lia_move::undef) {
|
if (r == lia_move::undef)
|
||||||
m_hnf_cut_period *= 2;
|
m_hnf_cut_period *= 2;
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
m_hnf_cut_period = settings().hnf_cut_period();
|
m_hnf_cut_period = settings().hnf_cut_period();
|
||||||
}
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,10 +392,8 @@ bool int_solver::get_freedom_interval_for_column(unsigned j, bool & inf_l, impq
|
||||||
if (column_is_int(i) && !a.is_int() && xi.is_int())
|
if (column_is_int(i) && !a.is_int() && xi.is_int())
|
||||||
m = lcm(m, denominator(a));
|
m = lcm(m, denominator(a));
|
||||||
|
|
||||||
if (!inf_l && !inf_u) {
|
if (!inf_l && !inf_u && l == u)
|
||||||
if (l == u)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (a.is_neg()) {
|
if (a.is_neg()) {
|
||||||
if (has_lower(i))
|
if (has_lower(i))
|
||||||
|
@ -530,8 +520,7 @@ std::ostream & int_solver::display_row(std::ostream & out, lp::row_strip<rationa
|
||||||
first = false;
|
first = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c.coeff().is_one())
|
if (c.coeff().is_one()) {
|
||||||
{
|
|
||||||
if (!first)
|
if (!first)
|
||||||
out << "+";
|
out << "+";
|
||||||
}
|
}
|
||||||
|
@ -586,13 +575,11 @@ bool int_solver::shift_var(unsigned j, unsigned range) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (column_is_int(j)) {
|
if (column_is_int(j)) {
|
||||||
if (!inf_l) {
|
if (!inf_l)
|
||||||
l = impq(ceil(l));
|
l = impq(ceil(l));
|
||||||
}
|
if (!inf_u)
|
||||||
if (!inf_u) {
|
|
||||||
u = impq(floor(u));
|
u = impq(floor(u));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!inf_l && !inf_u && l >= u)
|
if (!inf_l && !inf_u && l >= u)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -633,31 +620,6 @@ bool int_solver::shift_var(unsigned j, unsigned range) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not used:
|
|
||||||
bool int_solver::non_basic_columns_are_at_bounds() const {
|
|
||||||
for (unsigned j : lrac.m_r_nbasis) {
|
|
||||||
auto & val = lrac.m_r_x[j];
|
|
||||||
switch (lrac.m_column_types()[j]) {
|
|
||||||
case column_type::boxed:
|
|
||||||
if (val != lrac.m_r_lower_bounds()[j] && val != lrac.m_r_upper_bounds()[j])
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
case column_type::lower_bound:
|
|
||||||
if (val != lrac.m_r_lower_bounds()[j])
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
case column_type::upper_bound:
|
|
||||||
if (val != lrac.m_r_upper_bounds()[j])
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (column_is_int(j) && !val.is_int()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int int_solver::select_int_infeasible_var() {
|
int int_solver::select_int_infeasible_var() {
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
|
@ -109,7 +109,6 @@ private:
|
||||||
bool has_lower(unsigned j) const;
|
bool has_lower(unsigned j) const;
|
||||||
bool has_upper(unsigned j) const;
|
bool has_upper(unsigned j) const;
|
||||||
unsigned row_of_basic_column(unsigned j) const;
|
unsigned row_of_basic_column(unsigned j) const;
|
||||||
bool non_basic_columns_are_at_bounds() const;
|
|
||||||
bool cut_indices_are_columns() const;
|
bool cut_indices_are_columns() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue