Orbiter 2022
Combinatorial Objects
orbit_based_testing.cpp
Go to the documentation of this file.
1// orbit_based_testing.cpp
2//
3// Anton Betten
4// November 19, 2018
5
7#include "discreta/discreta.h"
10
11using namespace std;
12
13namespace orbiter {
14namespace layer4_classification {
15namespace poset_classification {
16
17
19{
20 null();
21}
22
24{
25 freeself();
26}
27
29{
30 int i;
31
32 PC = NULL;
33 max_depth = 0;
34 local_S = NULL;
35 nb_callback = 0;
36 for (i = 0; i < MAX_CALLBACK; i++) {
37 callback_testing[i] = NULL;
38 callback_data[i] = NULL;
39 }
41 for (i = 0; i < MAX_CALLBACK; i++) {
43 callback_data_no_group[i] = NULL;
44 }
45}
46
48{
49 if (local_S) {
51 }
52 null();
53}
54
57 int max_depth,
58 int verbose_level)
59{
60 int f_v = (verbose_level >= 1);
61
62 if (f_v) {
63 cout << "orbit_based_testing::init" << endl;
64 }
68 if (f_v) {
69 cout << "orbit_based_testing::init done" << endl;
70 }
71}
72
74 int (*func)(orbit_based_testing *Obt,
75 long int *S, int len, void *data, int verbose_level),
76 void *data,
77 int verbose_level)
78{
79 int f_v = (verbose_level >= 1);
80
81 if (f_v) {
82 cout << "orbit_based_testing::add_callback" << endl;
83 }
87
88 if (f_v) {
89 cout << "orbit_based_testing::add_callback done" << endl;
90 }
91}
92
94 void (*func)(long int *S, int len,
95 long int *candidates, int nb_candidates,
96 long int *good_candidates, int &nb_good_candidates,
97 void *data, int verbose_level),
98 void *data,
99 int verbose_level)
100{
101 int f_v = (verbose_level >= 1);
102
103 if (f_v) {
104 cout << "orbit_based_testing::add_callback_no_group" << endl;
105 }
109
110 if (f_v) {
111 cout << "orbit_based_testing::add_callback_no_group done" << endl;
112 }
113}
114
116 long int *S, int len,
117 long int *candidates, int nb_candidates,
118 long int *good_candidates, int &nb_good_candidates,
119 int verbose_level)
120{
121 int f_v = (verbose_level >= 1);
122 //int f_vv = (verbose_level >= 2);
123
124 if (f_v) {
125 cout << "orbit_based_testing::early_test_func" << endl;
126 }
127 if (nb_callback) {
128 if (f_v) {
129 cout << "orbit_based_testing::early_test_func before early_test_func_by_using_group" << endl;
130 }
131
133 S, len,
134 candidates, nb_candidates,
135 good_candidates, nb_good_candidates,
136 verbose_level);
137
138 if (f_v) {
139 cout << "orbit_based_testing::early_test_func after early_test_func_by_using_group" << endl;
140 }
141 }
142 else if (nb_callback_no_group) {
143 if (nb_callback_no_group > 1) {
144 cout << "orbit_based_testing::early_test_func "
145 "nb_callback_no_group > 1" << endl;
146 exit(1);
147 }
148 if (f_v) {
149 cout << "orbit_based_testing::early_test_func nb_callback_no_group = " << nb_callback_no_group << endl;
150 }
151 if (f_v) {
152 cout << "orbit_based_testing::early_test_func before (*callback_testing_no_group[0])" << endl;
153 }
155 S, len,
156 candidates, nb_candidates,
157 good_candidates, nb_good_candidates,
158 callback_data_no_group[0], verbose_level);
159 if (f_v) {
160 cout << "orbit_based_testing::early_test_func after (*callback_testing_no_group[0])" << endl;
161 }
162 }
163 else {
164 if (f_v) {
165 cout << "orbit_based_testing::early_test_func no test function" << endl;
166 }
167 }
168 if (f_v) {
169 cout << "orbit_based_testing::early_test_func done" << endl;
170 }
171}
172
174 long int *S, int len,
175 long int *candidates, int nb_candidates,
176 long int *good_candidates, int &nb_good_candidates,
177 int verbose_level)
178{
179 int f_v = (verbose_level >= 1);
180 int f_vv = (verbose_level >= 2);
182
183 if (f_v) {
184 cout << "orbit_based_testing::early_test_func_by_using_group" << endl;
185 }
186
187 if (f_vv) {
188 cout << "S=";
189 Lint_vec_print(cout, S, len);
190 cout << " testing " << nb_candidates << " candidates" << endl;
191 //int_vec_print(cout, candidates, nb_candidates);
192 //cout << endl;
193 }
194
195 if (len >= max_depth) {
196 cout << "orbit_based_testing::early_test_func_by_using_group "
197 "len >= max_depth" << endl;
198 exit(1);
199 }
200 Lint_vec_copy(S, local_S, len);
201
202
203 int i, j, node, f, l, nb_good_orbits;
204 long int pt;
206 int f_orbit_is_good;
207 //int s, a;
208
210 FALSE /* f_tolerant */, 0);
211 O = PC->get_node(node);
212
213 if (f_v) {
214 cout << "orbit_based_testing::early_test_func_by_using_group for ";
215 O->print_set(PC);
216 cout << endl;
217 }
218
219 groups::schreier Schreier;
220
221 Schreier.init(PC->get_A2(), verbose_level - 2);
222
223
224#if 0
225 Schreier.init_generators_by_hdl(
226 O->nb_strong_generators, O->hdl_strong_generators, 0);
227#else
228 {
229 vector<int> gen_hdl;
230
231 O->get_strong_generators_handle(gen_hdl, verbose_level);
232 }
233#endif
234
235 if (f_v) {
236 cout << "orbit_based_testing::early_test_func_by_using_group "
237 "before Schreier.compute_all_orbits_on_invariant_subset" << endl;
238 }
240 nb_candidates, candidates,
241 0/*verbose_level*/);
242
243 if (f_v) {
244 cout << "orbit_based_testing::early_test_func_by_using_group "
245 "after Schreier.compute_all_orbits_on_invariant_subset, we found "
246 << Schreier.nb_orbits << " orbits" << endl;
247 }
248 nb_good_candidates = 0;
249 nb_good_orbits = 0;
250 for (i = 0; i < Schreier.nb_orbits; i++) {
251 f = Schreier.orbit_first[i];
252 l = Schreier.orbit_len[i];
253 pt = Schreier.orbit[f];
254 local_S[len] = pt;
255 f_orbit_is_good = TRUE;
256 if (f_v) {
257 cout << "orbit_based_testing::early_test_func_by_using_group "
258 "testing orbit " << i << " / " << Schreier.nb_orbits << " of length " << l << endl;
259 }
260 for (j = 0; j < nb_callback; j++) {
261 if (f_v) {
262 cout << "orbit_based_testing::early_test_func_by_using_group "
263 "testing orbit " << i << " / " << Schreier.nb_orbits << " of length " << l
264 << " calling test function " << j << " / " << nb_callback << endl;
265 }
266 if (!(*callback_testing[j])(this,
267 local_S, len + 1, callback_data[j], verbose_level - 1)) {
268 f_orbit_is_good = FALSE;
269 break;
270 }
271 }
272#if 0
273 if (f_linear) {
274 if (rc.check_rank_last_two_are_fixed(len + 1,
275 local_S, verbose_level - 1)) {
276 f_orbit_is_good = TRUE;
277 }
278 else {
279 f_orbit_is_good = FALSE;
280 }
281 }
282 else {
283 f_orbit_is_good = TRUE;
284 for (s = 0; s < len; s++) {
285 a = local_S[s];
286 if (Hamming_distance(a, pt) < d) {
287 f_orbit_is_good = FALSE;
288 break;
289 }
290 }
291 }
292#endif
293
294 if (f_orbit_is_good) {
295 for (j = 0; j < l; j++) {
296 pt = Schreier.orbit[f + j];
297 good_candidates[nb_good_candidates++] = pt;
298 }
299 nb_good_orbits++;
300 }
301 }
302
303 Sorting.lint_vec_heapsort(good_candidates, nb_good_candidates);
304 if (f_v) {
305 cout << "orbit_based_testing::early_test_func_by_using_group "
306 "after Schreier.compute_all_orbits_on_invariant_subset, "
307 "we found "
308 << nb_good_candidates << " good candidates in "
309 << nb_good_orbits << " good orbits" << endl;
310 }
311}
312
313}}}
314
315
316
317
318
319
a collection of functions related to sorted vectors
Schreier trees for orbits of groups on points.
Definition: groups.h:839
void orbits_on_invariant_subset_fast_lint(int len, long int *subset, int verbose_level)
Definition: schreier.cpp:1983
void init(actions::action *A, int verbose_level)
Definition: schreier.cpp:308
void init_generators_by_hdl(int nb_gen, int *gen_hdl, int verbose_level)
Definition: schreier.cpp:529
maintains a list of test functions which define a G-invariant poset
void(* callback_testing_no_group[MAX_CALLBACK])(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level)
void init(poset_classification *PC, int max_depth, int verbose_level)
void early_test_func_by_using_group(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, int verbose_level)
void early_test_func(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, int verbose_level)
void add_callback_no_group(void(*func)(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level), void *data, int verbose_level)
void add_callback(int(*func)(orbit_based_testing *Obt, long int *S, int len, void *data, int verbose_level), void *data, int verbose_level)
int(* callback_testing[MAX_CALLBACK])(orbit_based_testing *Obt, long int *S, int len, void *data, int verbose_level)
int find_poset_orbit_node_for_set(int len, long int *set, int f_tolerant, int verbose_level)
to represent one poset orbit; related to the class poset_classification
void get_strong_generators_handle(std::vector< int > &gen_hdl, int verbose_level)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
the orbiter library for the classification of combinatorial objects
#define MAX_CALLBACK