mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +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
|
@ -992,9 +992,9 @@ namespace smt {
|
|||
// Optimization
|
||||
//
|
||||
// -----------------------------------
|
||||
virtual bool max(theory_var v) { return max_min(v, true); }
|
||||
virtual bool maximize(theory_var v) { return max_min(v, true); }
|
||||
virtual theory_var add_objective(app* term);
|
||||
virtual optional<rational> get_objective_value(theory_var v);
|
||||
virtual inf_eps_rational<rational> get_objective_value(theory_var v);
|
||||
inf_rational m_objective;
|
||||
|
||||
// -----------------------------------
|
||||
|
|
|
@ -19,6 +19,7 @@ Revision History:
|
|||
#ifndef _THEORY_ARITH_AUX_H_
|
||||
#define _THEORY_ARITH_AUX_H_
|
||||
|
||||
#include"inf_eps_rational.h"
|
||||
#include"theory_arith.h"
|
||||
|
||||
namespace smt {
|
||||
|
@ -960,12 +961,10 @@ namespace smt {
|
|||
}
|
||||
|
||||
template<typename Ext>
|
||||
optional<rational> theory_arith<Ext>::get_objective_value(theory_var v) {
|
||||
optional<rational> rat;
|
||||
if (m_objective.is_rational()) {
|
||||
rat = m_objective.get_rational();
|
||||
};
|
||||
return rat;
|
||||
inf_eps_rational<rational> theory_arith<Ext>::get_objective_value(theory_var v) {
|
||||
inf_eps_rational<rational> val;
|
||||
val = m_objective.get_rational();
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,15 +18,21 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
#include "inf_eps_rational.h"
|
||||
|
||||
#ifndef _THEORY_OPT_H_
|
||||
#define _THEORY_OPT_H_
|
||||
|
||||
namespace smt {
|
||||
class theory_opt {
|
||||
public:
|
||||
virtual bool max(theory_var v) { UNREACHABLE(); return false; };
|
||||
virtual bool maximize(theory_var v) { UNREACHABLE(); return false; };
|
||||
virtual theory_var add_objective(app* term) { UNREACHABLE(); return null_theory_var; }
|
||||
virtual optional<rational> get_objective_value(theory_var v) { UNREACHABLE(); optional<rational> r; return r;}
|
||||
virtual inf_eps_rational<rational> get_objective_value(theory_var v) {
|
||||
UNREACHABLE();
|
||||
inf_eps_rational<rational> r(rational(1), rational(0));
|
||||
return r;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue