3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 13:28:47 +00:00

fixes in indices in lar_solver::maximize_term()

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2019-03-03 10:57:25 -10:00
parent 3ee5c0e7d9
commit 06725de477
3 changed files with 12 additions and 12 deletions

View file

@ -3329,7 +3329,8 @@ public:
st = lp::lp_status::UNBOUNDED; st = lp::lp_status::UNBOUNDED;
} }
else { else {
st = m_solver->maximize_term(v, term_max); vi = m_theory_var2var_index[v];
st = m_solver->maximize_term(vi, term_max);
} }
switch (st) { switch (st) {
case lp::lp_status::OPTIMAL: { case lp::lp_status::OPTIMAL: {

View file

@ -505,24 +505,23 @@ bool lar_solver::remove_from_basis(unsigned j) {
return m_mpq_lar_core_solver.m_r_solver.remove_from_basis(j); return m_mpq_lar_core_solver.m_r_solver.remove_from_basis(j);
} }
lar_term lar_solver::get_term_to_maximize(unsigned ext_j) const { lar_term lar_solver::get_term_to_maximize(unsigned j_or_term) const {
unsigned local_j; if (is_term(j_or_term))
if (m_var_register.external_is_used(ext_j, local_j)) { return get_term(j_or_term);
if (j_or_term < m_mpq_lar_core_solver.m_r_x.size()) {
lar_term r; lar_term r;
r. add_monomial(one_of_type<mpq>(), local_j); r.add_monomial(one_of_type<mpq>(), j_or_term);
return r; return r;
} }
if (!is_term(ext_j) || adjust_term_index(ext_j) >= m_terms.size()) return lar_term(); // return an empty term
return lar_term(); // return an empty term
return get_term(ext_j);
} }
lp_status lar_solver::maximize_term(unsigned ext_j, lp_status lar_solver::maximize_term(unsigned j_or_term,
impq &term_max) { impq &term_max) {
TRACE("lar_solver", print_values(tout);); TRACE("lar_solver", print_values(tout););
bool was_feasible = m_mpq_lar_core_solver.m_r_solver.calc_current_x_is_feasible_include_non_basis(); bool was_feasible = m_mpq_lar_core_solver.m_r_solver.calc_current_x_is_feasible_include_non_basis();
impq prev_value; impq prev_value;
lar_term term = get_term_to_maximize(ext_j); lar_term term = get_term_to_maximize(j_or_term);
if (term.is_empty()) { if (term.is_empty()) {
return lp_status::UNBOUNDED; return lp_status::UNBOUNDED;
} }

View file

@ -310,7 +310,7 @@ public:
impq &term_max); impq &term_max);
// starting from a given feasible state look for the maximum of the term // starting from a given feasible state look for the maximum of the term
// return true if found and false if unbounded // return true if found and false if unbounded
lp_status maximize_term(unsigned ext_j , lp_status maximize_term(unsigned j_or_term,
impq &term_max); impq &term_max);