Skip to content

Commit

Permalink
use only maxres if there is a lexicographic objective, fix #6697
Browse files Browse the repository at this point in the history
- maxlex.enable heuristic does not work if it is chained among multiple objectives. Only maxres is set up to commit the proper constraints.
  • Loading branch information
NikolajBjorner committed Apr 25, 2023
1 parent 7a689c3 commit fdd5c92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/opt/maxsmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/opt/maxsmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
4 changes: 2 additions & 2 deletions src/opt/opt_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fdd5c92

Please sign in to comment.