Skip to content

Commit 7ecac27

Browse files
committed
fix a bug in dio
1 parent b0383da commit 7ecac27

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/math/lp/dioph_eq.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ namespace lp {
233233
// {coeff*lar.get_term(k)})
234234

235235
std_vector<unsigned> m_k2s;
236-
std_vector<unsigned> m_fresh_definitions;
236+
std_vector<unsigned> m_fresh_definitions; // seems only needed in the debug
237+
// version in remove_fresh_vars
238+
237239
unsigned m_conflict_index = -1; // m_entries[m_conflict_index] gives the conflict
238240
unsigned m_max_number_of_iterations = 100;
239241
unsigned m_number_of_iterations;
@@ -302,7 +304,7 @@ namespace lp {
302304
void fill_entry(const lar_term& t) {
303305
TRACE("dioph_eq", print_lar_term_L(t, tout) << std::endl;);
304306
entry te = {lar_term(t.j()), mpq(0), entry_status::F};
305-
unsigned entry_index = (unsigned)m_entries.size();
307+
unsigned entry_index = m_entries.size();
306308
m_f.push_back(entry_index);
307309
m_entries.push_back(te);
308310
entry& e = m_entries.back();
@@ -926,10 +928,11 @@ namespace lp {
926928
}
927929
TRACE("dio_br", lra.print_column_info(b.m_j, tout) <<"add bound" << std::endl;);
928930
if (lra.column_is_fixed(b.m_j)) {
929-
unsigned local_b_mj;
930-
if (!m_var_register.external_is_used(b.m_j, local_b_mj))
931+
unsigned local_mj;
932+
if (! m_var_register.external_is_used(b.m_j, local_mj))
931933
return lia_move::undef;
932-
if (fix_var(local_b_mj) == lia_move::conflict) {
934+
935+
if (fix_var(lar_solver_to_local(b.m_j)) == lia_move::conflict) {
933936
TRACE("dio_br", tout << "conflict in fix_var" << std::endl;) ;
934937
return lia_move::conflict;
935938
}
@@ -1025,7 +1028,7 @@ namespace lp {
10251028
}
10261029

10271030
unsigned get_number_of_int_inf() const {
1028-
return (unsigned)std::count_if(
1031+
return std::count_if(
10291032
lra.r_basis().begin(), lra.r_basis().end(),
10301033
[this](unsigned j) {
10311034
return lia.column_is_int_inf(j);
@@ -1166,7 +1169,7 @@ namespace lp {
11661169
[ei](const auto& cell) {
11671170
return cell.var() == ei;
11681171
});
1169-
unsigned pivot_col_cell_index = (unsigned) std::distance(column.begin(), it);
1172+
unsigned pivot_col_cell_index = std::distance(column.begin(), it);
11701173
if (pivot_col_cell_index != 0) {
11711174
// swap the pivot column cell with the head cell
11721175
auto c = column[0];
@@ -1329,7 +1332,7 @@ namespace lp {
13291332
m_e_matrix.add_new_element(fresh_row, i, q);
13301333
}
13311334

1332-
m_k2s.resize(k + 1, -1);
1335+
m_k2s.resize(std::max(k + 1, xt + 1), -1);
13331336
m_k2s[k] = fresh_row;
13341337
m_fresh_definitions.resize(xt + 1, -1);
13351338
m_fresh_definitions[xt] = fresh_row;

0 commit comments

Comments
 (0)