3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

Sketch a skeleton of Difference Logic optimizer

This commit is contained in:
Anh-Dung Phan 2013-10-22 16:28:03 -07:00
parent 36d7948399
commit 6919f335a1
4 changed files with 89 additions and 6 deletions

View file

@ -78,7 +78,7 @@ namespace opt {
// SASSERT(instanceof(*s, opt_solver));
// if (!instsanceof ...) { throw ... invalid usage ..}
is_sat = optimize_objectives(dynamic_cast<opt_solver&>(*s), m_objectives, values);
std::cout << "is-sat: " << is_sat << "\n";
std::cout << "is-sat: " << is_sat << std::endl;
if (is_sat != l_true) {
return;
@ -88,15 +88,14 @@ namespace opt {
if (!m_is_max[i]) {
values[i].neg();
}
std::cout << "objective function: " << mk_pp(m_objectives[i].get(), m) << " -> " << values[i].to_string() << "\n";
std::cout << "objective value: " << mk_pp(m_objectives[i].get(), m) << " -> " << values[i].to_string() << std::endl;
}
}
if (m_objectives.empty() && m_soft_constraints.empty()) {
is_sat = s->check_sat(0,0);
std::cout << "nothing to optimize: is-sat " << is_sat << "\n";
std::cout << "nothing to optimize: is-sat " << is_sat << std::endl;
}
}
bool context::is_maxsat_problem() const {

View file

@ -2,6 +2,7 @@
#include"opt_solver.h"
#include"smt_context.h"
#include"theory_arith.h"
#include"theory_diff_logic.h"
namespace opt {
@ -55,6 +56,12 @@ namespace opt {
else if (typeid(smt::theory_i_arith) == typeid(*arith_theory)) {
return dynamic_cast<smt::theory_i_arith&>(*arith_theory);
}
else if (typeid(smt::theory_rdl&) == typeid(*arith_theory)) {
return dynamic_cast<smt::theory_rdl&>(*arith_theory);
}
else if (typeid(smt::theory_idl&) == typeid(*arith_theory)) {
return dynamic_cast<smt::theory_idl&>(*arith_theory);
}
else {
UNREACHABLE();
return dynamic_cast<smt::theory_mi_arith&>(*arith_theory);