mirror of
https://github.com/Z3Prover/z3
synced 2025-04-08 10:25:18 +00:00
adding soft-assertions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
e50e02e656
commit
552cbd840f
|
@ -105,6 +105,10 @@ namespace opt {
|
|||
m_c.set_enable_sls(f);
|
||||
}
|
||||
|
||||
void maxsmt_solver_base::set_soft_assumptions() {
|
||||
m_c.set_soft_assumptions()
|
||||
}
|
||||
|
||||
app* maxsmt_solver_base::mk_fresh_bool(char const* name) {
|
||||
app* result = m.mk_fresh_const(name, m.mk_bool_sort());
|
||||
m_c.fm().insert(result->get_decl());
|
||||
|
|
|
@ -102,6 +102,7 @@ namespace opt {
|
|||
protected:
|
||||
void enable_sls(expr_ref_vector const& soft, weights_t& ws);
|
||||
void set_enable_sls(bool f);
|
||||
void set_soft_assumptions();
|
||||
void trace_bounds(char const* solver);
|
||||
|
||||
};
|
||||
|
|
|
@ -493,6 +493,13 @@ namespace opt {
|
|||
}
|
||||
}
|
||||
|
||||
void context::set_soft_assumptions() {
|
||||
if (m_sat_solver.get()) {
|
||||
m_params.set_bool("soft_assumptions", true);
|
||||
m_sat_solver->updt_params(m_params);
|
||||
}
|
||||
}
|
||||
|
||||
void context::enable_sls(expr_ref_vector const& soft, vector<rational> const& weights) {
|
||||
SASSERT(soft.size() == weights.size());
|
||||
if (m_sat_solver.get()) {
|
||||
|
|
|
@ -184,6 +184,7 @@ namespace opt {
|
|||
params_ref& params() { return m_params; }
|
||||
void enable_sls(expr_ref_vector const& soft, weights_t& weights);
|
||||
void set_enable_sls(bool f) { m_enable_sls = f; }
|
||||
void set_soft_assumptions();
|
||||
symbol const& maxsat_engine() const { return m_maxsat_engine; }
|
||||
void get_base_model(model_ref& m);
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ namespace sat {
|
|||
m_minimize_core = p.minimize_core();
|
||||
m_minimize_core_partial = p.minimize_core_partial();
|
||||
m_optimize_model = p.optimize_model();
|
||||
m_soft_assumptions = p.soft_assumptions();
|
||||
m_bcd = p.bcd();
|
||||
m_dyn_sub_res = p.dyn_sub_res();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace sat {
|
|||
bool m_minimize_core;
|
||||
bool m_minimize_core_partial;
|
||||
bool m_optimize_model;
|
||||
bool m_soft_assumptions;
|
||||
bool m_bcd;
|
||||
|
||||
|
||||
|
|
|
@ -22,5 +22,6 @@ def_module_params('sat',
|
|||
('minimize_core', BOOL, False, 'minimize computed core'),
|
||||
('minimize_core_partial', BOOL, False, 'apply partial (cheap) core minimization'),
|
||||
('optimize_model', BOOL, False, 'enable optimization of soft constraints'),
|
||||
('soft_assumptions', BOOL, False, 'disable assumptions that are forced during unit propagation'),
|
||||
('bcd', BOOL, False, 'enable blocked clause decomposition for equality extraction'),
|
||||
('dimacs.core', BOOL, False, 'extract core from DIMACS benchmarks')))
|
||||
|
|
|
@ -914,17 +914,26 @@ namespace sat {
|
|||
|
||||
for (unsigned i = 0; !inconsistent() && i < m_user_scope_literals.size(); ++i) {
|
||||
literal nlit = ~m_user_scope_literals[i];
|
||||
assign(nlit, justification());
|
||||
// propagate(false);
|
||||
assign(nlit, justification());
|
||||
}
|
||||
|
||||
for (unsigned i = 0; !inconsistent() && i < num_lits; ++i) {
|
||||
literal lit = lits[i];
|
||||
SASSERT(is_external((lit).var()));
|
||||
m_assumption_set.insert(lit);
|
||||
m_assumptions.push_back(lit);
|
||||
assign(lit, justification());
|
||||
// propagate(false);
|
||||
|
||||
if (m_config.soft_assumptions) {
|
||||
if (value(lit) == l_undef) {
|
||||
m_assumptions.push_back(lit);
|
||||
assign(lit, justification());
|
||||
}
|
||||
propagate(false);
|
||||
}
|
||||
else {
|
||||
m_assumptions.push_back(lit);
|
||||
assign(lit, justification());
|
||||
// propagate(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue