mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Merge branch 'unit_prop_on_monomials' of https://github.com/z3prover/z3 into unit_prop_on_monomials
This commit is contained in:
commit
f2a0ddb385
28 changed files with 161 additions and 89 deletions
|
@ -9,29 +9,18 @@
|
|||
#include "math/lp/lp_settings.h"
|
||||
#include "util/uint_set.h"
|
||||
#include "math/lp/implied_bound.h"
|
||||
#include <vector>
|
||||
#include "util/vector.h"
|
||||
namespace lp {
|
||||
template <typename T>
|
||||
struct my_allocator {
|
||||
using value_type = T;
|
||||
|
||||
T* allocate(std::size_t n) {
|
||||
return static_cast<T*>(memory::allocate(n * sizeof(T)));
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t n) {
|
||||
memory::deallocate(p);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class lp_bound_propagator {
|
||||
uint_set m_visited_rows;
|
||||
uint_set m_visited_rows;
|
||||
// these maps map a column index to the corresponding index in ibounds
|
||||
u_map<unsigned> m_improved_lower_bounds;
|
||||
u_map<unsigned> m_improved_upper_bounds;
|
||||
|
||||
T& m_imp;
|
||||
std::vector<implied_bound, my_allocator<implied_bound>> m_ibounds;
|
||||
std_vector<implied_bound> m_ibounds;
|
||||
|
||||
map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>> m_val2fixed_row;
|
||||
// works for rows of the form x + y + sum of fixed = 0
|
||||
|
@ -119,10 +108,10 @@ private:
|
|||
~reset_cheap_eq() { p.reset_cheap_eq_eh(); }
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
lp_bound_propagator(T& imp) : m_imp(imp) {}
|
||||
|
||||
const std::vector<implied_bound, my_allocator<implied_bound>>& ibounds() const { return m_ibounds; }
|
||||
const std_vector<implied_bound>& ibounds() const { return m_ibounds; }
|
||||
|
||||
void init() {
|
||||
m_improved_upper_bounds.reset();
|
||||
|
@ -192,13 +181,12 @@ private:
|
|||
|
||||
void propagate_monic(lpvar monic_var, const svector<lpvar>& vars) {
|
||||
lpvar non_fixed, zero_var;
|
||||
if (!is_linear(vars, zero_var, non_fixed)) {
|
||||
return;
|
||||
}
|
||||
if (!is_linear(vars, zero_var, non_fixed))
|
||||
return;
|
||||
|
||||
if (zero_var != null_lpvar) {
|
||||
if (zero_var != null_lpvar)
|
||||
add_bounds_for_zero_var(monic_var, zero_var);
|
||||
} else {
|
||||
else {
|
||||
rational k = rational(1);
|
||||
for (auto v : vars)
|
||||
if (v != non_fixed) {
|
||||
|
@ -206,19 +194,18 @@ private:
|
|||
if (k.is_big()) return;
|
||||
}
|
||||
|
||||
if (non_fixed != null_lpvar) {
|
||||
if (non_fixed != null_lpvar)
|
||||
propagate_monic_with_non_fixed(monic_var, vars, non_fixed, k);
|
||||
} else { // all variables are fixed
|
||||
else // all variables are fixed
|
||||
propagate_monic_with_all_fixed(monic_var, vars, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void propagate_monic_with_non_fixed(lpvar monic_var, const svector<lpvar>& vars, lpvar non_fixed, const rational& k) {
|
||||
lp::impq bound_value;
|
||||
bool is_strict;
|
||||
lp::impq bound_value;
|
||||
bool is_strict;
|
||||
|
||||
if (lower_bound_is_available(non_fixed)) {
|
||||
if (lower_bound_is_available(non_fixed)) {
|
||||
bound_value = lp().column_lower_bound(non_fixed);
|
||||
is_strict = !bound_value.y.is_zero();
|
||||
auto lambda = [vars, non_fixed](int* s) {
|
||||
|
|
|
@ -7,16 +7,14 @@
|
|||
--*/
|
||||
#pragma once
|
||||
namespace nla {
|
||||
class core;
|
||||
class monotone : common {
|
||||
public:
|
||||
monotone(core *core);
|
||||
void monotonicity_lemma();
|
||||
private:
|
||||
void monotonicity_lemma(monic const& m);
|
||||
void monotonicity_lemma_gt(const monic& m);
|
||||
void monotonicity_lemma_lt(const monic& m);
|
||||
std::vector<rational> get_sorted_key(const monic& rm) const;
|
||||
vector<std::pair<rational, lpvar>> get_sorted_key_with_rvars(const monic& a) const;
|
||||
};
|
||||
class core;
|
||||
class monotone : common {
|
||||
public:
|
||||
monotone(core *core);
|
||||
void monotonicity_lemma();
|
||||
private:
|
||||
void monotonicity_lemma(monic const& m);
|
||||
void monotonicity_lemma_gt(const monic& m);
|
||||
void monotonicity_lemma_lt(const monic& m);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue