Skip to content

Commit 69f9640

Browse files
fix #7018
1 parent 3422f44 commit 69f9640

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Diff for: src/opt/opt_context.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namespace opt {
213213

214214
void context::add_hard_constraint(expr* f, expr* t) {
215215
if (m_calling_on_model)
216-
throw default_exception("adding soft constraints is not supported during callbacks");
216+
throw default_exception("adding hard constraints is not supported during callbacks");
217217
m_scoped_state.m_asms.push_back(t);
218218
m_scoped_state.add(m.mk_implies(t, f));
219219
clear_state();
@@ -905,12 +905,14 @@ namespace opt {
905905
ptr_vector<expr> deps;
906906
expr_dependency_ref core(r->dep(i), m);
907907
m.linearize(core, deps);
908-
if (!deps.empty()) {
909-
fmls.push_back(m.mk_implies(m.mk_and(deps.size(), deps.data()), r->form(i)));
910-
}
911-
else {
908+
if (deps.empty())
909+
fmls.push_back(r->form(i));
910+
else if (deps.size() == 1 && deps[0] == r->form(i))
911+
continue;
912+
else if (is_objective(r->form(i)))
912913
fmls.push_back(r->form(i));
913-
}
914+
else
915+
fmls.push_back(m.mk_implies(mk_and(m, deps.size(), deps.data()), r->form(i)));
914916
}
915917
if (r->inconsistent()) {
916918
ptr_vector<expr> core_elems;
@@ -920,6 +922,10 @@ namespace opt {
920922
}
921923
}
922924

925+
bool context::is_objective(expr* fml) {
926+
return is_app(fml) && m_objective_fns.contains(to_app(fml)->get_decl());
927+
}
928+
923929
bool context::is_maximize(expr* fml, app_ref& term, expr_ref& orig_term, unsigned& index) {
924930
if (is_app(fml) && m_objective_fns.find(to_app(fml)->get_decl(), index) &&
925931
m_objectives[index].m_type == O_MAXIMIZE) {

Diff for: src/opt/opt_context.h

+1
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ namespace opt {
303303
void import_scoped_state();
304304
void normalize(expr_ref_vector const& asms);
305305
void internalize();
306+
bool is_objective(expr* fml);
306307
bool is_maximize(expr* fml, app_ref& term, expr_ref& orig_term, unsigned& index);
307308
bool is_minimize(expr* fml, app_ref& term, expr_ref& orig_term, unsigned& index);
308309
bool is_maxsat(expr* fml, expr_ref_vector& terms,

0 commit comments

Comments
 (0)