File tree Expand file tree Collapse file tree 5 files changed +36
-11
lines changed Expand file tree Collapse file tree 5 files changed +36
-11
lines changed Original file line number Diff line number Diff line change @@ -791,11 +791,10 @@ class maxres : public maxsmt_solver_base {
791
791
improve_model (mdl);
792
792
mdl->set_model_completion (true );
793
793
unsigned correction_set_size = 0 ;
794
- for (expr* a : m_asms) {
795
- if (mdl->is_false (a)) {
794
+ for (expr* a : m_asms)
795
+ if (mdl->is_false (a))
796
796
++correction_set_size;
797
- }
798
- }
797
+
799
798
if (!m_csmodel.get () || correction_set_size < m_correction_set_size) {
800
799
m_csmodel = mdl;
801
800
m_correction_set_size = correction_set_size;
@@ -810,22 +809,22 @@ class maxres : public maxsmt_solver_base {
810
809
return ;
811
810
}
812
811
813
- if (!m_c.verify_model (m_index, mdl.get (), upper)) {
812
+ if (!m_c.verify_model (m_index, mdl.get (), upper))
814
813
return ;
815
- }
816
814
815
+ unsigned num_assertions = s ().get_num_assertions ();
817
816
m_model = mdl;
818
817
m_c.model_updated (mdl.get ());
819
818
820
819
TRACE (" opt" , tout << " updated upper: " << upper << " \n " ;);
821
820
822
- for (soft& s : m_soft) {
821
+ for (soft& s : m_soft)
823
822
s.set_value (m_model->is_true (s.s ));
824
- }
825
823
826
824
verify_assignment ();
827
825
828
- m_upper = upper;
826
+ if (num_assertions == s ().get_num_assertions ())
827
+ m_upper = upper;
829
828
830
829
trace ();
831
830
Original file line number Diff line number Diff line change @@ -50,7 +50,13 @@ namespace opt {
50
50
51
51
void maxsmt_solver_base::updt_params (params_ref& p) {
52
52
m_params.copy (p);
53
- }
53
+ }
54
+
55
+ void maxsmt_solver_base::reset_upper () {
56
+ m_upper = m_lower;
57
+ for (soft& s : m_soft)
58
+ m_upper += s.weight ;
59
+ }
54
60
55
61
solver& maxsmt_solver_base::s () {
56
62
return m_c.get_solver ();
@@ -289,6 +295,12 @@ namespace opt {
289
295
}
290
296
}
291
297
298
+ void maxsmt::reset_upper () {
299
+ if (m_msolver) {
300
+ m_msolver->reset_upper ();
301
+ m_upper = m_msolver->get_upper ();
302
+ }
303
+ }
292
304
293
305
void maxsmt::verify_assignment () {
294
306
// TBD: have to use a different solver
Original file line number Diff line number Diff line change @@ -103,6 +103,8 @@ namespace opt {
103
103
};
104
104
105
105
lbool find_mutexes (obj_map<expr, rational>& new_soft);
106
+
107
+ void reset_upper ();
106
108
107
109
108
110
protected:
@@ -153,6 +155,7 @@ namespace opt {
153
155
void display_answer (std::ostream& out) const ;
154
156
void collect_statistics (statistics& st) const ;
155
157
void model_updated (model* mdl);
158
+ void reset_upper ();
156
159
private:
157
160
bool is_maxsat_problem (weights_t & ws) const ;
158
161
void verify_assignment ();
Original file line number Diff line number Diff line change @@ -195,13 +195,22 @@ namespace opt {
195
195
}
196
196
197
197
void context::add_hard_constraint (expr* f) {
198
- if (m_calling_on_model)
198
+ if (m_calling_on_model) {
199
199
get_solver ().assert_expr (f);
200
+ for (auto const & [k, v] : m_maxsmts)
201
+ v->reset_upper ();
202
+ for (unsigned i = 0 ; i < num_objectives (); ++i) {
203
+ auto const & o = m_scoped_state.m_objectives [i];
204
+ if (o.m_type != O_MAXSMT)
205
+ m_optsmt.update_upper (o.m_index , inf_eps::infinity ());
206
+ }
207
+ }
200
208
else {
201
209
m_scoped_state.add (f);
202
210
clear_state ();
203
211
}
204
212
}
213
+
205
214
206
215
void context::add_hard_constraint (expr* f, expr* t) {
207
216
if (m_calling_on_model)
Original file line number Diff line number Diff line change @@ -3818,6 +3818,8 @@ namespace sat {
3818
3818
void solver::move_to_front (bool_var b) {
3819
3819
if (b >= num_vars ())
3820
3820
return ;
3821
+ if (m_case_split_queue.empty ())
3822
+ return ;
3821
3823
bool_var next = m_case_split_queue.min_var ();
3822
3824
auto next_act = m_activity[next];
3823
3825
set_activity (b, next_act + 1 );
You can’t perform that action at this time.
0 commit comments