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

enable bounding for various domains

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-12-06 19:36:12 -08:00
parent 437a545c3b
commit a617eac010
8 changed files with 39 additions and 19 deletions

View file

@ -190,15 +190,33 @@ namespace opt {
return m_objective_values;
}
expr_ref opt_solver::block_upper_bound(unsigned var, inf_eps const& val) {
expr_ref opt_solver::mk_ge(unsigned var, inf_eps const& val) {
smt::theory_opt& opt = get_optimizer();
SASSERT(typeid(smt::theory_inf_arith) == typeid(opt));
smt::theory_inf_arith& th = dynamic_cast<smt::theory_inf_arith&>(opt);
smt::theory_var v = m_objective_vars[var];
return expr_ref(th.block_upper_bound(v, val), m);
if (typeid(smt::theory_inf_arith) == typeid(opt)) {
smt::theory_inf_arith& th = dynamic_cast<smt::theory_inf_arith&>(opt);
return expr_ref(th.mk_ge(v, val), m);
}
if (typeid(smt::theory_mi_arith) == typeid(opt)) {
smt::theory_mi_arith& th = dynamic_cast<smt::theory_mi_arith&>(opt);
SASSERT(val.get_infinity().is_zero());
return expr_ref(th.mk_ge(v, val.get_numeral()), m);
}
if (typeid(smt::theory_i_arith) == typeid(opt)) {
SASSERT(val.get_infinity().is_zero());
SASSERT(val.get_infinitesimal().is_zero());
smt::theory_i_arith& th = dynamic_cast<smt::theory_i_arith&>(opt);
return expr_ref(th.mk_ge(v, val.get_rational()), m);
}
// difference logic?
return expr_ref(m.mk_true(), m);
}
expr_ref opt_solver::block_lower_bound(unsigned var, inf_eps const& val) {
expr_ref opt_solver::mk_gt(unsigned var, inf_eps const& val) {
if (val.get_infinity().is_pos()) {
return expr_ref(m.mk_false(), m);
}
@ -207,7 +225,7 @@ namespace opt {
}
else {
inf_rational n = val.get_numeral();
return expr_ref(get_optimizer().block_lower_bound(m_objective_vars[var], n), m);
return expr_ref(get_optimizer().mk_gt(m_objective_vars[var], n), m);
}
}

View file

@ -75,8 +75,8 @@ namespace opt {
void reset_objectives();
vector<inf_eps> const& get_objective_values();
expr_ref block_lower_bound(unsigned obj_index, inf_eps const& val);
expr_ref block_upper_bound(unsigned obj_index, inf_eps const& val);
expr_ref mk_gt(unsigned obj_index, inf_eps const& val);
expr_ref mk_ge(unsigned obj_index, inf_eps const& val);
static opt_solver& to_opt(solver& s);
void set_interim_stats(statistics & st);

View file

@ -121,7 +121,7 @@ namespace opt {
for (unsigned i = 0; i < m_lower.size(); ++i) {
inf_eps const& v = m_lower[i];
disj.push_back(s->block_lower_bound(i, v));
disj.push_back(s->mk_gt(i, v));
}
constraint = m.mk_or(disj.size(), disj.c_ptr());
s->assert_expr(constraint);
@ -149,7 +149,7 @@ namespace opt {
smt::theory_var v = m_vars[i];
mid.push_back((m_upper[i]+m_lower[i])/rational(2));
//mid.push_back(m_upper[i]);
bound = th.block_upper_bound(v, mid[i]);
bound = th.mk_ge(v, mid[i]);
bounds.push_back(bound);
}
else {
@ -273,7 +273,7 @@ namespace opt {
m_upper[i] = mid;
TRACE("opt", tout << "set lower bound of "; display_objective(tout, i) << " to: " << mid << "\n";
tout << get_lower(i) << ":" << get_upper(i) << "\n";);
s->assert_expr(s->block_upper_bound(i, mid));
s->assert_expr(s->mk_ge(i, mid));
}
std::ostream& optsmt::display_objective(std::ostream& out, unsigned i) const {