mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
add has_value utility to retrieve value from solver state
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
593a6e5139
commit
b6054b8406
3 changed files with 25 additions and 2 deletions
|
@ -1104,6 +1104,25 @@ bool lar_solver::has_upper_bound(var_index var, constraint_index& ci, mpq& value
|
|||
}
|
||||
}
|
||||
|
||||
bool lar_solver::has_value(var_index var, mpq& value) const {
|
||||
if (is_term(var)) {
|
||||
lar_term const& t = get_term(var);
|
||||
value = t.m_v;
|
||||
for (auto const& cv : t) {
|
||||
impq const& r = get_column_value(cv.var());
|
||||
if (!numeric_traits<mpq>::is_zero(r.y)) return false;
|
||||
value += r.x * cv.coeff();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
impq const& r = get_column_value(var);
|
||||
value = r.x;
|
||||
return numeric_traits<mpq>::is_zero(r.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lar_solver::get_infeasibility_explanation(vector<std::pair<mpq, constraint_index>> & explanation) const {
|
||||
explanation.clear();
|
||||
if (m_infeasible_column_index != -1) {
|
||||
|
|
|
@ -426,6 +426,7 @@ public:
|
|||
|
||||
bool has_upper_bound(var_index var, constraint_index& ci, mpq& value, bool& is_strict) const;
|
||||
|
||||
bool has_value(var_index var, mpq& value) const;
|
||||
|
||||
void get_infeasibility_explanation(vector<std::pair<mpq, constraint_index>> & explanation) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue