diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index b9b3d8166..e57050e82 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -149,7 +149,7 @@ extern "C" { to_param_ref(p).validate(r); to_solver_ref(s)->updt_params(to_param_ref(p)); } - to_solver(s)->m_params = to_param_ref(p); + to_solver(s)->m_params.append(to_param_ref(p)); Z3_CATCH; } diff --git a/src/opt/inc_sat_solver.cpp b/src/opt/inc_sat_solver.cpp index 1c450bbef..1a3fc7ff5 100644 --- a/src/opt/inc_sat_solver.cpp +++ b/src/opt/inc_sat_solver.cpp @@ -81,8 +81,8 @@ public: simp2_p.set_bool("hoist_mul", false); // required by som m_preprocess = and_then(mk_card2bv_tactic(m, m_params), - mk_simplify_tactic(m), - mk_propagate_values_tactic(m), + //mk_simplify_tactic(m), + //mk_propagate_values_tactic(m), using_params(mk_simplify_tactic(m), simp2_p), mk_max_bv_sharing_tactic(m), mk_bit_blaster_tactic(m), diff --git a/src/opt/maxres.cpp b/src/opt/maxres.cpp index d0694222a..209601c78 100644 --- a/src/opt/maxres.cpp +++ b/src/opt/maxres.cpp @@ -88,6 +88,7 @@ private: rational m_max_upper; bool m_found_feasible_optimum; bool m_hill_climb; // prefer large weight soft clauses for cores + unsigned m_last_index; // last index used during hill-climbing bool m_add_upper_bound_block; // restrict upper bound with constraint unsigned m_max_num_cores; // max number of cores per round. unsigned m_max_core_size; // max core size per round. @@ -110,6 +111,7 @@ public: m_st(st), m_found_feasible_optimum(false), m_hill_climb(true), + m_last_index(0), m_add_upper_bound_block(false), m_max_num_cores(UINT_MAX), m_max_core_size(3), @@ -352,16 +354,21 @@ public: /** Give preference to cores that have large minmal values. */ - sort_assumptions(asms); - unsigned index = 0; - unsigned last_index = 0; + sort_assumptions(asms); + + m_last_index = std::min(m_last_index, asms.size()-1); + m_last_index = 0; + unsigned index = m_last_index>0?m_last_index-1:0; + m_last_index = 0; + bool first = index > 0; + SASSERT(index < asms.size() || asms.empty()); while (index < asms.size() && is_sat == l_true) { - while (asms.size() > 20*(index - last_index) && index < asms.size()) { + while (!first && asms.size() > 20*(index - m_last_index) && index < asms.size()) { index = next_index(asms, index); - //break; } - IF_VERBOSE(3, verbose_stream() << "weight: " << get_weight(asms[0].get()) << " " << get_weight(asms[index-1].get()) << "\n";); - last_index = index; + first = false; + IF_VERBOSE(3, verbose_stream() << "weight: " << get_weight(asms[0].get()) << " " << get_weight(asms[index-1].get()) << " num soft: " << index << "\n";); + m_last_index = index; is_sat = s().check_sat(index, asms.c_ptr()); } } @@ -880,6 +887,7 @@ public: } m_max_upper = m_upper; m_found_feasible_optimum = false; + m_last_index = 0; add_upper_bound_block(); } diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index e61289f02..d41277df9 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -123,6 +123,7 @@ namespace opt { m_objective_refs(m), m_enable_sat(false), m_enable_sls(false), + m_is_clausal(false), m_pp_neat(false) { params_ref p; @@ -553,6 +554,10 @@ namespace opt { } void context::simplify_fmls(expr_ref_vector& fmls) { + if (m_is_clausal) { + return; + } + goal_ref g(alloc(goal, m, true, false)); for (unsigned i = 0; i < fmls.size(); ++i) { g->assert_expr(fmls[i].get()); diff --git a/src/opt/opt_context.h b/src/opt/opt_context.h index 0a342e058..5618efe7b 100644 --- a/src/opt/opt_context.h +++ b/src/opt/opt_context.h @@ -126,6 +126,7 @@ namespace opt { tactic_ref m_simplify; bool m_enable_sat; bool m_enable_sls; + bool m_is_clausal; bool m_pp_neat; symbol m_maxsat_engine; symbol m_logic; @@ -155,6 +156,7 @@ namespace opt { virtual void display_assignment(std::ostream& out); virtual bool is_pareto() { return m_pareto.get() != 0; } virtual void set_logic(symbol const& s) { m_logic = s; } + void set_clausal(bool f) { m_is_clausal = f; } void display(std::ostream& out); static void collect_param_descrs(param_descrs & r); diff --git a/src/opt/opt_solver.cpp b/src/opt/opt_solver.cpp index 8b23a4e8a..d1136a636 100644 --- a/src/opt/opt_solver.cpp +++ b/src/opt/opt_solver.cpp @@ -161,17 +161,9 @@ namespace opt { void opt_solver::maximize_objectives(expr_ref_vector& blockers) { expr_ref blocker(m); - vector values; - for (unsigned i = 0; i < m_objective_vars.size(); ++i) { - values.push_back(current_objective_value(i)); - } for (unsigned i = 0; i < m_objective_vars.size(); ++i) { maximize_objective(i, blocker); blockers.push_back(blocker); - if (values[i] > m_objective_values[i]) { - std::cout << "local optimization produced a worse result\n"; - exit(0); - } } } diff --git a/src/sat/sat_mus.cpp b/src/sat/sat_mus.cpp index c66f8ef6f..65d776d84 100644 --- a/src/sat/sat_mus.cpp +++ b/src/sat/sat_mus.cpp @@ -90,15 +90,17 @@ namespace sat { break; } unsigned num_literals = core.size() + mus.size(); + if (num_literals <= 2) { + // IF_VERBOSE(0, verbose_stream() << "num literals: " << core << " " << mus << "\n";); + break; + } literal lit = core.back(); core.pop_back(); lbool is_sat; { scoped_append _sa(mus, core); - if (true || core_miss < 2) { - mus.push_back(~lit); // TBD: measure - } + mus.push_back(~lit); is_sat = s.check(mus.size(), mus.c_ptr()); TRACE("sat", tout << "mus: " << mus << "\n";); } @@ -146,7 +148,7 @@ namespace sat { } TRACE("sat", tout << "new core: " << mus << "\n";); set_core(); - IF_VERBOSE(2, verbose_stream() << "(sat.mus.new " << core << ")\n";); + IF_VERBOSE(2, verbose_stream() << "(sat.mus.new " << s.m_core << ")\n";); return l_true; } diff --git a/src/shell/opt_frontend.cpp b/src/shell/opt_frontend.cpp index 6f8143ff1..616fc1962 100644 --- a/src/shell/opt_frontend.cpp +++ b/src/shell/opt_frontend.cpp @@ -118,7 +118,9 @@ class wcnf { public: - wcnf(opt::context& opt, stream_buffer& in): opt(opt), m(opt.get_manager()), in(in) {} + wcnf(opt::context& opt, stream_buffer& in): opt(opt), m(opt.get_manager()), in(in) { + opt.set_clausal(true); + } void parse() { int num_vars = 0, num_clauses = 0, max_weight = 0; diff --git a/src/tactic/core/propagate_values_tactic.cpp b/src/tactic/core/propagate_values_tactic.cpp index 5873efd61..39df3b174 100644 --- a/src/tactic/core/propagate_values_tactic.cpp +++ b/src/tactic/core/propagate_values_tactic.cpp @@ -135,6 +135,7 @@ class propagate_values_tactic : public tactic { TRACE("shallow_context_simplifier_bug", tout << mk_ismt2_pp(curr, m()) << "\n---->\n" << mk_ismt2_pp(new_curr, m()) << "\n";); push_result(new_curr, new_pr); + if (new_curr != curr) m_modified = true; } @@ -160,6 +161,9 @@ class propagate_values_tactic : public tactic { if (m_goal->inconsistent()) goto end; + if (m_max_rounds == 0) + goto end; + m_subst = alloc(expr_substitution, m(), g->unsat_core_enabled(), g->proofs_enabled()); m_r.set_substitution(m_subst.get()); m_occs(*m_goal); diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 04acf1ad9..197f65c10 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -230,6 +230,7 @@ public: } } + void set(param_descrs const & d, symbol const & param_name, char const * value, symbol const & mod_name) { param_kind k = d.get_kind(param_name); params_ref & ps = get_params(mod_name);