@@ -240,7 +240,7 @@ namespace lp {
240240 unsigned m_conflict_index = -1 ; // m_entries[m_conflict_index] gives the conflict
241241 unsigned m_max_number_of_iterations = 100 ;
242242 unsigned m_number_of_iterations;
243- std_vector< std::unordered_set<unsigned >> m_columns_to_entries ; // m_columnn_to_terms [j] is the set of of all k such that m_entry[k].m_l depends on j
243+ std::unordered_map< unsigned , std::unordered_set<unsigned >> m_columns_to_term_columns ; // m_columnn_to_term_columns [j] is the set of of all k such that lra.get_term(k) depends on j
244244 struct branch {
245245 unsigned m_j = UINT_MAX;
246246 mpq m_rs;
@@ -290,16 +290,19 @@ namespace lp {
290290 };
291291
292292
293- struct undo_add_column_bound : public trail {
293+ struct undo_change_column_bound : public trail {
294294 imp& m_s;
295295 unsigned m_j; // the column that has been added
296- undo_add_column_bound (imp& s, unsigned j) : m_s(s), m_j(j) {}
296+ undo_change_column_bound (imp& s, unsigned j) : m_s(s), m_j(j) {}
297297
298298 void undo () override {
299- NOT_IMPLEMENTED_YET ( );
299+ m_s. add_changed_column (m_j );
300300 }
301301 };
302302
303+ uint_set m_changed_columns; // the columns are given as lar_solver columns
304+ friend undo_change_column_bound;
305+ void add_changed_column (unsigned j) { m_changed_columns.insert (j);}
303306 std_vector<const lar_term*> m_added_terms;
304307
305308 std_vector<variable_branch_stats> m_branch_stats;
@@ -318,17 +321,17 @@ namespace lp {
318321 lra.trail ().push (undo);
319322 }
320323
321- void add_column_bound_delegate (unsigned j) {
324+ void update_column_bound_delegate (unsigned j) {
322325 if (!lra.column_is_int (j))
323326 return ;
324- auto undo = undo_add_column_bound (*this , j);
327+ auto undo = undo_change_column_bound (*this , j);
325328 lra.trail ().push (undo) ;
326329 }
327330
328331 public:
329332 imp (int_solver& lia, lar_solver& lra) : lia(lia), lra(lra) {
330333 lra.register_add_term_delegate ([this ](const lar_term*t){add_term_delegate (t);});
331- lra.register_add_column_bound_delegate ([this ](unsigned j) {add_column_bound_delegate (j);});
334+ lra.register_update_column_bound_delegate ([this ](unsigned j) {update_column_bound_delegate (j);});
332335 }
333336 term_o get_term_from_entry (unsigned i) const {
334337 term_o t;
@@ -348,6 +351,22 @@ namespace lp {
348351 return m_var_register.local_to_external (j);
349352 }
350353
354+ void register_term_columns (const lar_term & t) {
355+ for (const auto & p : t) {
356+ register_term_column (p.j (), t);
357+ }
358+ }
359+ void register_term_column (unsigned j, const lar_term& t) {
360+ auto it = m_columns_to_term_columns.find (j);
361+ if (it != m_columns_to_term_columns.end ())
362+ it->second .insert (t.j ());
363+ else {
364+ auto s = std::unordered_set<unsigned >();
365+ s.insert (t.j ());
366+ m_columns_to_term_columns[j] = s;
367+ }
368+
369+ }
351370 // the term has form sum(a_i*x_i) - t.j() = 0,
352371 void fill_entry (const lar_term& t) {
353372 TRACE (" dioph_eq" , print_lar_term_L (t, tout) << std::endl;);
@@ -383,7 +402,7 @@ namespace lp {
383402 m_e_matrix.add_columns_up_to (lj);
384403 m_e_matrix.add_new_element (entry_index, lj, -mpq (1 ));
385404 }
386- TRACE ( " dioph_eq " , print_entry (entry_index, tout); );
405+ register_term_columns (t );
387406 SASSERT (entry_invariant (entry_index));
388407 }
389408
@@ -394,6 +413,21 @@ namespace lp {
394413 }
395414 return true ;
396415 }
416+ void process_changed_columns () {
417+ std::unordered_set<unsigned > entries_to_recalculate;
418+ for (unsigned j : m_changed_columns) {
419+ for (unsigned k : m_columns_to_term_columns[j]) {
420+ for (const auto & p : m_l_matrix.column (k)) {
421+ entries_to_recalculate.insert (p.var ());
422+ }
423+ }
424+ }
425+
426+ if (entries_to_recalculate.size () > 0 )
427+ NOT_IMPLEMENTED_YET ();
428+
429+ m_changed_columns.reset ();
430+ }
397431
398432 void init () {
399433 m_report_branch = false ;
@@ -403,6 +437,7 @@ namespace lp {
403437 m_number_of_iterations = 0 ;
404438 m_branch_stack.clear ();
405439 m_lra_level = 0 ;
440+ process_changed_columns ();
406441 for (const lar_term* t: m_added_terms) {
407442 fill_entry (*t);
408443 }
0 commit comments