mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 03:45:51 +00:00
Replace the use of optional<rational> by inf_eps_rational<rational>
Also handle composite objectives correctly.
This commit is contained in:
parent
a44044fb15
commit
53f78f7d19
9 changed files with 50 additions and 43 deletions
|
@ -7,7 +7,6 @@ namespace opt {
|
|||
|
||||
opt_solver::opt_solver(ast_manager & m, params_ref const & p, symbol const & l):
|
||||
solver_na2as(m),
|
||||
m_manager(m),
|
||||
m_params(p),
|
||||
m_context(m, m_params),
|
||||
m_objective_enabled(false) {
|
||||
|
@ -15,7 +14,7 @@ namespace opt {
|
|||
if (m_logic != symbol::null)
|
||||
m_context.set_logic(m_logic);
|
||||
}
|
||||
|
||||
|
||||
opt_solver::~opt_solver() {
|
||||
}
|
||||
|
||||
|
@ -64,14 +63,14 @@ namespace opt {
|
|||
|
||||
|
||||
lbool opt_solver::check_sat_core(unsigned num_assumptions, expr * const * assumptions) {
|
||||
TRACE("opt_solver_na2as", tout << "smt_opt_solver::check_sat_core: " << num_assumptions << "\n";);
|
||||
TRACE("opt_solver_na2as", tout << "opt_opt_solver::check_sat_core: " << num_assumptions << "\n";);
|
||||
lbool r = m_context.check(num_assumptions, assumptions);
|
||||
if (r == l_true && m_objective_enabled) {
|
||||
bool is_bounded = get_optimizer().max(m_objective_var);
|
||||
bool is_bounded = get_optimizer().maximize(m_objective_var);
|
||||
if (is_bounded) {
|
||||
m_objective_value = get_optimizer().get_objective_value(m_objective_var);
|
||||
} else {
|
||||
optional<rational> r;
|
||||
inf_eps_rational<rational> r(rational(1), rational(0));
|
||||
m_objective_value = r;
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +131,7 @@ namespace opt {
|
|||
m_objective_enabled = enable;
|
||||
}
|
||||
|
||||
optional<rational> opt_solver::get_objective_value() {
|
||||
inf_eps_rational<rational> opt_solver::get_objective_value() {
|
||||
return m_objective_value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue