mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 19:35:50 +00:00
lcm normalization
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
5ca3bc3212
commit
cbaa16df57
2 changed files with 18 additions and 2 deletions
|
@ -485,6 +485,21 @@ namespace opt {
|
|||
}
|
||||
}
|
||||
|
||||
model_based_opt::row& model_based_opt::row::normalize() {
|
||||
if (m_type == t_mod)
|
||||
return *this;
|
||||
rational D(abs(m_coeff));
|
||||
for (auto const& [id, coeff] : m_vars)
|
||||
D = lcm(D, coeff);
|
||||
if (D == 1)
|
||||
return *this;
|
||||
SASSERT(D > 0);
|
||||
for (auto & [id, coeff] : m_vars)
|
||||
coeff *= D;
|
||||
m_coeff *= D;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// Let
|
||||
// row1: t1 + a1*x <= 0
|
||||
|
@ -923,9 +938,9 @@ namespace opt {
|
|||
}
|
||||
|
||||
void model_based_opt::get_live_rows(vector<row>& rows) {
|
||||
for (row const& r : m_rows) {
|
||||
for (row & r : m_rows) {
|
||||
if (r.m_alive) {
|
||||
rows.push_back(r);
|
||||
rows.push_back(r.normalize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue