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

add clausification features

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-01-12 08:23:22 -08:00
parent 69879322d8
commit 9635a74e52
7 changed files with 117 additions and 21 deletions

View file

@ -353,12 +353,26 @@ namespace opt {
m_upper += w;
}
struct cmp_first {
bool operator()(std::pair<unsigned, rational> const& x, std::pair<unsigned, rational> const& y) const {
return x.first < y.first;
}
};
void maxsmt::display_answer(std::ostream& out) const {
for (unsigned i = 0; i < m_soft_constraints.size(); ++i) {
expr* e = m_soft_constraints[i];
vector<std::pair<unsigned, rational>> sorted_weights;
unsigned n = m_weights.size();
for (unsigned i = 0; i < n; ++i) {
sorted_weights.push_back(std::make_pair(i, m_weights[i]));
}
std::sort(sorted_weights.begin(), sorted_weights.end(), cmp_first());
sorted_weights.reverse();
for (unsigned i = 0; i < n; ++i) {
unsigned idx = sorted_weights[i].first;
expr* e = m_soft_constraints[idx];
bool is_not = m.is_not(e, e);
out << m_weights[i] << ": " << mk_pp(e, m)
<< ((is_not != get_assignment(i))?" |-> true ":" |-> false ")
out << m_weights[idx] << ": " << mk_pp(e, m)
<< ((is_not != get_assignment(idx))?" |-> true ":" |-> false ")
<< "\n";
}