mirror of
https://github.com/Z3Prover/z3
synced 2025-07-23 04:38:53 +00:00
no calling cut_solver when there are bounded columns
Signed-off-by: Lev Nachmanson <levnach@hotmail.com> use special bounds inf find_cube for x+y, x-y Signed-off-by: Lev Nachmanson <levnach@hotmail.com> bug fixes in column patching, add stats to patching, restructure int_solver Signed-off-by: Lev Nachmanson <levnach@hotmail.com> comment out m_old_values from int_solver Signed-off-by: Lev Nachmanson <levnach@hotmail.com> avoid calling pivot_fixed_vars_from_basis() in int_solver Signed-off-by: Lev Nachmanson <levnach@hotmail.com> fix the return value from path_nbasic_columns Signed-off-by: Lev Nachmanson <levnach@hotmail.com> fix the return value from path_nbasic_columns Signed-off-by: Lev Nachmanson <levnach@hotmail.com> work in patch_columns Signed-off-by: Lev Nachmanson <levnach@hotmail.com> work on int_solver check() Signed-off-by: Lev Nachmanson <levnach@hotmail.com> exit from find_free_interval() when l >= u Signed-off-by: Lev Nachmanson <levnach@hotmail.com> experiment with branching on nbasic columns Signed-off-by: Lev Nachmanson <levnach@hotmail.com> remove m_old_values Signed-off-by: Lev Nachmanson <levnach@hotmail.com> add rounding to patch_columns Signed-off-by: Lev Nachmanson <levnach@hotmail.com> qflia Signed-off-by: Lev Nachmanson <levnach@hotmail.com> patch all columns, round non-patched, branch or basic columns Signed-off-by: Lev Nachmanson <levnach@hotmail.com> refactor int_solver::check() Signed-off-by: Lev Nachmanson <levnach@hotmail.com> restore move_non_basic_columns_to_bounds() after a failure in find_cube() Signed-off-by: Lev Nachmanson <levnach@hotmail.com> optimize gomory cuts search Signed-off-by: Lev Nachmanson <levnach@hotmail.com> produce gomory cuts without moving columns to bounds Signed-off-by: Lev Nachmanson <levnach@hotmail.com> call find_feasible_solution() after moving columns Signed-off-by: Lev Nachmanson <levnach@hotmail.com> alway move colums to bounds before gomory cut Signed-off-by: Lev Nachmanson <levnach@hotmail.com> merge from best branch Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
7e82ab595e
commit
c04bcb411d
13 changed files with 341 additions and 276 deletions
|
@ -30,14 +30,14 @@ class lar_solver;
|
|||
template <typename T, typename X>
|
||||
struct lp_constraint;
|
||||
enum class lia_move {
|
||||
ok,
|
||||
branch,
|
||||
cut,
|
||||
conflict,
|
||||
continue_with_check,
|
||||
give_up,
|
||||
unsat
|
||||
};
|
||||
sat,
|
||||
branch,
|
||||
cut,
|
||||
conflict,
|
||||
continue_with_check,
|
||||
undef,
|
||||
unsat
|
||||
};
|
||||
|
||||
struct explanation {
|
||||
vector<std::pair<mpq, constraint_index>> m_explanation;
|
||||
|
@ -52,11 +52,13 @@ struct explanation {
|
|||
class int_solver {
|
||||
public:
|
||||
// fields
|
||||
lar_solver *m_lar_solver;
|
||||
int_set m_old_values_set;
|
||||
vector<impq> m_old_values_data;
|
||||
unsigned m_branch_cut_counter;
|
||||
cut_solver m_cut_solver;
|
||||
lar_solver * m_lar_solver;
|
||||
unsigned m_branch_cut_counter;
|
||||
cut_solver m_cut_solver;
|
||||
lar_term* m_t; // the term to return in the cut
|
||||
mpq *m_k; // the right side of the cut
|
||||
explanation *m_ex; // the conflict explanation
|
||||
bool *m_upper; // we have a cut m_t*x <= k if m_upper is true nad m_t*x >= k otherwise
|
||||
// methods
|
||||
int_solver(lar_solver* lp);
|
||||
|
||||
|
@ -69,7 +71,7 @@ private:
|
|||
|
||||
// how to tighten bounds for integer variables.
|
||||
|
||||
bool gcd_test_for_row(static_matrix<mpq, numeric_pair<mpq>> & A, unsigned i, explanation &);
|
||||
bool gcd_test_for_row(static_matrix<mpq, numeric_pair<mpq>> & A, unsigned i);
|
||||
|
||||
// gcd test
|
||||
// 5*x + 3*y + 6*z = 5
|
||||
|
@ -79,25 +81,17 @@ private:
|
|||
// this is unsolvable because 5/3 is not an integer.
|
||||
// so we create a lemma that rules out this condition.
|
||||
//
|
||||
bool gcd_test(explanation & ); // returns false in case of failure. Creates a theory lemma in case of failure.
|
||||
|
||||
// create goromy cuts
|
||||
// either creates a conflict or a bound.
|
||||
|
||||
// branch and bound:
|
||||
// decide what to branch and bound on
|
||||
// creates a fresh inequality.
|
||||
bool gcd_test(); // returns false in case of failure. Creates a theory lemma in case of failure.
|
||||
|
||||
bool branch(const lp_constraint<mpq, mpq> & new_inequality);
|
||||
bool ext_gcd_test(const row_strip<mpq>& row,
|
||||
mpq const & least_coeff,
|
||||
mpq const & lcm_den,
|
||||
mpq const & consts,
|
||||
explanation & ex);
|
||||
void fill_explanation_from_fixed_columns(const row_strip<mpq> & row, explanation &);
|
||||
void add_to_explanation_from_fixed_or_boxed_column(unsigned j, explanation &);
|
||||
void patch_int_infeasible_non_basic_column(unsigned j);
|
||||
void patch_int_infeasible_nbasic_columns();
|
||||
mpq const & consts);
|
||||
void fill_explanation_from_fixed_columns(const row_strip<mpq> & row);
|
||||
void add_to_explanation_from_fixed_or_boxed_column(unsigned j);
|
||||
void patch_nbasic_column(unsigned j);
|
||||
lia_move patch_nbasic_columns();
|
||||
bool get_freedom_interval_for_column(unsigned j, bool & inf_l, impq & l, bool & inf_u, impq & u, mpq & m);
|
||||
const impq & lower_bound(unsigned j) const;
|
||||
const impq & upper_bound(unsigned j) const;
|
||||
|
@ -111,7 +105,6 @@ private:
|
|||
void set_value_for_nbasic_column(unsigned j, const impq & new_val);
|
||||
void set_value_for_nbasic_column_ignore_old_values(unsigned j, const impq & new_val);
|
||||
bool non_basic_columns_are_at_bounds() const;
|
||||
void failed();
|
||||
bool is_feasible() const;
|
||||
const impq & get_value(unsigned j) const;
|
||||
bool column_is_int_inf(unsigned j) const;
|
||||
|
@ -122,11 +115,10 @@ private:
|
|||
lp_settings& settings();
|
||||
bool move_non_basic_columns_to_bounds();
|
||||
void branch_infeasible_int_var(unsigned);
|
||||
lia_move mk_gomory_cut(lar_term& t, mpq& k,explanation & ex, unsigned inf_col, const row_strip<mpq>& row);
|
||||
lia_move report_conflict_from_gomory_cut(mpq & k);
|
||||
void adjust_term_and_k_for_some_ints_case_gomory(lar_term& t, mpq& k, mpq& lcm_den);
|
||||
void init_check_data();
|
||||
lia_move proceed_with_gomory_cut(lar_term& t, mpq& k, explanation& ex, unsigned j, bool & upper);
|
||||
lia_move mk_gomory_cut(unsigned inf_col, const row_strip<mpq>& row);
|
||||
lia_move report_conflict_from_gomory_cut();
|
||||
void adjust_term_and_k_for_some_ints_case_gomory(mpq& lcm_den);
|
||||
lia_move proceed_with_gomory_cut(unsigned j);
|
||||
int find_free_var_in_gomory_row(const row_strip<mpq>& );
|
||||
bool is_gomory_cut_target(const row_strip<mpq>&);
|
||||
bool at_bound(unsigned j) const;
|
||||
|
@ -147,19 +139,19 @@ public:
|
|||
return n.x - floor(n.x);
|
||||
}
|
||||
private:
|
||||
void real_case_in_gomory_cut(const mpq & a, unsigned x_j, mpq & k, lar_term& t, explanation & ex, const mpq& f_0, const mpq& one_minus_f_0);
|
||||
void int_case_in_gomory_cut(const mpq & a, unsigned x_j, mpq & k, lar_term& t, explanation& ex, mpq & lcm_den, const mpq& f_0, const mpq& one_minus_f_0);
|
||||
void real_case_in_gomory_cut(const mpq & a, unsigned x_j, const mpq& f_0, const mpq& one_minus_f_0);
|
||||
void int_case_in_gomory_cut(const mpq & a, unsigned x_j, mpq & lcm_den, const mpq& f_0, const mpq& one_minus_f_0);
|
||||
constraint_index column_upper_bound_constraint(unsigned j) const;
|
||||
constraint_index column_lower_bound_constraint(unsigned j) const;
|
||||
void display_row_info(std::ostream & out, unsigned row_index) const;
|
||||
void gomory_cut_adjust_t_and_k(vector<std::pair<mpq, unsigned>> & pol, lar_term & t, mpq &k, bool num_ints, mpq &lcm_den);
|
||||
bool current_solution_is_inf_on_cut(const lar_term& t, const mpq& k) const;
|
||||
bool current_solution_is_inf_on_cut() const;
|
||||
public:
|
||||
bool shift_var(unsigned j, unsigned range);
|
||||
private:
|
||||
unsigned random();
|
||||
bool has_inf_int() const;
|
||||
lia_move create_branch_on_column(int j, lar_term& t, mpq& k, bool free_column, bool & upper);
|
||||
lia_move create_branch_on_column(int j);
|
||||
void catch_up_in_adding_constraints_to_cut_solver();
|
||||
public:
|
||||
template <typename T>
|
||||
|
@ -168,7 +160,7 @@ public:
|
|||
void get_int_coeffs_from_constraint(const lar_base_constraint* c, vector<cut_solver::monomial>& coeff, T & rs);
|
||||
bool is_term(unsigned j) const;
|
||||
void add_constraint_to_cut_solver(unsigned,const lar_base_constraint*);
|
||||
void copy_explanations_from_cut_solver(explanation &);
|
||||
void copy_explanations_from_cut_solver();
|
||||
void pop(unsigned);
|
||||
void push();
|
||||
void copy_values_from_cut_solver();
|
||||
|
@ -177,5 +169,11 @@ public:
|
|||
bool tighten_terms_for_cube();
|
||||
bool tighten_term_for_cube(unsigned);
|
||||
unsigned column_count() const;
|
||||
bool all_columns_are_bounded() const;
|
||||
impq get_cube_delta_for_term(const lar_term&) const;
|
||||
void find_feasible_solution();
|
||||
int find_inf_int_nbasis_column() const;
|
||||
lia_move run_gcd_test();
|
||||
lia_move call_cut_solver();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue