@@ -240,7 +240,7 @@ namespace lp {
240
240
unsigned m_conflict_index = -1 ; // m_entries[m_conflict_index] gives the conflict
241
241
unsigned m_max_number_of_iterations = 100 ;
242
242
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
244
244
struct branch {
245
245
unsigned m_j = UINT_MAX;
246
246
mpq m_rs;
@@ -290,16 +290,19 @@ namespace lp {
290
290
};
291
291
292
292
293
- struct undo_add_column_bound : public trail {
293
+ struct undo_change_column_bound : public trail {
294
294
imp& m_s;
295
295
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) {}
297
297
298
298
void undo () override {
299
- NOT_IMPLEMENTED_YET ( );
299
+ m_s. add_changed_column (m_j );
300
300
}
301
301
};
302
302
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);}
303
306
std_vector<const lar_term*> m_added_terms;
304
307
305
308
std_vector<variable_branch_stats> m_branch_stats;
@@ -318,17 +321,17 @@ namespace lp {
318
321
lra.trail ().push (undo);
319
322
}
320
323
321
- void add_column_bound_delegate (unsigned j) {
324
+ void update_column_bound_delegate (unsigned j) {
322
325
if (!lra.column_is_int (j))
323
326
return ;
324
- auto undo = undo_add_column_bound (*this , j);
327
+ auto undo = undo_change_column_bound (*this , j);
325
328
lra.trail ().push (undo) ;
326
329
}
327
330
328
331
public:
329
332
imp (int_solver& lia, lar_solver& lra) : lia(lia), lra(lra) {
330
333
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);});
332
335
}
333
336
term_o get_term_from_entry (unsigned i) const {
334
337
term_o t;
@@ -348,6 +351,22 @@ namespace lp {
348
351
return m_var_register.local_to_external (j);
349
352
}
350
353
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
+ }
351
370
// the term has form sum(a_i*x_i) - t.j() = 0,
352
371
void fill_entry (const lar_term& t) {
353
372
TRACE (" dioph_eq" , print_lar_term_L (t, tout) << std::endl;);
@@ -383,7 +402,7 @@ namespace lp {
383
402
m_e_matrix.add_columns_up_to (lj);
384
403
m_e_matrix.add_new_element (entry_index, lj, -mpq (1 ));
385
404
}
386
- TRACE ( " dioph_eq " , print_entry (entry_index, tout); );
405
+ register_term_columns (t );
387
406
SASSERT (entry_invariant (entry_index));
388
407
}
389
408
@@ -394,6 +413,21 @@ namespace lp {
394
413
}
395
414
return true ;
396
415
}
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
+ }
397
431
398
432
void init () {
399
433
m_report_branch = false ;
@@ -403,6 +437,7 @@ namespace lp {
403
437
m_number_of_iterations = 0 ;
404
438
m_branch_stack.clear ();
405
439
m_lra_level = 0 ;
440
+ process_changed_columns ();
406
441
for (const lar_term* t: m_added_terms) {
407
442
fill_entry (*t);
408
443
}
0 commit comments