11namespace dejavu {
namespace search_strategy {
29 std::vector<int> heuristic_reroll;
47 std::vector<int> base;
50 local_state.
walk(g, start_from, base);
72 const unsigned long hash_c = local_state.
T->
get_hash() + hash_offset;
77 if (other_leaf ==
nullptr) {
86 gl_automorphism.
reset();
90 const int* lab = other_leaf->get_lab_or_base();
94 load_state_from_leaf(g, other_state, root_save, other_leaf);
99 const bool cert = local_state.
certify(g, gl_automorphism);
107 if(hook) (*hook)(g->
v_size, gl_automorphism.
p(), gl_automorphism.
nsupp(),
108 gl_automorphism.
supp());
111 bool sift = group.
sift(gl_schreierw, gl_automorphism, uniform);
112 gl_automorphism.
reset();
118 bool any_changed =
false;
120 const bool sift_changed = group.
sift_random(gl_schreierw, gl_automorphism, rng);
121 any_changed = sift_changed || any_changed;
122 fail -= !sift_changed;
130 gl_automorphism.
reset();
137 gl_automorphism.
reset();
176 rng(rgenerator), gl_printer(printer), gl_schreierw(schreier), gl_automorphism(automorphism)
202 if(other_leaf ==
nullptr) {
242 double progress_initial = 1.0 * s_cell_initial / g->
v_size;
246 int s_sifting_success = 0;
261 if(local_state.
s_base_pos <= could_start_from) {
262 while (local_state.
s_base_pos <= could_start_from) {
267 start_from = &my_own_save;
270 const double progress_now = 1.0 * s_cells_now / g->
v_size;
272 if(progress_now - progress_initial > 0.1) {
274 "base_pos", could_start_from,
276 progress_initial = progress_now;
280 const int start_from_base_pos = local_state.
s_base_pos;
289 const int col = (*selector)(local_state.
c, base_pos);
290 const int col_sz = local_state.
c->
ptn[col] + 1;
291 const int rand = rng() % col_sz;
292 int choose_pos = col + rand;
310 if(base_pos > start_from_base_pos + 1 && g->
v_size > 5000 && s_sifting_success >= 0 &&
317 if(col == v_base_col) {
323 int v = local_state.
c->
lab[choose_pos];
329 heuristic_reroll.clear();
330 for(
int i = 0; i < col_sz; ++i) {
331 heuristic_reroll.push_back(local_state.
c->
lab[col + i]);
334 if(!heuristic_reroll.empty()) {
335 const int rand_reroll = rng() %
static_cast<int>(heuristic_reroll.size());
336 v = heuristic_reroll[rand_reroll];
347 if(base_pos == target_level) {
361 if(base_pos == target_level) {
368 const bool sift = add_leaf_to_storage_and_group(g, hook, group, ir_tree.
stored_leaves, local_state,
369 other_state, *root_save, uniform);
370 s_sifting_success += sift?1:-1;
371 s_sifting_success += sift && !uniform?1:0;
372 s_sifting_success = std::max(std::min(s_sifting_success, 10), -10);
408 if((
s_paths & 0x000000FF) == 0x000000FE)
417 const int start_from_base_pos = base_pos;
421 const int col = (*selector)(local_state.
c, base_pos);
422 const int col_sz = local_state.
c->
ptn[col] + 1;
423 const int rand = rng() % col_sz;
424 int v = local_state.
c->
lab[col + rand];
429 if(base_pos == start_from_base_pos) {
441 if(base_pos == start_from_base_pos) {
448 add_leaf_to_storage_and_group(g, hook, group, ir_tree.
stored_leaves, local_state, other_state,
Workspace for sparse automorphisms.
void write_color_diff(const int *vertex_to_col, const int *col_to_vertex)
dej_nodiscard int nsupp() const
dej_nodiscard int * p() const
dej_nodiscard int * supp() const
Compressed Schreier structure.
double s_compression_ratio
dej_nodiscard bool deterministic_abort_criterion() const
bool sift(schreier_workspace &w, automorphism_workspace &automorphism, bool uniform=false)
bool is_in_base_orbit(const int base_pos, const int v)
dej_nodiscard int get_consecutive_success() const
dej_nodiscard int base_point(int pos) const
bool sift_random(schreier_workspace &w, automorphism_workspace &automorphism, random_source &rng)
dej_nodiscard int s_densegen() const
dej_nodiscard bool probabilistic_abort_criterion() const
dej_nodiscard int finished_up_to_level() const
dej_nodiscard int s_sparsegen() const
void reduce_to_unfinished(schreier_workspace &w, std::vector< int > &selection, int base_pos)
Auxiliary workspace used for Schreier computations.
coloring * get_coloring()
stored_leaf * lookup_leaf(unsigned long hash)
void add_leaf(unsigned long hash, coloring &c, std::vector< int > &base)
dej_nodiscard int get_finished_up_to() const
ir::tree_node * pick_node_from_level(const int level, int num)
shared_leaves stored_leaves
@ STORE_LAB
stores coloring of the leaf
@ STORE_BASE
stores only base of the leaf
int get_lab_or_base_size()
const int * get_lab_or_base()
dej_nodiscard stored_leaf_type get_store_type() const
dej_nodiscard int get_position() const
dej_nodiscard unsigned long get_hash() const
dej_nodiscard bool trace_equal() const
limited_save * get_save()
Random number generation.
IR search using random walks.
double s_rolling_first_level_success
static void specific_walk(sgraph *g, ir::shared_tree &ir_tree, ir::controller &local_state, std::vector< int > &base_vertex)
const int h_hash_col_limit
static bool h_almost_done(groups::compressed_schreier &group)
void random_walks_from_tree(sgraph *g, dejavu_hook *hook, std::function< ir::type_selector_hook > *selector, ir::shared_tree &ir_tree, groups::compressed_schreier &group, ir::controller &local_state, ir::controller &other_state, int fail_limit)
void random_walks(sgraph *g, dejavu_hook *hook, std::function< ir::type_selector_hook > *selector, ir::shared_tree &ir_tree, groups::compressed_schreier &group, ir::controller &local_state, ir::controller &other_state, int fail_limit)
random_ir(timed_print &printer, groups::schreier_workspace &schreier, groups::automorphism_workspace &automorphism, random_source &rgenerator)
int s_random_sift_success
void use_look_close(bool look_close=false)
Internal graph data structure.
Prints information to the console.
void progress_current_method(const std::string &print) const
Controls movement in IR tree.
std::vector< int > * compare_base_vertex
void link_compare(controller *state)
void save_reduced_state(limited_save &state)
void move_to_child(sgraph *g, int v)
void walk(sgraph *g, ir::limited_save &start_from, std::vector< int > &vertices)
void use_reversible(const bool reversible)
void use_trace_early_out(bool trace_early_out)
void load_reduced_state(limited_save &state)
void write_strong_invariant_quarter(const sgraph *g) const
int get_number_of_splits()
std::vector< int > base_vertex
void write_strong_invariant(const sgraph *g) const
bool certify(sgraph *g, groups::automorphism_workspace &automorphism)
std::function< void(int, const int *, int, const int *)> dejavu_hook