5#ifndef DEJAVU_INPROCESS_H
6#define DEJAVU_INPROCESS_H
13namespace dejavu {
namespace search_strategy {
42 int depth = 8,
bool lower_depth =
true) {
43 constexpr int test_frac = 100;
51 int best_depth = depth;
55 for (
int i = 0; i < g->
v_size; ++i) {
61 const int col_sz = local_state.
c->
ptn[col] + 1;
62 if (col_sz >= 2 && col_sz != orbit_partition.
orbit_size(i)) {
67 if(test_frac * i < g->v_size && lower_depth && splits < best_depth &&
71 if(test_frac * i >= g->
v_size && lower_depth && best_depth < depth) {
82 for (
int i = 0; i < g->
v_size; ++i) inv[i] = inv[orbit_partition.
find_orbit(i)];
97 struct comparator_map {
98 std::vector<unsigned long> *map;
101 explicit comparator_map(std::vector<unsigned long> *m,
int* vertex_to_col) {
103 this->colmap = vertex_to_col;
106 bool operator()(
const int &a,
const int &b)
const {
107 return (colmap[a] < colmap[b]) || ((colmap[a] == colmap[b]) && ((*map)[a] < (*map)[b]));
110 auto c = comparator_map(map, colmap);
124 int num_of_hashs = 0;
125 for(
int i = 0; i < g->
v_size; ++i)
nodes.push_back(i);
127 unsigned long last_inv = -1;
129 for(
int i = 0; i < g->
v_size; ++i) {
130 const int v =
nodes[i];
131 const unsigned long v_inv = inv[v];
133 if(last_col != v_col) {
138 if(v_inv != last_inv) {
142 hash[v] = num_of_hashs;
149 struct comparator_map {
153 explicit comparator_map(
unsigned long *m,
int* vertex_to_col) {
155 this->colmap = vertex_to_col;
158 bool operator()(
const int &a,
const int &b)
const {
159 return (colmap[a] < colmap[b]) || ((colmap[a] == colmap[b]) && (map[a] < map[b]));
162 auto c = comparator_map(map, colmap);
174 constexpr int col_sz_upper_bound = 16;
175 constexpr int fixed_split_limit = 8;
182 for(
int _col = 0; _col < g->
v_size;) {
183 const int _col_sz = local_state.
c->
ptn[_col] + 1;
184 original_colors.
set(_col);
188 std::vector<int> col_buffer;
189 col_buffer.reserve(col_sz_upper_bound);
192 for(
int i = 0; i < g->
v_size; ++i) {
196 const int col_sz = local_state.
c->
ptn[col] + 1;
205 for(
int _col = 0; _col < g->
v_size;) {
206 const int _col_sz = local_state.
c->
ptn[_col] + 1;
208 if (_col_sz >= 2 && _col_sz <= col_sz_upper_bound && !original_colors.
get(_col)) {
211 for (
int jj = _col; jj < _col + _col_sz; ++jj) col_buffer.push_back(local_state.
c->
lab[jj]);
213 for (
int j : col_buffer) {
246 const int ind_v = i.first;
249 const int orb_sz_det = i.second;
250 if(ind_col_sz > 1 && ind_col_sz == orb_sz_det) {
271 bool use_shallow_inprocess,
bool use_shallow_quadratic_inprocess,
groups::orbit& orbit_partition) {
275 bool touched_coloring =
false;
279 if (use_shallow_inprocess && !(tree.
get_finished_up_to() >= 1 && use_bfs_inprocess)) {
280 bool changed =
false;
285 const int cell_last = local_state.
c->
cells;
291 for (
int i = 0; i < g->
v_size; ++i) inv[i] = 0;
295 const int cell_after = local_state.
c->
cells;
296 changed = cell_after != cell_last;
297 if (changed) local_state.
refine(g);
300 }
while(changed && g->
v_size != local_state.
c->
cells && its < 3);
304 if (use_shallow_quadratic_inprocess) {
310 for(
int i = 0; i < g->
v_size; ++i) inv[i] = 0;
314 const int cell_after = local_state.
c->
cells;
315 if (cell_after != cell_prev) {
330 int num_of_hashs = 0;
332 for(
int i = 0; i < g->
v_size; ++i)
nodes.push_back(i);
336 for(
int i = 0; i < g->
v_size; ++i) {
337 const int v =
nodes[i];
340 if(last_col != v_col) {
345 if(v_inv != last_inv) {
349 hash[v] = num_of_hashs;
353 const int cell_after = local_state.
c->
cells;
354 if (cell_after != cell_prev) {
364 const int ind_v = i.first;
373 const int ind_v = i.first;
375 const int ind_col_sz = local_state.
c->
ptn[ind_col] + 1;
376 const int orb_sz_det = i.second;
377 if(ind_col_sz > 1 && ind_col_sz == orb_sz_det) {
384 if(num_inds > 0) orbit_partition.
reset();
391 if(cell_prev != local_state.
c->
cells) {
393 touched_coloring =
true;
396 return touched_coloring;
void multiply(int number)
Set specialized for quick resets.
Fixed-size array, uninitialized.
Compressed Schreier structure.
void determine_potential_individualization(std::vector< std::pair< int, int > > *save_to_individualize, coloring *root_coloring)
int orbit_size(const int v)
dej_nodiscard bool represents_orbit(const int v) const
int find_orbit(const int v)
coloring * get_coloring()
void make_node_invariant()
void mark_first_level(markset &marks)
std::vector< unsigned long > * get_node_invariant()
dej_nodiscard int get_finished_up_to() const
dej_nodiscard unsigned long get_hash() const
void set_hash(unsigned long new_hash)
Inprocessing for symmetry detection.
void sort_nodes_map(std::vector< unsigned long > *map, int *colmap)
void split_with_invariant(sgraph *g, ir::controller &local_state, worklist_t< unsigned long > &inv)
std::vector< std::pair< int, int > > inproc_maybe_individualize
static void shallow_bfs_invariant2(sgraph *g, ir::controller &local_state, worklist_t< unsigned long > &inv)
std::vector< std::pair< int, int > > inproc_can_individualize
void set_splits_hint(int splits_hint)
std::vector< int > inproc_fixed_points
void sort_nodes_map(unsigned long *map, int *colmap)
bool inprocess(sgraph *g, ir::shared_tree &tree, groups::compressed_schreier &group, ir::controller &local_state, ir::limited_save &root_save, int, bool use_bfs_inprocess, bool use_shallow_inprocess, bool use_shallow_quadratic_inprocess, groups::orbit &orbit_partition)
static void shallow_bfs_invariant(sgraph *g, ir::controller &local_state, worklist_t< unsigned long > &inv, groups::orbit &orbit_partition, int depth=8, bool lower_depth=true)
int check_individualizations(ir::limited_save &root_save)
Internal graph data structure.
void initialize_coloring(ds::coloring *c, int *vertex_to_col)
Controls movement in IR tree.
std::vector< base_info > * compare_base
void use_increase_deviation(bool deviation_inc_active)
dej_nodiscard coloring * get_coloring() const
void save_reduced_state(limited_save &state)
void move_to_child(sgraph *g, int v)
void use_split_limit(bool use_split_limit, int limit=0)
void use_reversible(const bool reversible)
void use_trace_early_out(bool trace_early_out)
void move_to_child_no_trace(sgraph *g, int v)
void load_reduced_state(limited_save &state)
int get_number_of_splits()