Skip to content

Commit

Permalink
fix #7018
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Nov 28, 2023
1 parent 3422f44 commit 69f9640
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/opt/opt_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace opt {

void context::add_hard_constraint(expr* f, expr* t) {
if (m_calling_on_model)
throw default_exception("adding soft constraints is not supported during callbacks");
throw default_exception("adding hard constraints is not supported during callbacks");
m_scoped_state.m_asms.push_back(t);
m_scoped_state.add(m.mk_implies(t, f));
clear_state();
Expand Down Expand Up @@ -905,12 +905,14 @@ namespace opt {
ptr_vector<expr> deps;
expr_dependency_ref core(r->dep(i), m);
m.linearize(core, deps);
if (!deps.empty()) {
fmls.push_back(m.mk_implies(m.mk_and(deps.size(), deps.data()), r->form(i)));
}
else {
if (deps.empty())
fmls.push_back(r->form(i));
else if (deps.size() == 1 && deps[0] == r->form(i))
continue;
else if (is_objective(r->form(i)))
fmls.push_back(r->form(i));
}
else
fmls.push_back(m.mk_implies(mk_and(m, deps.size(), deps.data()), r->form(i)));
}
if (r->inconsistent()) {
ptr_vector<expr> core_elems;
Expand All @@ -920,6 +922,10 @@ namespace opt {
}
}

bool context::is_objective(expr* fml) {
return is_app(fml) && m_objective_fns.contains(to_app(fml)->get_decl());
}

bool context::is_maximize(expr* fml, app_ref& term, expr_ref& orig_term, unsigned& index) {
if (is_app(fml) && m_objective_fns.find(to_app(fml)->get_decl(), index) &&
m_objectives[index].m_type == O_MAXIMIZE) {
Expand Down
1 change: 1 addition & 0 deletions src/opt/opt_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ namespace opt {
void import_scoped_state();
void normalize(expr_ref_vector const& asms);
void internalize();
bool is_objective(expr* fml);
bool is_maximize(expr* fml, app_ref& term, expr_ref& orig_term, unsigned& index);
bool is_minimize(expr* fml, app_ref& term, expr_ref& orig_term, unsigned& index);
bool is_maxsat(expr* fml, expr_ref_vector& terms,
Expand Down

0 comments on commit 69f9640

Please sign in to comment.