mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 11:25:51 +00:00
mv util/lp to math/lp
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
b6513b8e2d
commit
33cbd29ed0
150 changed files with 524 additions and 479 deletions
40
src/math/lp/mon_eq.cpp
Normal file
40
src/math/lp/mon_eq.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright (c) 2017 Microsoft Corporation
|
||||
Author: Nikolaj Bjorner
|
||||
*/
|
||||
#include "math/lp/lar_solver.h"
|
||||
#include "math/lp/monomial.h"
|
||||
namespace nla {
|
||||
|
||||
template <typename T>
|
||||
bool check_assignment(T const& m, variable_map_type & vars) {
|
||||
rational r1 = vars[m.var()];
|
||||
if (r1.is_zero()) {
|
||||
for (auto w : m.vars()) {
|
||||
if (vars[w].is_zero())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
rational r2(1);
|
||||
for (auto w : m.vars()) {
|
||||
r2 *= vars[w];
|
||||
}
|
||||
return r1 == r2;
|
||||
}
|
||||
template <typename K>
|
||||
bool check_assignments(const K & monomials,
|
||||
const lp::lar_solver& s,
|
||||
variable_map_type & vars) {
|
||||
s.get_model(vars);
|
||||
for (auto const& m : monomials) {
|
||||
if (!check_assignment(m, vars)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template bool check_assignments<vector<mon_eq>>(const vector<mon_eq>&,
|
||||
const lp::lar_solver& s,
|
||||
variable_map_type & vars);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue