mirror of
https://github.com/Z3Prover/z3
synced 2025-08-03 09:50:23 +00:00
separate pre-processing, add callback parameter to push/pop in python API
This commit is contained in:
parent
f43d9d00d4
commit
c996a66da0
16 changed files with 287 additions and 200 deletions
|
@ -52,21 +52,23 @@ namespace opt {
|
|||
// ---------------------------------------------
|
||||
// base class with common utilities used
|
||||
// by maxsmt solvers
|
||||
//
|
||||
//
|
||||
|
||||
struct soft {
|
||||
expr_ref s;
|
||||
rational weight;
|
||||
lbool value;
|
||||
void set_value(bool t) { value = t?l_true:l_undef; }
|
||||
void set_value(lbool t) { value = t; }
|
||||
bool is_true() const { return value == l_true; }
|
||||
soft(expr_ref const& s, rational const& w, bool t): s(s), weight(w), value(t?l_true:l_undef) {}
|
||||
};
|
||||
|
||||
class maxsmt_solver_base : public maxsmt_solver {
|
||||
protected:
|
||||
struct soft {
|
||||
expr_ref s;
|
||||
rational weight;
|
||||
lbool value;
|
||||
void set_value(bool t) { value = t?l_true:l_undef; }
|
||||
void set_value(lbool t) { value = t; }
|
||||
bool is_true() const { return value == l_true; }
|
||||
soft(expr_ref const& s, rational const& w, bool t): s(s), weight(w), value(t?l_true:l_undef) {}
|
||||
};
|
||||
ast_manager& m;
|
||||
maxsat_context& m_c;
|
||||
vector<soft> m_soft;
|
||||
vector<soft>& m_soft;
|
||||
expr_ref_vector m_assertions;
|
||||
expr_ref_vector m_trail;
|
||||
rational m_lower;
|
||||
|
@ -76,8 +78,8 @@ namespace opt {
|
|||
params_ref m_params; // config
|
||||
|
||||
public:
|
||||
maxsmt_solver_base(maxsat_context& c, weights_t& ws, expr_ref_vector const& soft);
|
||||
|
||||
maxsmt_solver_base(maxsat_context& c, vector<soft>& soft);
|
||||
|
||||
~maxsmt_solver_base() override {}
|
||||
rational get_lower() const override { return m_lower; }
|
||||
rational get_upper() const override { return m_upper; }
|
||||
|
@ -102,8 +104,6 @@ namespace opt {
|
|||
smt::theory_wmaxsat& operator()();
|
||||
};
|
||||
|
||||
lbool find_mutexes(obj_map<expr, rational>& new_soft);
|
||||
|
||||
void reset_upper();
|
||||
|
||||
|
||||
|
@ -111,9 +111,6 @@ namespace opt {
|
|||
void enable_sls(bool force);
|
||||
void trace_bounds(char const* solver);
|
||||
|
||||
void process_mutex(expr_ref_vector& mutex, obj_map<expr, rational>& new_soft);
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -126,10 +123,9 @@ namespace opt {
|
|||
maxsat_context& m_c;
|
||||
unsigned m_index;
|
||||
scoped_ptr<maxsmt_solver_base> m_msolver;
|
||||
expr_ref_vector m_soft_constraints;
|
||||
vector<soft> m_soft;
|
||||
obj_map<expr, unsigned> m_soft_constraint_index;
|
||||
expr_ref_vector m_answer;
|
||||
vector<rational> m_weights;
|
||||
rational m_lower;
|
||||
rational m_upper;
|
||||
adjust_value m_adjust_value;
|
||||
|
@ -142,9 +138,9 @@ namespace opt {
|
|||
void updt_params(params_ref& p);
|
||||
void add(expr* f, rational const& w);
|
||||
void set_adjust_value(adjust_value& adj);
|
||||
unsigned size() const { return m_soft_constraints.size(); }
|
||||
expr* operator[](unsigned idx) const { return m_soft_constraints[idx]; }
|
||||
rational weight(unsigned idx) const { return m_weights[idx]; }
|
||||
unsigned size() const { return m_soft.size(); }
|
||||
expr* operator[](unsigned idx) const { return m_soft[idx].s; }
|
||||
rational weight(unsigned idx) const { return m_soft[idx].weight; }
|
||||
void commit_assignment();
|
||||
rational get_lower() const;
|
||||
rational get_upper() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue