mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 22:23:22 +00:00
working on wmaxsmt
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
6302d1b7db
commit
42cbbe830e
3 changed files with 9 additions and 12 deletions
|
@ -82,6 +82,13 @@ namespace opt {
|
||||||
~toggle_objective();
|
~toggle_objective();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class scoped_push {
|
||||||
|
opt_solver& s;
|
||||||
|
public:
|
||||||
|
scoped_push(opt_solver& s):s(s) { s.push(); }
|
||||||
|
~scoped_push() { s.pop(1); }
|
||||||
|
};
|
||||||
|
|
||||||
smt::context& get_context() { return m_context.get_context(); } // used by weighted maxsat.
|
smt::context& get_context() { return m_context.get_context(); } // used by weighted maxsat.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -46,17 +46,6 @@ Notes:
|
||||||
|
|
||||||
namespace opt {
|
namespace opt {
|
||||||
|
|
||||||
class scoped_push {
|
|
||||||
opt_solver& s;
|
|
||||||
public:
|
|
||||||
scoped_push(opt_solver& s):s(s) {
|
|
||||||
s.push();
|
|
||||||
}
|
|
||||||
~scoped_push() {
|
|
||||||
s.pop(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void optimize_objectives::set_cancel(bool f) {
|
void optimize_objectives::set_cancel(bool f) {
|
||||||
m_cancel = true;
|
m_cancel = true;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +75,7 @@ namespace opt {
|
||||||
return is_sat;
|
return is_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_push _push(s);
|
opt_solver::scoped_push _push(s);
|
||||||
|
|
||||||
opt_solver::toggle_objective _t(s, true);
|
opt_solver::toggle_objective _t(s, true);
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,7 @@ namespace opt {
|
||||||
ctx.register_plugin(wth);
|
ctx.register_plugin(wth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opt_solver::scoped_push _s(s);
|
||||||
for (unsigned i = 0; i < soft_constraints.size(); ++i) {
|
for (unsigned i = 0; i < soft_constraints.size(); ++i) {
|
||||||
wth->assert_weighted(soft_constraints[i].get(), weights[i]);
|
wth->assert_weighted(soft_constraints[i].get(), weights[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue