@@ -387,7 +387,7 @@ namespace lp {
387
387
}
388
388
};
389
389
390
- void remove_term_callback (const lar_term *t) {
390
+ void undo_add_term_method (const lar_term *t) {
391
391
TRACE (" d_undo" , tout << " t:" << t<<" , t->j():" << t->j () << std::endl;);
392
392
TRACE (" dioph_eq" , lra.print_term (*t, tout); tout << " , t->j() =" << t->j () << std::endl;);
393
393
if (!contains (m_active_terms, t)) {
@@ -422,8 +422,18 @@ namespace lp {
422
422
tout << " and " << m_l_matrix.row_count () << " rows" << std::endl;
423
423
print_lar_term_L (*t, tout); tout << " ; t->j()=" << t->j () << std::endl;
424
424
);
425
- shrink_L_to_sizes ();
425
+ shrink_matrices ();
426
426
}
427
+
428
+ struct undo_add_term : public trail {
429
+ imp& m_s;
430
+ const lar_term* m_t ;
431
+ undo_add_term (imp& s, const lar_term *t): m_s(s), m_t (t) {}
432
+
433
+ void undo () {
434
+ m_s.undo_add_term_method (m_t );
435
+ }
436
+ };
427
437
428
438
struct undo_fixed_column : public trail {
429
439
imp& m_imp;
@@ -504,7 +514,7 @@ namespace lp {
504
514
m_l_matrix.add_rows (mpq (1 ), i, m_l_matrix.row_count () - 1 );
505
515
}
506
516
507
- void shrink_L_to_sizes () {
517
+ void shrink_matrices () {
508
518
unsigned i = m_l_matrix.row_count () - 1 ;
509
519
eliminate_last_term_column ();
510
520
remove_last_row_in_matrix (m_l_matrix);
@@ -564,7 +574,9 @@ namespace lp {
564
574
TRACE (" dioph_eq" , tout << " not all vars are integrall\n " ;);
565
575
return ;
566
576
}
567
- m_added_terms.push_back (t);
577
+ m_added_terms.push_back (t);
578
+ auto undo = undo_add_term (*this , t);
579
+ lra.trail ().push (undo);
568
580
}
569
581
570
582
void update_column_bound_callback (unsigned j) {
@@ -578,7 +590,6 @@ namespace lp {
578
590
public:
579
591
imp (int_solver& lia, lar_solver& lra) : lia(lia), lra(lra) {
580
592
lra.m_add_term_callback =[this ](const lar_term*t){add_term_callback (t);};
581
- lra.m_remove_term_callback = [this ](const lar_term*t){remove_term_callback (t);};
582
593
lra.m_update_column_bound_callback = [this ](unsigned j){update_column_bound_callback (j);};
583
594
}
584
595
term_o get_term_from_entry (unsigned i) const {
0 commit comments