3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-19 19:02:02 +00:00

add a config parameter to grobner

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2020-01-08 17:26:04 -08:00
parent cca19ef1a7
commit d1e9998332
6 changed files with 19 additions and 13 deletions

View file

@ -70,11 +70,9 @@ namespace dd {
} }
// some of the config fields are set, others are calculated
void solver::set_thresholds() { void solver::set_thresholds() {
IF_VERBOSE(3, verbose_stream() << "start saturate\n"; display_statistics(verbose_stream())); IF_VERBOSE(3, verbose_stream() << "start saturate\n"; display_statistics(verbose_stream()));
if (m_to_simplify.size() == 0)
return;
m_config.m_eqs_threshold = 10 * ceil(log(m_to_simplify.size()))*m_to_simplify.size();
m_config.m_expr_size_limit = 0; m_config.m_expr_size_limit = 0;
m_config.m_expr_degree_limit = 0; m_config.m_expr_degree_limit = 0;
for (equation* e: m_to_simplify) { for (equation* e: m_to_simplify) {
@ -89,9 +87,9 @@ namespace dd {
verbose_stream() << "set m_config.m_expr_degree_limit to " << m_config.m_expr_degree_limit << "\n"; verbose_stream() << "set m_config.m_expr_degree_limit to " << m_config.m_expr_degree_limit << "\n";
); );
m_config.m_max_steps = 700; m_config.m_max_steps = 700;
m_config.m_max_simplified = 7000; m_config.m_max_simplified = 7000;
} }
void solver::saturate() { void solver::saturate() {
simplify(); simplify();
init_saturate(); init_saturate();

View file

@ -55,6 +55,7 @@ public:
unsigned m_max_simplified; unsigned m_max_simplified;
unsigned m_random_seed; unsigned m_random_seed;
bool m_enable_exlin; bool m_enable_exlin;
unsigned m_eqs_growth;
config() : config() :
m_eqs_threshold(UINT_MAX), m_eqs_threshold(UINT_MAX),
m_expr_size_limit(UINT_MAX), m_expr_size_limit(UINT_MAX),

View file

@ -1425,18 +1425,21 @@ void core::run_pdd_grobner() {
// configure grobner // configure grobner
// TBD: move this code somewhere self-contained, and tune it. // TBD: move this code somewhere self-contained, and tune it.
double tree_size = 100; double tree_size = 100;
unsigned gr_eq_size = 0;
for (auto* e : m_pdd_grobner.equations()) { for (auto* e : m_pdd_grobner.equations()) {
tree_size = std::max(tree_size, e->poly().tree_size()); tree_size = std::max(tree_size, e->poly().tree_size());
gr_eq_size ++;
} }
tree_size *= 10; tree_size *= 10;
struct dd::solver::config cfg; struct dd::solver::config cfg;
cfg.m_expr_size_limit = (unsigned)tree_size; cfg.m_expr_size_limit = (unsigned)tree_size;
cfg.m_eqs_threshold = m_pdd_grobner.equations().size()*5; cfg.m_max_steps = gr_eq_size;
cfg.m_max_steps = m_pdd_grobner.equations().size(); cfg.m_eqs_threshold = m_nla_settings.grobner_eqs_growth() * ceil(log(gr_eq_size + 1)) * gr_eq_size;;
m_pdd_grobner.set(cfg); m_pdd_grobner.set(cfg);
m_pdd_grobner.set_thresholds();
m_pdd_manager.set_max_num_nodes(10000); // or something proportional to the number of initial nodes. m_pdd_manager.set_max_num_nodes(10000); // or something proportional to the number of initial nodes.
m_pdd_grobner.set_thresholds();
m_pdd_grobner.saturate(); m_pdd_grobner.saturate();
bool conflict = false; bool conflict = false;
for (auto eq : m_pdd_grobner.equations()) { for (auto eq : m_pdd_grobner.equations()) {

View file

@ -4,11 +4,11 @@ def_module_params('nla',
('order', BOOL, True, 'run order lemmas'), ('order', BOOL, True, 'run order lemmas'),
('tangents', BOOL, True, 'run tangent lemmas'), ('tangents', BOOL, True, 'run tangent lemmas'),
('horner', BOOL, True, 'run horner\'s heuristic'), ('horner', BOOL, True, 'run horner\'s heuristic'),
('horner_subs_fixed', BOOL, True, 'substitute fixed variables by constants'), ('horner_subs_fixed', BOOL, False, 'substitute fixed variables by constants'),
('horner_frequency', UINT, 4, 'horner\'s call frequency'), ('horner_frequency', UINT, 4, 'horner\'s call frequency'),
('horner_row_length_limit', UINT, 10, 'row is disregarded by the heuristic if its length is longer than the value'), ('horner_row_length_limit', UINT, 10, 'row is disregarded by the heuristic if its length is longer than the value'),
('grobner', BOOL, True, 'run grobner\'s basis heuristic'), ('grobner', BOOL, True, 'run grobner\'s basis heuristic'),
('grobner_eqs_threshold', UINT, 512, 'grobner\'s maximum number of equalities'), ('grobner_eqs_growth', UINT, 10, 'grobner\'s maximum number of equalities'),
('grobner_subs_fixed', BOOL, False, 'substitute fixed variables by constants') ('grobner_subs_fixed', BOOL, False, 'substitute fixed variables by constants')
)) ))

View file

@ -29,9 +29,10 @@ class nla_settings {
unsigned m_horner_row_length_limit; unsigned m_horner_row_length_limit;
bool m_horner_subs_fixed; bool m_horner_subs_fixed;
// grobner fields // grobner fields
bool m_run_grobner; bool m_run_grobner;
unsigned m_grobner_row_length_limit; unsigned m_grobner_row_length_limit;
bool m_grobner_subs_fixed; bool m_grobner_subs_fixed;
unsigned m_grobner_eqs_growth;
public: public:
nla_settings() : m_run_order(true), nla_settings() : m_run_order(true),
m_run_tangents(true), m_run_tangents(true),
@ -43,7 +44,8 @@ public:
m_grobner_row_length_limit(50), m_grobner_row_length_limit(50),
m_grobner_subs_fixed(false) m_grobner_subs_fixed(false)
{} {}
unsigned grobner_eqs_growth() const { return m_grobner_eqs_growth;}
unsigned& grobner_eqs_growth() { return m_grobner_eqs_growth;}
bool run_order() const { return m_run_order; } bool run_order() const { return m_run_order; }
bool& run_order() { return m_run_order; } bool& run_order() { return m_run_order; }

View file

@ -456,6 +456,8 @@ class theory_lra::imp {
m_nla->get_core()->m_nla_settings.horner_row_length_limit() = nla.horner_row_length_limit(); m_nla->get_core()->m_nla_settings.horner_row_length_limit() = nla.horner_row_length_limit();
m_nla->get_core()->m_nla_settings.run_grobner() = nla.grobner(); m_nla->get_core()->m_nla_settings.run_grobner() = nla.grobner();
m_nla->get_core()->m_nla_settings.grobner_subs_fixed() = nla.grobner_subs_fixed(); m_nla->get_core()->m_nla_settings.grobner_subs_fixed() = nla.grobner_subs_fixed();
m_nla->get_core()->m_nla_settings.grobner_eqs_growth() = nla.grobner_eqs_growth();
} }
} }