3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-07 15:55:46 +00:00

fix bug in handling of repeated soft constraints. #815

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-12-11 10:19:57 +01:00
parent 0765eea486
commit 2307a7ffa7
5 changed files with 40 additions and 4 deletions

View file

@ -333,8 +333,15 @@ namespace opt {
TRACE("opt", tout << mk_pp(f, m) << " weight: " << w << "\n";);
SASSERT(m.is_bool(f));
SASSERT(w.is_pos());
m_soft_constraints.push_back(f);
m_weights.push_back(w);
unsigned index = 0;
if (m_soft_constraint_index.find(f, index)) {
m_weights[index] += w;
}
else {
m_soft_constraint_index.insert(f, m_weights.size());
m_soft_constraints.push_back(f);
m_weights.push_back(w);
}
m_upper += w;
}