mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 19:35:50 +00:00
working on weighted maxsat
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
906bbb4eeb
commit
d30f183476
5 changed files with 109 additions and 36 deletions
|
@ -59,14 +59,15 @@ namespace opt {
|
|||
is_sat = opt::fu_malik_maxsat(*s, fmls_copy);
|
||||
}
|
||||
else {
|
||||
is_sat = weighted_maxsat(*s, fmls_copy, m_weights);
|
||||
is_sat = weighted_maxsat(get_opt_solver(*s), fmls_copy, m_weights);
|
||||
}
|
||||
std::cout << "is-sat: " << is_sat << "\n";
|
||||
if (is_sat != l_true) {
|
||||
return;
|
||||
}
|
||||
std::cout << "Satisfying soft constraints\n";
|
||||
for (unsigned i = 0; i < fmls_copy.size(); ++i) {
|
||||
std::cout << "Satisfying soft constraint: " << mk_pp(fmls_copy[i].get(), m) << "\n";
|
||||
std::cout << mk_pp(fmls_copy[i].get(), m) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,9 +76,7 @@ namespace opt {
|
|||
for (unsigned i = 0; i < fmls_copy.size(); ++i) {
|
||||
s->assert_expr(fmls_copy[i].get());
|
||||
}
|
||||
// SASSERT(instanceof(*s, opt_solver));
|
||||
// if (!instsanceof ...) { throw ... invalid usage ..}
|
||||
is_sat = optimize_objectives(dynamic_cast<opt_solver&>(*s), m_objectives, values);
|
||||
is_sat = optimize_objectives(get_opt_solver(*s), m_objectives, values);
|
||||
std::cout << "is-sat: " << is_sat << std::endl;
|
||||
|
||||
if (is_sat != l_true) {
|
||||
|
@ -108,6 +107,13 @@ namespace opt {
|
|||
return true;
|
||||
}
|
||||
|
||||
opt_solver& context::get_opt_solver(solver& s) {
|
||||
if (typeid(opt_solver) != typeid(s)) {
|
||||
throw default_exception("BUG: optimization context has not been initialized correctly");
|
||||
}
|
||||
return dynamic_cast<opt_solver&>(s);
|
||||
}
|
||||
|
||||
void context::cancel() {
|
||||
if (m_solver) {
|
||||
m_solver->cancel();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue