@@ -213,7 +213,7 @@ namespace opt {
213
213
214
214
void context::add_hard_constraint (expr* f, expr* t) {
215
215
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" );
217
217
m_scoped_state.m_asms .push_back (t);
218
218
m_scoped_state.add (m.mk_implies (t, f));
219
219
clear_state ();
@@ -905,12 +905,14 @@ namespace opt {
905
905
ptr_vector<expr> deps;
906
906
expr_dependency_ref core (r->dep (i), m);
907
907
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)))
912
913
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)));
914
916
}
915
917
if (r->inconsistent ()) {
916
918
ptr_vector<expr> core_elems;
@@ -920,6 +922,10 @@ namespace opt {
920
922
}
921
923
}
922
924
925
+ bool context::is_objective (expr* fml) {
926
+ return is_app (fml) && m_objective_fns.contains (to_app (fml)->get_decl ());
927
+ }
928
+
923
929
bool context::is_maximize (expr* fml, app_ref& term, expr_ref& orig_term, unsigned & index) {
924
930
if (is_app (fml) && m_objective_fns.find (to_app (fml)->get_decl (), index ) &&
925
931
m_objectives[index ].m_type == O_MAXIMIZE) {
0 commit comments