diff --git a/src/opt/opt_solver.cpp b/src/opt/opt_solver.cpp index 091adb9b0..d6877e5db 100644 --- a/src/opt/opt_solver.cpp +++ b/src/opt/opt_solver.cpp @@ -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(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(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(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(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); } } diff --git a/src/opt/opt_solver.h b/src/opt/opt_solver.h index 3be11f4bc..f35a79203 100644 --- a/src/opt/opt_solver.h +++ b/src/opt/opt_solver.h @@ -75,8 +75,8 @@ namespace opt { void reset_objectives(); vector 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); diff --git a/src/opt/optsmt.cpp b/src/opt/optsmt.cpp index 1380080ba..ebad310d3 100644 --- a/src/opt/optsmt.cpp +++ b/src/opt/optsmt.cpp @@ -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 { diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index 7979ffc6e..f0211ca9d 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -999,8 +999,8 @@ namespace smt { // ----------------------------------- virtual inf_eps_rational maximize(theory_var v); virtual theory_var add_objective(app* term); - virtual expr* block_lower_bound(theory_var v, inf_rational const& val); - expr* block_upper_bound(theory_var v, inf_numeral const& val); + virtual expr* mk_gt(theory_var v, inf_rational const& val); + virtual expr* mk_ge(theory_var v, inf_numeral const& val); void enable_record_conflict(expr* bound); void record_conflict(unsigned num_lits, literal const * lits, unsigned num_eqs, enode_pair const * eqs, diff --git a/src/smt/theory_arith_aux.h b/src/smt/theory_arith_aux.h index 90a6db250..96245165f 100644 --- a/src/smt/theory_arith_aux.h +++ b/src/smt/theory_arith_aux.h @@ -1044,7 +1044,7 @@ namespace smt { \brief: assert val < v */ template - expr* theory_arith::block_lower_bound(theory_var v, inf_rational const& val) { + expr* theory_arith::mk_gt(theory_var v, inf_rational const& val) { ast_manager& m = get_manager(); expr* obj = get_enode(v)->get_owner(); expr_ref e(m); @@ -1062,7 +1062,7 @@ namespace smt { \brief assert val <= v */ template - expr* theory_arith::block_upper_bound(theory_var v, inf_numeral const& val) { + expr* theory_arith::mk_ge(theory_var v, inf_numeral const& val) { ast_manager& m = get_manager(); context& ctx = get_context(); std::ostringstream strm; diff --git a/src/smt/theory_diff_logic.h b/src/smt/theory_diff_logic.h index 015144c2a..ed52b76fc 100644 --- a/src/smt/theory_diff_logic.h +++ b/src/smt/theory_diff_logic.h @@ -310,7 +310,8 @@ namespace smt { virtual inf_eps_rational maximize(theory_var v); virtual theory_var add_objective(app* term); - virtual expr* block_lower_bound(theory_var v, inf_rational const& val); + virtual expr* mk_gt(theory_var v, inf_rational const& val); + virtual expr* mk_ge(theory_var v, inf_rational const& val) { return 0; } bool internalize_objective(expr * n, rational const& m, rational& r, objective_term & objective); diff --git a/src/smt/theory_diff_logic_def.h b/src/smt/theory_diff_logic_def.h index 4202b86a3..1982f2eb7 100644 --- a/src/smt/theory_diff_logic_def.h +++ b/src/smt/theory_diff_logic_def.h @@ -1146,7 +1146,7 @@ expr* theory_diff_logic::block_objective(theory_var v, inf_rational const& } template -expr* theory_diff_logic::block_lower_bound(theory_var v, inf_rational const& val) { +expr* theory_diff_logic::mk_gt(theory_var v, inf_rational const& val) { expr * o = block_objective(v, val); context & ctx = get_context(); model_ref mdl; diff --git a/src/smt/theory_opt.h b/src/smt/theory_opt.h index 774e4abd1..208330bfb 100644 --- a/src/smt/theory_opt.h +++ b/src/smt/theory_opt.h @@ -28,9 +28,10 @@ namespace smt { class theory_opt { public: typedef inf_eps_rational inf_eps; - virtual inf_eps_rational maximize(theory_var v) { UNREACHABLE(); return inf_eps::infinity(); } + virtual inf_eps maximize(theory_var v) { UNREACHABLE(); return inf_eps::infinity(); } virtual theory_var add_objective(app* term) { UNREACHABLE(); return null_theory_var; } - virtual expr* block_lower_bound(theory_var v, inf_rational const& val) { return 0; } + virtual expr* mk_gt(theory_var v, inf_rational const& val) { UNREACHABLE(); return 0; } + virtual expr* mk_ge(theory_var v, inf_eps const& val) { UNREACHABLE(); return 0; } }; }