@@ -113,23 +113,23 @@ namespace lp {
113
113
e is an equation and ℓ is a linear combination of variables from L
114
114
*/
115
115
//
116
+ enum class entry_status {
117
+ F,
118
+ S,
119
+ NO_S_NO_F
120
+ };
116
121
struct eprime_entry {
117
122
unsigned m_row_index; // the index of the row in the constraint matrix that m_e corresponds to
118
123
term_o m_e; // it will be used for debugging only
119
124
// we keep the dependency of the equation in m_l
120
125
// a more expensive alternative is to keep the history term of m_e : originally m_l is i, the index of row m_e was constructed from
121
126
u_dependency *m_l;
122
- };
123
- enum class row_status {
124
- F,
125
- S,
126
- NO_S_NO_F
127
+ mpq m_c; // the constant of the term
128
+ entry_status m_entry_status;
127
129
};
128
130
vector<eprime_entry> m_eprime;
129
131
// the terms are stored in m_A and m_c
130
132
static_matrix<mpq, numeric_pair<mpq>> m_e_matrix; // the rows of the matrix are the terms, without the constant part
131
- vector<row_status> m_row_status;
132
- vector<mpq> m_c; // to keep the constants of the terms
133
133
int_solver& lia;
134
134
lar_solver& lra;
135
135
explanation m_infeas_explanation;
@@ -152,7 +152,7 @@ namespace lp {
152
152
for (const auto & p: m_e_matrix.m_rows [i]) {
153
153
t.add_monomial (p.coeff (), p.var ());
154
154
}
155
- t.c () = m_c [i];
155
+ t.c () = m_eprime [i]. m_c ;
156
156
return t;
157
157
}
158
158
private:
@@ -168,7 +168,7 @@ namespace lp {
168
168
t.c () *= lcm;
169
169
#endif
170
170
// init m_e_matrix and m_c
171
- mpq & c = m_c [row_index];
171
+ mpq & c = m_eprime [row_index]. m_c ;
172
172
for (const auto & p: row)
173
173
if (lia.is_fixed (p.var ()))
174
174
c += p.coeff ()*lia.lower_bound (p.var ()).x ;
@@ -181,8 +181,6 @@ namespace lp {
181
181
182
182
void init () {
183
183
m_e_matrix = static_matrix<mpq, impq>(lra.row_count (), lra.column_count ());
184
- m_row_status.resize (lra.row_count (), row_status::NO_S_NO_F);
185
- m_c.resize (lra.row_count (), mpq (0 ));
186
184
m_report_branch = false ;
187
185
unsigned n_of_rows = lra.A_r ().row_count ();
188
186
m_k2s.clear ();
@@ -209,7 +207,7 @@ namespace lp {
209
207
continue ;
210
208
}
211
209
term_o t = create_eprime_entry_from_row (row, i);
212
- m_row_status [i] = row_status ::F;
210
+ m_eprime [i]. m_entry_status = entry_status ::F;
213
211
TRACE (" dioph_eq" , tout << " row = " ; lra.print_row (row, tout) << std::endl;);
214
212
if (t.size () == 0 ) {
215
213
SASSERT (t.c ().is_zero ());
@@ -292,12 +290,12 @@ namespace lp {
292
290
return true ;
293
291
}
294
292
TRACE (" dioph_eq" , tout << " g:" << g << std::endl;);
295
- mpq c_g = m_c [row_index] / g;
293
+ mpq c_g = m_eprime [row_index]. m_c / g;
296
294
if (c_g.is_int ()) {
297
295
for (auto & p: m_e_matrix.m_rows [row_index]) {
298
296
p.coeff () /= g;
299
297
}
300
- m_c [row_index] = c_g;
298
+ m_eprime [row_index]. m_c = c_g;
301
299
// ep.m_l *= (1/g);
302
300
TRACE (" dioph_eq" , tout << " ep_m_e:" ; print_eprime_entry (ep, tout) << std::endl;);
303
301
return true ;
@@ -453,6 +451,7 @@ namespace lp {
453
451
// }
454
452
455
453
// return tighten_bounds_for_term(t, g, j, dep);
454
+ return false ;
456
455
}
457
456
void handle_constant_term (term_o& t, unsigned j, u_dependency* dep) {
458
457
if (t.c ().is_zero ()) {
@@ -514,6 +513,7 @@ namespace lp {
514
513
// }
515
514
// }
516
515
// return change;
516
+ return false ;
517
517
}
518
518
519
519
void tighten_bound_for_term_for_bound_kind (term_o& t,
@@ -666,20 +666,20 @@ namespace lp {
666
666
667
667
unsigned f_rows_in_column =0 ;
668
668
for (const auto & c: column) {
669
- if (m_row_status [c.var ()] == row_status ::F)
669
+ if (m_eprime [c.var ()]. m_entry_status == entry_status ::F)
670
670
f_rows_in_column ++;
671
671
}
672
672
TRACE (" dioph_eq" , tout << " f_rows_in_column:" << f_rows_in_column << std::endl;);
673
673
while (column.size () > 1 && f_rows_in_column > 0 ) {
674
674
auto & c = column.back ();
675
- if (m_row_status [c.var ()] != row_status ::F)
675
+ if (m_eprime [c.var ()]. m_entry_status != entry_status ::F)
676
676
continue ;
677
677
f_rows_in_column--;
678
678
SASSERT (c.var () != piv_row_index);
679
679
mpq coeff = m_e_matrix.get_val (c);
680
680
TRACE (" dioph_eq" , tout << " c_row:" << c.var (); print_e_row (c.var (), tout) << std::endl;);
681
681
m_e_matrix.pivot_row_to_row_given_cell_with_sign (piv_row_index, c, j, j_sign);
682
- m_c [c.var ()] -= j_sign* coeff*m_c [piv_row_index];
682
+ m_eprime [c.var ()]. m_c -= j_sign* coeff*m_eprime [piv_row_index]. m_c ;
683
683
TRACE (" dioph_eq" , tout << " after pivoting c_row:" ; print_e_row (c.var (), tout) << std::endl;);
684
684
}
685
685
}
@@ -705,17 +705,17 @@ namespace lp {
705
705
unsigned fresh_row = m_e_matrix.row_count ();
706
706
m_e_matrix.add_row (); // for the fresh variable definition
707
707
m_e_matrix.add_column (); // the fresh variable itself
708
- m_row_status .push_back (row_status::S); // adding a new row to S
708
+ m_eprime .push_back ({fresh_row, term_o (), nullptr , mpq ( 0 ), entry_status::S});
709
709
// Add a new row for the fresh variable definition
710
710
/* Let eh = sum(ai*xi) + c. For each i != k, let ai = qi*ahk + ri, and let c = c_q * ahk + c_r.
711
711
eh = ahk*(x_k + sum{qi*xi|i != k} + c_q) + sum {ri*xi|i!= k} + c_r.
712
712
Then -xt + x_k + sum {qi*x_i)| i != k} + c_q will be the fresh row
713
713
eh = ahk*xt + sum {ri*x_i | i != k} + c_r is the row m_e_matrix[e.m_row_index]
714
714
*/
715
715
mpq q, r;
716
- q = machine_div_rem (m_c[h] , ahk, r);
717
- m_c[h] = r;
718
- m_c. push_back (q) ;
716
+ q = machine_div_rem (e. m_c , ahk, r);
717
+ e. m_c = r;
718
+ m_eprime. back (). m_c = q ;
719
719
m_e_matrix.add_new_element (h, xt, ahk);
720
720
m_e_matrix.add_new_element (fresh_row, xt, -mpq (1 ));
721
721
m_e_matrix.add_new_element (fresh_row, k, mpq (1 ));
@@ -755,8 +755,8 @@ namespace lp {
755
755
756
756
// k is the index of the index of the variable with the coefficient +-1 that is being substituted
757
757
void move_entry_from_f_to_s (unsigned k, std::list<unsigned >::iterator it) {
758
- SASSERT (m_row_status [*it] == row_status ::F);
759
- m_row_status [*it] = row_status ::S;
758
+ SASSERT (m_eprime [*it]. m_entry_status == entry_status ::F);
759
+ m_eprime [*it]. m_entry_status = entry_status ::S;
760
760
if (k >= m_k2s.size ()) { // k is a fresh variable
761
761
m_k2s.resize (k+1 , -1 );
762
762
}
0 commit comments