Skip to content

Commit d766292

Browse files
add seed parameter, fix trail undo order from insertion to ensure lifetime
1 parent b44c897 commit d766292

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/ast/simplifiers/randomizer.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Module Name:
2222
#include "ast/ast_pp.h"
2323
#include "ast/simplifiers/dependent_expr_state.h"
2424
#include "util/obj_hashtable.h"
25+
#include "params/tactic_params.hpp"
2526
#include <algorithm>
2627

2728
class randomizer_simplifier : public dependent_expr_simplifier {
@@ -40,13 +41,13 @@ class randomizer_simplifier : public dependent_expr_simplifier {
4041
std::string rand_name = f->get_name().str() + "_rand_" + std::to_string(m_rand());
4142
symbol new_sym(rand_name.c_str());
4243
r = m.mk_func_decl(new_sym, f->get_arity(), f->get_domain(), f->get_range());
43-
m_rename.insert(f, r);
4444
m_ast_trail.push_back(r);
4545
m_ast_trail.push_back(f);
46-
47-
m_trail.push(insert_obj_map(m_rename, f));
46+
m_rename.insert(f, r);
47+
4848
m_trail.push(push_back_vector(m_ast_trail));
4949
m_trail.push(push_back_vector(m_ast_trail));
50+
m_trail.push(insert_obj_map(m_rename, f));
5051

5152

5253
m_args.reset();
@@ -115,7 +116,8 @@ class randomizer_simplifier : public dependent_expr_simplifier {
115116
public:
116117
randomizer_simplifier(ast_manager& m, params_ref const & p, dependent_expr_state& fmls)
117118
: dependent_expr_simplifier(m, fmls), m(m), m_ast_trail(m), m_new_exprs(m) {
118-
// set m_rand reading from parameter?
119+
tactic_params tp(p);
120+
m_rand.set_seed(tp.randomizer_seed()); // set random seed from parameter
119121
}
120122

121123
char const* name() const override { return "randomizer"; }

src/params/tactic_params.pyg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def_module_params('tactic',
1111
('propagate_values.max_rounds', UINT, 4, "maximal number of rounds to propagate values."),
1212
('lia2card.max_range', UINT, 100, "maximal range of integers to compilation into Booleans"),
1313
('lia2card.max_ite_nesting', UINT, 4, "maximal nesting depth for ite expressions to be compiled into PB constraints"),
14+
('randomizer.seed', UINT, 0, "seed for randomizer pre-processor"),
1415
('default_tactic', SYMBOL, '', "overwrite default tactic in strategic solver"),
1516

1617
# ('aig.per_assertion', BOOL, True, "process one assertion at a time"),

0 commit comments

Comments
 (0)