@@ -341,7 +341,9 @@ void theory_diff_logic<Ext>::pop_scope_eh(unsigned num_scopes) {
341
341
m_scopes.shrink (new_lvl);
342
342
unsigned num_edges = m_graph.get_num_edges ();
343
343
m_graph.pop (num_scopes);
344
- if (num_edges != m_graph.get_num_edges () && m_num_simplex_edges > 0 ) {
344
+ TRACE (" arith" , m_graph.display (tout););
345
+ SASSERT (m_graph.is_feasible ());
346
+ if (true || (num_edges != m_graph.get_num_edges () && m_num_simplex_edges > 0 )) {
345
347
m_S.reset ();
346
348
m_num_simplex_edges = 0 ;
347
349
m_objective_rows.reset ();
@@ -565,6 +567,7 @@ bool theory_diff_logic<Ext>::propagate_atom(atom* a) {
565
567
}
566
568
int edge_id = a->get_asserted_edge ();
567
569
if (!m_graph.enable_edge (edge_id)) {
570
+ TRACE (" arith" , display (tout););
568
571
set_neg_cycle_conflict ();
569
572
return false ;
570
573
}
@@ -685,11 +688,8 @@ void theory_diff_logic<Ext>::set_neg_cycle_conflict() {
685
688
context & ctx = get_context ();
686
689
TRACE (" arith_conflict" ,
687
690
tout << " conflict: " ;
688
- for (unsigned i = 0 ; i < lits.size (); ++i) {
689
- ctx.display_literal_info (tout, lits[i]);
690
- }
691
- tout << " \n " ;
692
- );
691
+ for (literal lit : lits) ctx.display_literal_info (tout, lit);
692
+ tout << " \n " ;);
693
693
694
694
if (dump_lemmas ()) {
695
695
symbol logic (m_lia_or_lra == is_lia ? " QF_LIA" : " QF_LRA" );
@@ -911,6 +911,7 @@ void theory_diff_logic<Ext>::compute_delta() {
911
911
}
912
912
913
913
914
+
914
915
template <typename Ext>
915
916
void theory_diff_logic<Ext>::init_model(smt::model_generator & m) {
916
917
m_factory = alloc (arith_factory, get_manager ());
@@ -935,9 +936,11 @@ model_value_proc * theory_diff_logic<Ext>::mk_value(enode * n, model_generator &
935
936
936
937
template <typename Ext>
937
938
void theory_diff_logic<Ext>::display(std::ostream & out) const {
938
- for (unsigned i = 0 ; i < m_atoms.size (); ++i) {
939
- m_atoms[i]->display (*this , out);
939
+ out << " atoms\n " ;
940
+ for (atom* a : m_atoms) {
941
+ a->display (*this , out) << " \n " ;
940
942
}
943
+ out << " graph\n " ;
941
944
m_graph.display (out);
942
945
}
943
946
@@ -1150,6 +1153,8 @@ void theory_diff_logic<Ext>::update_simplex(Simplex& S) {
1150
1153
}
1151
1154
S.set_lower (node2simplex (get_zero (true )), mpq_inf (mpq (0 ), mpq (0 )));
1152
1155
S.set_upper (node2simplex (get_zero (true )), mpq_inf (mpq (0 ), mpq (0 )));
1156
+ S.set_lower (node2simplex (get_zero (false )), mpq_inf (mpq (0 ), mpq (0 )));
1157
+ S.set_upper (node2simplex (get_zero (false )), mpq_inf (mpq (0 ), mpq (0 )));
1153
1158
svector<unsigned > vars;
1154
1159
scoped_mpq_vector coeffs (mgr);
1155
1160
coeffs.push_back (mpq (1 ));
@@ -1215,6 +1220,8 @@ typename theory_diff_logic<Ext>::inf_eps theory_diff_logic<Ext>::value(theory_va
1215
1220
return r;
1216
1221
}
1217
1222
1223
+
1224
+
1218
1225
template <typename Ext>
1219
1226
typename theory_diff_logic<Ext>::inf_eps
1220
1227
theory_diff_logic<Ext>::maximize(theory_var v, expr_ref& blocker, bool & has_shared) {
@@ -1224,6 +1231,9 @@ theory_diff_logic<Ext>::maximize(theory_var v, expr_ref& blocker, bool& has_shar
1224
1231
Simplex& S = m_S;
1225
1232
ast_manager& m = get_manager ();
1226
1233
1234
+ CTRACE (" arith" ,!m_graph.is_feasible (), m_graph.display (tout););
1235
+ SASSERT (m_graph.is_feasible ());
1236
+
1227
1237
update_simplex (S);
1228
1238
1229
1239
TRACE (" arith" ,
@@ -1235,7 +1245,12 @@ theory_diff_logic<Ext>::maximize(theory_var v, expr_ref& blocker, bool& has_shar
1235
1245
tout << " Free coefficient " << m_objective_consts[v] << " \n " ;
1236
1246
);
1237
1247
1238
- TRACE (" opt" , S.display (tout); display (tout););
1248
+ TRACE (" opt" ,
1249
+ S.display (tout);
1250
+ for (unsigned i = 0 ; i < m_graph.get_num_nodes (); ++i)
1251
+ tout << " $" << i << " : " << node2simplex (i) << " \n " ;
1252
+ display (tout);
1253
+ );
1239
1254
1240
1255
// optimize
1241
1256
lbool is_sat = S.make_feasible ();
@@ -1252,8 +1267,6 @@ theory_diff_logic<Ext>::maximize(theory_var v, expr_ref& blocker, bool& has_shar
1252
1267
simplex::mpq_ext::eps_numeral const & val = S.get_value (w);
1253
1268
inf_rational r (-rational (val.first ), -rational (val.second ));
1254
1269
Simplex::row row = m_objective_rows[v];
1255
- TRACE (" opt" , tout << r << " " << " \n " ;
1256
- S.display_row (tout, row, true ););
1257
1270
Simplex::row_iterator it = S.row_begin (row), end = S.row_end (row);
1258
1271
expr_ref_vector& core = m_objective_assignments[v];
1259
1272
expr_ref tmp (m);
@@ -1269,13 +1282,21 @@ theory_diff_logic<Ext>::maximize(theory_var v, expr_ref& blocker, bool& has_shar
1269
1282
}
1270
1283
}
1271
1284
}
1272
- compute_delta ();
1285
+ ensure_rational_solution (S);
1286
+ TRACE (" opt" , tout << r << " " << " \n " ;
1287
+ S.display_row (tout, row, true );
1288
+ S.display (tout);
1289
+ );
1290
+
1273
1291
for (unsigned i = 0 ; i < m_graph.get_num_nodes (); ++i) {
1274
1292
unsigned w = node2simplex (i);
1275
- simplex::mpq_ext::eps_numeral const & val = S.get_value (w);
1276
- rational r = rational (val.first ) + m_delta*rational (val.second );
1293
+ auto const & val = S.get_value (w);
1294
+ SASSERT (rational (val.second ).is_zero ());
1295
+ rational r = rational (val.first );
1277
1296
m_graph.set_assignment (i, numeral (r));
1278
1297
}
1298
+ CTRACE (" arith" ,!m_graph.is_feasible (), m_graph.display (tout););
1299
+ SASSERT (m_graph.is_feasible ());
1279
1300
inf_eps r1 (rational (0 ), r);
1280
1301
blocker = mk_gt (v, r1);
1281
1302
return inf_eps (rational (0 ), r + m_objective_consts[v]);
0 commit comments