3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-08 02:15:19 +00:00

use only maxres if there is a lexicographic objective, fix #6697

- maxlex.enable heuristic does not work if it is chained among multiple objectives. Only maxres is set up to commit the proper constraints.
This commit is contained in:
Nikolaj Bjorner 2023-04-24 20:20:26 -07:00
parent 7a689c3298
commit fdd5c923ed
3 changed files with 6 additions and 6 deletions

View file

@ -178,14 +178,14 @@ namespace opt {
maxsmt::maxsmt(maxsat_context& c, unsigned index):
m(c.get_manager()), m_c(c), m_index(index), m_answer(m) {}
lbool maxsmt::operator()() {
lbool maxsmt::operator()(bool committed) {
lbool is_sat = l_undef;
m_msolver = nullptr;
opt_params optp(m_params);
symbol const& maxsat_engine = m_c.maxsat_engine();
IF_VERBOSE(1, verbose_stream() << "(maxsmt)\n";);
TRACE("opt_verbose", s().display(tout << "maxsmt\n") << "\n";);
if (optp.maxlex_enable() && is_maxlex(m_soft))
if (!committed && optp.maxlex_enable() && is_maxlex(m_soft))
m_msolver = mk_maxlex(m_c, m_index, m_soft);
else if (m_soft.empty() || maxsat_engine == symbol("maxres") || maxsat_engine == symbol::null)
m_msolver = mk_maxres(m_c, m_index, m_soft);
@ -401,7 +401,7 @@ namespace opt {
for (auto const& p : soft) {
maxsmt.add(p.first, p.second);
}
lbool r = maxsmt();
lbool r = maxsmt(true);
if (r == l_true) {
svector<symbol> labels;
maxsmt.get_model(m_model, labels);

View file

@ -137,7 +137,7 @@ namespace opt {
params_ref m_params;
public:
maxsmt(maxsat_context& c, unsigned id);
lbool operator()();
lbool operator()(bool committed);
void updt_params(params_ref& p);
void add(expr* f, rational const& w);
unsigned size() const { return m_soft.size(); }

View file

@ -453,8 +453,8 @@ namespace opt {
lbool context::execute_maxsat(symbol const& id, bool committed, bool scoped) {
model_ref tmp;
maxsmt& ms = *m_maxsmts.find(id);
if (scoped) get_solver().push();
lbool result = ms();
if (scoped) get_solver().push();
lbool result = ms(committed);
if (result != l_false && (ms.get_model(tmp, m_labels), tmp.get())) {
ms.get_model(m_model, m_labels);
}