Skip to content

Commit b30272f

Browse files
committed
add missing explanations
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent e0a08f1 commit b30272f

File tree

1 file changed

+29
-36
lines changed

1 file changed

+29
-36
lines changed

src/math/lp/dioph_eq.cpp

+29-36
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ namespace lp {
508508
term_o term_to_tighten = lra.get_term(j); // copy the term aside
509509
std::queue<unsigned> q;
510510
for (const auto& p: term_to_tighten) {
511-
if (can_substitute(p.j()))
511+
if (can_substitute(p.j()) && !lra.column_is_fixed(p.j()))
512512
q.push(p.j());
513513
}
514514
if (q.empty()) {
@@ -549,23 +549,11 @@ namespace lp {
549549
}
550550

551551
void get_expl_from_meta_term(const lar_term& t, explanation& ex) {
552-
for (const auto& p: t) {
553-
const auto& l = lra.get_term(p.j());
554-
get_expl_from_lar_term(l, ex);
555-
}
552+
u_dependency *dep = explain_fixed_in_meta_term(t);
553+
for (constraint_index ci : lra.flatten(dep))
554+
ex.push_back(ci);
556555
}
557556

558-
void get_expl_from_lar_term(const lar_term & l, explanation& ex) {
559-
for (const auto& p: l) {
560-
if (lra.column_is_fixed(p.j())) {
561-
u_dependency* u = lra.get_bound_constraint_witnesses_for_column(p.j());
562-
for (const auto& ci: lra.flatten(u)) {
563-
ex.push_back(ci);
564-
}
565-
}
566-
}
567-
}
568-
569557
void handle_constant_term(unsigned j) {
570558
if (m_c.is_zero()) {
571559
return;
@@ -575,13 +563,21 @@ namespace lp {
575563
u_dependency *b_dep = nullptr;
576564
if (lra.has_upper_bound(j, b_dep, rs, is_strict)) {
577565
if (m_c > rs || (is_strict && m_c == rs)) {
578-
get_expl_from_meta_term(m_tmp_l, m_infeas_explanation);
566+
u_dependency* dep = lra.mk_join(explain_fixed(lra.get_term(j)), explain_fixed_in_meta_term(m_tmp_l));
567+
dep = lra.mk_join(dep, lra.get_bound_constraint_witnesses_for_column(j));
568+
for (constraint_index ci : lra.flatten(dep)) {
569+
m_infeas_explanation.push_back(ci);
570+
}
579571
return;
580572
}
581573
}
582574
if (lra.has_lower_bound(j, b_dep, rs, is_strict)) {
583575
if (m_c < rs || (is_strict && m_c == rs)) {
584-
get_expl_from_meta_term(m_tmp_l, m_infeas_explanation);
576+
u_dependency* dep = lra.mk_join(explain_fixed(lra.get_term(j)), explain_fixed_in_meta_term(m_tmp_l));
577+
dep = lra.mk_join(dep, lra.get_bound_constraint_witnesses_for_column(j));
578+
for (constraint_index ci : lra.flatten(dep)) {
579+
m_infeas_explanation.push_back(ci);
580+
}
585581
}
586582
}
587583
}
@@ -626,7 +622,10 @@ namespace lp {
626622
dep = lra.mk_join(dep, explain_fixed_in_meta_term(m_tmp_l));
627623
u_dependency* j_bound_dep = upper? lra.get_column_upper_bound_witness(j): lra.get_column_lower_bound_witness(j);
628624
dep = lra.mk_join(dep, j_bound_dep);
629-
TRACE("dioph_eq", tout << "jterm:"; print_lar_term_L(lra.get_term(j), tout) << "\ndep:"; print_dep(tout, dep) << std::endl;);
625+
dep = lra.mk_join(dep, explain_fixed(lra.get_term(j)));
626+
dep = lra.mk_join(dep, lra.get_bound_constraint_witnesses_for_column(j));
627+
TRACE("dioph_eq", tout << "jterm:"; print_lar_term_L(lra.get_term(j), tout) << "\ndep:"; print_dep(tout, dep) << std::endl;
628+
);
630629
lra.update_column_type_and_bound(j, kind, bound, dep);
631630
}
632631

@@ -636,11 +635,11 @@ namespace lp {
636635
for (const auto& p: t) {
637636
lar_term const& term = lra.get_term(p.j());
638637
for (const auto& q: term) {
639-
if (is_fixed(q.j())) {
640-
u_dependency* bound_dep = lra.get_bound_constraint_witnesses_for_column(q.j());
641-
dep = lra.mk_join(dep, bound_dep);
642-
}
638+
if (is_fixed(q.j()))
639+
dep = lra.mk_join(dep, lra.get_bound_constraint_witnesses_for_column(q.j()));
643640
}
641+
if (is_fixed(p.j()))
642+
dep = lra.mk_join(dep, lra.get_bound_constraint_witnesses_for_column(p.j()));
644643
}
645644
return dep;
646645
}
@@ -890,25 +889,27 @@ namespace lp {
890889
return print_eprime_entry(m_eprime[i], out, print_dep);
891890
}
892891

893-
std::ostream& print_eprime_entry(const eprime_entry& e, std::ostream& out, bool print_dep = true) {
892+
std::ostream& print_eprime_entry(const eprime_entry& e, std::ostream& out, bool need_print_dep = true) {
894893
out << "{\n";
895894
print_term_o(get_term_from_e_matrix(e.m_row_index), out << "\tm_e:") << ",\n";
896895
//out << "\tstatus:" << (int)e.m_entry_status;
897-
if (print_dep) {
896+
if (need_print_dep) {
898897
out << "\tm_l:{"; print_lar_term_L(e.m_l, out) << "}, ";
899-
print_ml(e.m_l, out<< " \topened m_l:") << "\n";
898+
print_ml(e.m_l, out<< " \tfixed expl of m_l:") << "\n";
899+
print_dep(out, explain_fixed_in_meta_term(e.m_l)) << std::endl;
900900
}
901901
switch (e.m_entry_status)
902902
{
903903
case entry_status::F:
904-
out << "\tF\n";
904+
out << "\tin F\n";
905905
break;
906906
case entry_status::S:
907-
out << "\tS\n";
907+
out << "\tin S\n";
908908
break;
909909
default:
910910
out << "\tNOSF\n";
911911
}
912+
out << "}\n";
912913
return out;
913914
}
914915

@@ -969,14 +970,6 @@ namespace lp {
969970
SASSERT(ex.empty());
970971
TRACE("dioph_eq", tout << "conflict:"; print_eprime_entry(m_conflict_index, tout, true) << std::endl;);
971972
auto & ep = m_eprime[m_conflict_index];
972-
/*
973-
for (const auto & pl : ep.m_l) {
974-
unsigned row_index = pl.j();
975-
for (const auto & p : lra.get_row(row_index))
976-
if (lra.column_is_fixed(p.var()))
977-
lra.explain_fixed_column(p.var(), ex);
978-
}
979-
*/
980973
for (auto ci: lra.flatten(eq_deps(ep.m_l))) {
981974
ex.push_back(ci);
982975
}

0 commit comments

Comments
 (0)