@@ -343,7 +343,7 @@ namespace lp {
343
343
return out;
344
344
}
345
345
346
- bool m_has_non_integral_term = false ;
346
+ bool m_some_terms_are_ignored = false ;
347
347
std_vector<mpq> m_sum_of_fixed;
348
348
// we have to use m_var_register because of the fresh variables: otherwise they clash with the existing lar_solver column indices
349
349
var_register m_var_register;
@@ -779,26 +779,29 @@ namespace lp {
779
779
std_vector<variable_branch_stats> m_branch_stats;
780
780
std_vector<branch> m_branch_stack;
781
781
std_vector<constraint_index> m_explanation_of_branches;
782
- bool term_has_big_number (const lar_term* t) const {
783
- for (const auto & p : * t)
782
+ bool term_has_big_number (const lar_term& t) const {
783
+ for (const auto & p : t)
784
784
if (p.coeff ().is_big ())
785
785
return true ;
786
786
return false ;
787
787
}
788
+
789
+ bool ignore_big_nums () const { return lra.settings ().dio_ignore_big_nums (); }
790
+
788
791
void add_term_callback (const lar_term* t) {
789
792
unsigned j = t->j ();
790
793
TRACE (" dio" , tout << " term column t->j():" << j << std::endl; lra.print_term (*t, tout) << std::endl;);
791
794
if (!lra.column_is_int (j)) {
792
795
TRACE (" dio" , tout << " ignored a non-integral column" << std::endl;);
793
- m_has_non_integral_term = true ;
796
+ m_some_terms_are_ignored = true ;
794
797
return ;
795
798
}
796
799
797
800
CTRACE (" dio" , !lra.column_has_term (j), tout << " added term that is not associated with a column yet" << std::endl;);
798
801
799
- if (term_has_big_number (t)) {
802
+ if (ignore_big_nums () && term_has_big_number (* t)) {
800
803
TRACE (" dio" , tout << " term_has_big_number\n " ;);
801
- m_has_non_integral_term = true ;
804
+ m_some_terms_are_ignored = true ;
802
805
return ;
803
806
}
804
807
m_added_terms.push_back (t);
@@ -815,11 +818,12 @@ namespace lp {
815
818
void update_column_bound_callback (unsigned j) {
816
819
if (!lra.column_is_int (j))
817
820
return ;
818
- if (lra.column_has_term (j) && !term_has_big_number (&lra.get_term (j)))
821
+ if (lra.column_has_term (j) &&
822
+ ignore_big_nums () && !term_has_big_number (lra.get_term (j)))
819
823
m_terms_to_tighten.insert (j); // the boundary of the term has changed: we can be successful to tighten this term
820
824
if (!lra.column_is_fixed (j))
821
825
return ;
822
- if (lra.get_lower_bound (j).x .is_big ())
826
+ if (ignore_big_nums () && lra.get_lower_bound (j).x .is_big ())
823
827
return ;
824
828
TRACE (" dio" , tout << " j:" << j << " \n " ; lra.print_column_info (j, tout););
825
829
m_changed_columns.insert (j);
@@ -1054,7 +1058,9 @@ namespace lp {
1054
1058
void process_changed_columns (std_vector<unsigned > &f_vector) {
1055
1059
find_changed_terms_and_more_changed_rows ();
1056
1060
for (unsigned j: m_changed_terms) {
1057
- SASSERT (!term_has_big_number (&lra.get_term (j)));
1061
+ if (j >= lra.column_count ())
1062
+ continue ;
1063
+ SASSERT (!ignore_big_nums () || !term_has_big_number (lra.get_term (j)));
1058
1064
m_terms_to_tighten.insert (j);
1059
1065
if (j < m_l_matrix.column_count ()) {
1060
1066
for (const auto & cs : m_l_matrix.column (j)) {
@@ -1346,10 +1352,13 @@ namespace lp {
1346
1352
unsigned best_var = UINT_MAX;
1347
1353
size_t min_new_vars = std::numeric_limits<size_t >::max ();
1348
1354
unsigned num_candidates = 0 ;
1349
-
1355
+ std::vector< unsigned > to_remove;
1350
1356
for (unsigned j : q.m_q ) {
1351
1357
size_t new_vars = 0 ;
1352
- if (!m_espace.has (j)) continue ;
1358
+ if (!m_espace.has (j)) {
1359
+ to_remove.push_back (j);
1360
+ continue ;
1361
+ }
1353
1362
if (m_k2s.has_key (j)) {
1354
1363
unsigned ei = m_k2s[j]; // entry index for substitution
1355
1364
for (const auto & p : m_e_matrix.m_rows [ei])
@@ -1377,6 +1386,10 @@ namespace lp {
1377
1386
if (best_var != UINT_MAX)
1378
1387
q.remove (best_var);
1379
1388
1389
+ for (unsigned j: to_remove)
1390
+ q.remove (j);
1391
+
1392
+
1380
1393
return best_var;
1381
1394
}
1382
1395
@@ -1544,25 +1557,31 @@ namespace lp {
1544
1557
1545
1558
// We will have lar_t, and let j is lar_t.j(), the term column.
1546
1559
// In the m_espace we have lar_t. The result of open_ml((1*j)) is lar_t - (1, j).
1547
- // So we have "equality" m_espace = open(m_lspace) + (1*lar_t.j())
1548
- void init_substitutions (const lar_term& lar_t , protected_queue& q) {
1560
+ // So we have "equality" m_espace = open(m_lspace) + (1*lar_t.j())
1561
+ // return false iff seen a big number and dio_ignore_big_nums() is true
1562
+ bool init_substitutions (const lar_term& lar_t , protected_queue& q) {
1549
1563
m_espace.clear ();
1550
1564
m_c = mpq (0 );
1551
1565
m_lspace.clear ();
1552
1566
m_lspace.add (mpq (1 ), lar_t .j ());
1553
1567
SASSERT (get_extended_term_value (lar_t ).is_zero ());
1554
1568
for (const auto & p : lar_t ) {
1555
1569
if (is_fixed (p.j ())) {
1556
- m_c += p.coeff () * lia.lower_bound (p.j ()).x ;
1570
+ const mpq& b = lia.lower_bound (p.j ()).x ;
1571
+ if (ignore_big_nums () && b.is_big ())
1572
+ return false ;
1573
+ m_c += p.coeff () * b;
1557
1574
}
1558
1575
else {
1559
1576
unsigned lj = lar_solver_to_local (p.j ());
1577
+ SASSERT (!p.coeff ().is_big ());
1560
1578
m_espace.add (p.coeff (), lj);;
1561
1579
if (can_substitute (lj))
1562
1580
q.push (lj);
1563
1581
}
1564
1582
}
1565
1583
SASSERT (subs_invariant (lar_t .j ()));
1584
+ return true ;
1566
1585
}
1567
1586
1568
1587
unsigned lar_solver_to_local (unsigned j) const {
@@ -1584,8 +1603,6 @@ namespace lp {
1584
1603
1585
1604
lia_move tighten_on_espace (unsigned j) {
1586
1605
mpq g = gcd_of_coeffs (m_espace.m_data , true );
1587
- TRACE (" dio" , tout << " after process_q_with_S\n t:" ; print_term_o (create_term_from_espace (), tout) << std::endl; tout << " g:" << g << std::endl;);
1588
-
1589
1606
if (g.is_one ())
1590
1607
return lia_move::undef;
1591
1608
if (g.is_zero ()) {
@@ -1623,7 +1640,8 @@ namespace lp {
1623
1640
lra.print_column_info (p.var (), tout);
1624
1641
}
1625
1642
);
1626
- init_substitutions (lra.get_term (j), q);
1643
+ if (!init_substitutions (lra.get_term (j), q))
1644
+ return lia_move::undef;
1627
1645
1628
1646
TRACE (" dio" , tout << " t:" ;
1629
1647
tout << " m_espace:" ;
@@ -2218,6 +2236,8 @@ namespace lp {
2218
2236
for (unsigned k = 0 ; k < lra.terms ().size (); k++) {
2219
2237
const lar_term* t = lra.terms ()[k];
2220
2238
if (!lia.column_is_int (t->j ())) continue ;
2239
+ if (ignore_big_nums () && term_has_big_number (*t))
2240
+ continue ;
2221
2241
SASSERT (t->j () != UINT_MAX);
2222
2242
for (const auto & p : (*t).ext_coeffs ()) {
2223
2243
unsigned j = p.var ();
@@ -2288,7 +2308,6 @@ namespace lp {
2288
2308
public:
2289
2309
lia_move check () {
2290
2310
lra.stats ().m_dio_calls ++;
2291
- std::cout << " check" << std::endl;
2292
2311
TRACE (" dio" , tout << lra.stats ().m_dio_calls << std::endl;);
2293
2312
std_vector<unsigned > f_vector;
2294
2313
lia_move ret;
@@ -2778,8 +2797,8 @@ namespace lp {
2778
2797
// needed for the template bound_analyzer_on_row.h
2779
2798
const lar_solver& lp () const { return lra; }
2780
2799
lar_solver& lp () {return lra;}
2781
- bool has_non_integral_term () const {
2782
- return m_has_non_integral_term ;
2800
+ bool some_terms_are_ignored () const {
2801
+ return m_some_terms_are_ignored ;
2783
2802
}
2784
2803
};
2785
2804
// Constructor definition
@@ -2798,8 +2817,8 @@ namespace lp {
2798
2817
m_imp->explain (ex);
2799
2818
}
2800
2819
2801
- bool dioph_eq::has_non_integral_term () const {
2802
- return m_imp->has_non_integral_term ();
2820
+ bool dioph_eq::some_terms_are_ignored () const {
2821
+ return m_imp->some_terms_are_ignored ();
2803
2822
}
2804
2823
2805
2824
0 commit comments