3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 19:35:50 +00:00

linear solver

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-05-14 17:10:01 -07:00
parent 17fcf79c04
commit 683ce27c8f
8 changed files with 264 additions and 42 deletions

View file

@ -83,6 +83,14 @@ namespace polysat {
return l_true;
}
template<typename Ext>
void fixplex<Ext>::add_row(var_t base_var, unsigned num_vars, var_t const* vars, rational const* coeffs) {
vector<numeral> _coeffs;
for (unsigned i = 0; i < num_vars; ++i)
_coeffs.push_back(m.from_rational(coeffs[i]));
add_row(base_var, num_vars, vars, _coeffs.data());
}
template<typename Ext>
void fixplex<Ext>::add_row(var_t base_var, unsigned num_vars, var_t const* vars, numeral const* coeffs) {
for (unsigned i = 0; i < num_vars; ++i)
@ -442,6 +450,21 @@ namespace polysat {
update_value(v, value2delta(v, value(v)));
}
template<typename Ext>
void fixplex<Ext>::set_bounds(var_t v, rational const& _lo, rational const& _hi) {
numeral lo = m.from_rational(_lo);
numeral hi = m.from_rational(_hi);
m_stashed_bounds.push_back(stashed_bound(v, lo, hi));
set_bounds(v, lo, hi);
}
template<typename Ext>
void fixplex<Ext>::restore_bound() {
auto const& b = m_stashed_bounds.back();
set_bounds(b.m_var, b.lo, b.hi);
m_stashed_bounds.pop_back();
}
/**
* Check if the coefficient b of y has the minimal number of trailing zeros.
* In other words, the coefficient b is a multiple of the smallest power of 2.