Orbiter 2022
Combinatorial Objects
hall_system_classify.cpp
Go to the documentation of this file.
1/*
2 * hall_system_classify.cpp
3 *
4 * Created on: Nov 6, 2019
5 * Author: anton
6 */
7
8
9
10
11#include "orbiter.h"
12
13using namespace std;
14
15namespace orbiter {
16namespace layer5_applications {
17namespace apps_combinatorics {
18
19
20static void hall_system_print_set(std::ostream &ost, int len, long int *S, void *data);
21static void hall_system_early_test_function(long int *S, int len,
22 long int *candidates, int nb_candidates,
23 long int *good_candidates, int &nb_good_candidates,
24 void *data, int verbose_level);
25
26
28{
29 null();
30}
31
33{
34 freeself();
35}
36
38{
39 //e = 0;
40 n = 0;
41 nm1 = 0;
42 nb_pairs = 0;
46 depth = 0;
47 N = 0;
48 N0 = 0;
49 triples = NULL;
50 row_sum = NULL;
51 pair_covering = NULL;
52 A = NULL;
53 A_on_triples = NULL;
56 Orbits_on_triples = NULL;
57 A_on_orbits = NULL;
59 S = NULL;
60 prefix[0] = 0;
62 Poset = NULL;
63 Control = NULL;
64 PC = NULL;
65}
66
68{
69 int verbose_level = 1;
70 int f_v = (verbose_level >= 1);
71
72 if (triples) {
74 }
75 if (row_sum) {
77 }
78 if (pair_covering) {
80 }
81 if (A) {
83 }
84 if (A_on_triples) {
86 }
89 }
92 }
95 }
96 if (A_on_orbits) {
98 }
99 if (S) {
100 FREE_OBJECT(S);
101 }
102 if (Control) {
104 }
105 if (Poset) {
107 }
108 if (PC) {
110 }
111 null();
112 if (f_v) {
113 cout << "hall_system::freeself done" << endl;
114 }
115}
116
117
119 int argc, const char **argv,
120 int n, int depth,
121 int verbose_level)
122{
123 int f_v = (verbose_level >= 1);
124 int i;
126
127 if (f_v) {
128 cout << "hall_system_classify::init" << endl;
129 }
132 //n = i_power_j(3, e);
133 nm1 = n - 1;
134 nb_pairs = nm1 / 2;
135 nb_pairs2 = (nm1 * (nm1 - 1)) / 2;
136 nb_blocks_overall = (n * (n - 1)) >> 1;
139 N0 = (nb_pairs * (nb_pairs - 1) * (nb_pairs - 2)) / 6 * 4;
140 N = N0 * 2;
141
142 char str[1000];
143 sprintf(str, "hall_%d", n);
144 prefix.assign(str);
145
146 if (f_v) {
147 cout << "hall_system_classify::init n=" << n << endl;
148 cout << "hall_system_classify::init nb_pairs=" << nb_pairs << endl;
149 cout << "hall_system_classify::init nb_pairs2=" << nb_pairs2 << endl;
150 cout << "hall_system_classify::init N0=" << N0 << endl;
151 cout << "hall_system_classify::init N=" << N << endl;
152 cout << "hall_system_classify::init nb_blocks_overall=" << nb_blocks_overall << endl;
153 cout << "hall_system_classify::init nb_blocks_needed=" << nb_blocks_needed << endl;
154 cout << "hall_system_classify::init nb_orbits_needed=" << nb_orbits_needed << endl;
155 }
156
157 triples = NEW_lint(N * 3);
160
161 if (f_v) {
162 cout << "hall_system_classify::init before computing triples" << endl;
163 }
164 for (i = 0; i < N; i++) {
165 if (f_v) {
166 cout << "triple " << i << " / " << N << ":" << endl;
167 }
168 unrank_triple(triples + i * 3, i);
169 if (f_v) {
170 Lint_vec_print(cout, triples + i * 3, 3);
171 cout << endl;
172 }
173 Sorting.lint_vec_heapsort(triples + i * 3, 3);
174 }
175 if (f_v) {
176 cout << "sorted:" << endl;
177 for (i = 0; i < N; i++) {
178 Lint_vec_print(cout, triples + i * 3, 3);
179 cout << endl;
180 }
181 }
182
183
184 if (f_v) {
185 cout << "hall_system_classify::init "
186 "before A->init_permutation_group" << endl;
187 }
189 int f_no_base = FALSE;
190
191 A->init_symmetric_group(nm1 /* degree */, f_no_base, verbose_level - 1);
192
193 //A->init_permutation_group(nm1 /* degree */, verbose_level - 1);
194 if (f_v) {
195 cout << "hall_system_classify::init "
196 "after A->init_permutation_group" << endl;
197 }
198
199 if (f_v) {
200 cout << "hall_system_classify::init "
201 "creating Strong_gens_Hall_reflection" << endl;
202 }
203
204 int degree; // nb_pairs * 2
205
209 nb_pairs, degree, verbose_level);
210
211
212 if (f_v) {
213 cout << "hall_system_classify::init "
214 "creating Strong_gens_normalizer" << endl;
215 }
216
220 nb_pairs, degree, verbose_level);
221
222 if (f_v) {
223 cout << "hall_system_classify::init "
224 "before Strong_gens->create_sims" << endl;
225 }
226 S = Strong_gens_normalizer->create_sims(verbose_level - 1);
227 if (f_v) {
228 cout << "hall_system_classify::init "
229 "after Strong_gens->create_sims" << endl;
230 }
231
233 if (f_v) {
234 cout << "hall_system_classify::init "
235 "before A_on_triples->induced_action_on_sets" << endl;
236 }
237 A_on_triples->induced_action_on_sets(*A, S /*sims *old_G*/,
238 N /* nb_sets*/, 3 /* set_size */, triples,
239 FALSE /* f_induce_action*/, verbose_level - 1);
240 if (f_v) {
241 cout << "hall_system_classify::init "
242 "after A2->induced_action_on_sets" << endl;
243 }
244
245 if (f_v) {
246 cout << "hall_system_classify::init "
247 "before orbits_on_triples" << endl;
248 }
249 orbits_on_triples(verbose_level);
250 if (f_v) {
251 cout << "hall_system_classify::init "
252 "after orbits_on_triples" << endl;
253 }
254
255
257 if (f_v) {
258 cout << "hall_system_classify::init "
259 "before Poset->init_subset_lattice" << endl;
260 }
263 verbose_level);
264 if (f_v) {
265 cout << "hall_system_classify::init "
266 "after Poset->init_subset_lattice" << endl;
267 }
269 hall_system_early_test_function,
270 this /* void *data */,
271 verbose_level);
272
274 Poset->print_function = hall_system_print_set;
275 Poset->print_function_data = (void *) this;
276
277
280 //PC->read_arguments(argc, argv, 0);
281 if (f_v) {
282 cout << "hall_system_classify::init before PC->initialize_and_allocate_root_node" << endl;
283 }
285 if (f_v) {
286 cout << "hall_system_classify::init after PC->initialize_and_allocate_root_node" << endl;
287 }
288
289
290 int depth_completed;
291 int f_use_invariant_subset_if_available = TRUE;
292 int f_debug = FALSE;
293 int schreier_depth = INT_MAX;
294 int t0;
296
297 t0 = Os.os_ticks();
298
299 if (f_v) {
300 cout << "hall_system_classify::init_generator "
301 "before PC->main" << endl;
302 }
303 depth_completed = PC->main(t0, schreier_depth,
304 f_use_invariant_subset_if_available,
305 f_debug,
306 verbose_level);
307 if (f_v) {
308 cout << "hall_system_classify::init_generator "
309 "after PC->main" << endl;
310 }
311 cout << "hall_system_classify returns "
312 "depth_completed=" << depth_completed << endl;
313
314 if (f_v) {
315 cout << "hall_system_classify::init done" << endl;
316 }
317}
318
320{
321 int f_v = (verbose_level >= 1);
323
324 if (f_v) {
325 cout << "hall_system_classify::orbits_on_triples" << endl;
326 }
327
329 fname_orbits_on_triples.append("_orbits_on_triples.bin");
330
331 if (Fio.file_size(fname_orbits_on_triples) > 0) {
332
333
334 if (f_v) {
335 cout << "hall_system_classify::orbits_on_triples "
336 "reading orbits from file "
337 << fname_orbits_on_triples << endl;
338 }
339
341
342 Orbits_on_triples->init(A_on_triples, verbose_level - 2);
345 *Strong_gens_Hall_reflection->gens, verbose_level - 2);
346 {
347 ifstream fp(fname_orbits_on_triples);
348 Orbits_on_triples->read_from_file_binary(fp, verbose_level);
349 }
350 if (f_v) {
351 cout << "hall_system_classify::orbits_on_triples "
352 "read orbits from file "
353 << fname_orbits_on_triples << endl;
354 }
355 }
356 else {
357
358 if (f_v) {
359 cout << "hall_system_classify::orbits_on_triples "
360 "computing orbits of the selected group" << endl;
361 }
362
365 A_on_triples, 0 /*verbose_level*/);
366
367 if (f_v) {
368 cout << "hall_system_classify::orbits_on_triples "
369 "computing orbits done" << endl;
370 cout << "We found " << Orbits_on_triples->nb_orbits
371 << " orbits of the selected group on lines" << endl;
372 }
373
374
375 {
376 ofstream fp(fname_orbits_on_triples);
377 Orbits_on_triples->write_to_file_binary(fp, verbose_level);
378 }
379 cout << "Written file " << fname_orbits_on_triples << " of size "
380 << Fio.file_size(fname_orbits_on_triples) << endl;
381 }
382
383 if (f_v) {
384 cout << "Orbits_on_triples:" << endl;
386 }
389 Orbits_on_triples, f_play_it_safe, verbose_level);
390
391 if (f_v) {
392 cout << "hall_system_classify::orbits_on_triples "
393 "created action on orbits of degree "
394 << A_on_orbits->degree << endl;
395 }
396
397
398
399 if (f_v) {
400 cout << "hall_system_classify::orbits_on_triples done" << endl;
401 }
402}
403
404
405
406void hall_system_classify::print(ostream &ost, long int *S, int len)
407{
408 int i;
409 int orb, f, l, j, t, a;
410 long int T[3];
411
412 for (i = 0; i < len; i++) {
413 ost << S[i] << " ";
414 }
415 ost << endl;
416 for (i = 0; i < len; i++) {
417
418 orb = S[i];
419
422 for (j = 0; j < l; j++ ) {
423 t = Orbits_on_triples->orbit[f + j];
424 unrank_triple(T, t);
425 for (a = 0; a < 3; a++) {
426 cout << T[a];
427 if (a < 3 - 1) {
428 cout << ", ";
429 }
430 } // next a
431 if (j < l) {
432 cout << "; ";
433 }
434 } // next j
435 cout << endl;
436 } // next i
437}
438
439void hall_system_classify::unrank_triple(long int *T, int rk)
440{
441 int a, b, i;
442 int set[3];
443 int binary[3];
445
446 b = rk % 8;
447 a = rk / 8;
448 Combi.unrank_k_subset(a, set, nb_pairs, 3);
449 binary[0] = b % 2;
450 b >>= 1;
451 binary[1] = b % 2;
452 b >>= 1;
453 binary[2] = b % 2;
454 for (i = 0; i < 3; i++) {
455 T[i] = 2 * set[i] + binary[i];
456 }
457}
458
459void hall_system_classify::unrank_triple_pair(long int *T1, long int *T2, int rk)
460{
461 int a, b, i;
462 int set[3];
463 int binary[3];
465
466 b = rk % 8;
467 a = rk / 8;
468 Combi.unrank_k_subset(a, set, nb_pairs, 3);
469 binary[0] = b % 2;
470 b >>= 1;
471 binary[1] = b % 2;
472 b >>= 1;
473 binary[2] = b % 2;
474 for (i = 0; i < 3; i++) {
475 T1[i] = 2 * set[i] + binary[i];
476 T2[i] = 2 * set[i] + 1 - binary[i];
477 }
478}
479
481 long int *candidates, int nb_candidates,
482 long int *good_candidates, int &nb_good_candidates,
483 int verbose_level)
484{
485 //verbose_level = 10;
486 int f_v = (verbose_level >= 1);
487 int f_vv = (verbose_level >= 2);
488 int i, j, a, b, p;
489 int orb, f, l, t, h;
490 long int T[3];
491 int f_OK;
493
494 if (f_v) {
495 cout << "hall_system_classify::early_test_func checking set ";
496 Lint_vec_print(cout, S, len);
497 cout << endl;
498 cout << "candidate set of size " << nb_candidates << ":" << endl;
499 Lint_vec_print(cout, candidates, nb_candidates);
500 cout << endl;
501 }
502
503
506
507
508 for (i = 0; i < len; i++) {
509
510 orb = S[i];
511
514 for (j = 0; j < l; j++ ) {
515 t = Orbits_on_triples->orbit[f + j];
516 unrank_triple(T, t);
517 for (a = 0; a < 3; a++) {
518 row_sum[T[a]]++;
519 for (b = a + 1; b < 3; b++) {
520 p = Combi.ij2k(T[a], T[b], nm1);
521 pair_covering[p] = TRUE;
522 } // next b
523 } // next a
524 } // next j
525 } // next i
526 if (f_vv) {
527 cout << "hall_system::early_test_func "
528 "pair_covering before testing:" << endl;
529 cout << "row_sum: " << endl;
530 Int_vec_print(cout, row_sum, nm1);
531 cout << endl;
532 cout << "pair_covering: " << endl;
534 cout << endl;
535 }
536
537
538 nb_good_candidates = 0;
539
540 for (j = 0; j < nb_candidates; j++) {
541
542
543 orb = candidates[j];
544
547
548 if (f_vv) {
549 cout << "Testing candidate " << j << " = "
550 << candidates[j] << " which is ";
551 for (h = 0; h < l; h++ ) {
552 t = Orbits_on_triples->orbit[f + h];
553 unrank_triple(T, t);
554 Lint_vec_print(cout, T, 3);
555 cout << ", ";
556 }
557 cout << endl;
558
559 }
560
561 f_OK = TRUE;
562
563 for (h = 0; h < l; h++ ) {
564 t = Orbits_on_triples->orbit[f + h];
565 unrank_triple(T, t);
566 for (a = 0; a < 3; a++) {
567 if (row_sum[T[a]] == nb_pairs - 1) {
568 if (f_v) {
569 cout << "bad because of row sum "
570 "in row " << T[a] << endl;
571 }
572 f_OK = FALSE;
573 break;
574 } // if
575 } // next a
576 if (!f_OK) {
577 break;
578 }
579 } // next h
580
581 if (f_OK) {
582 for (h = 0; h < l; h++ ) {
583 t = Orbits_on_triples->orbit[f + h];
584 unrank_triple(T, t);
585 for (a = 0; a < 3; a++) {
586 for (b = a + 1; b < 3; b++) {
587 p = Combi.ij2k(T[a], T[b], nm1);
588 if (pair_covering[p]) {
589 if (f_v) {
590 cout << "bad because of pair covering in pair "
591 << T[a] << "," << T[b] << "=" << p << endl;
592 }
593 f_OK = FALSE;
594 break;
595 }
596 }
597 if (!f_OK) {
598 break;
599 }
600 } // next a
601 if (!f_OK) {
602 break;
603 }
604 } // next h
605 }
606
607
608 if (f_OK) {
609 if (f_vv) {
610 cout << "Testing candidate " << j << " = "
611 << candidates[j] << " is good" << endl;
612 }
613 good_candidates[nb_good_candidates++] = candidates[j];
614 }
615 }
616}
617
618
619// #############################################################################
620// global functions:
621// #############################################################################
622
623
624
625
626static void hall_system_print_set(ostream &ost, int len, long int *S, void *data)
627{
629
630 //print_vector(ost, S, len);
631 H->print(ost, S, len);
632}
633
634
635static void hall_system_early_test_function(long int *S, int len,
636 long int *candidates, int nb_candidates,
637 long int *good_candidates, int &nb_good_candidates,
638 void *data, int verbose_level)
639{
640 hall_system_classify *H = (hall_system_classify *) data;
641 int f_v = (verbose_level >= 1);
642
643 if (f_v) {
644 cout << "hall_system_early_test_function for set ";
645 Lint_vec_print(cout, S, len);
646 cout << endl;
647 }
648 H->early_test_func(S, len,
649 candidates, nb_candidates,
650 good_candidates, nb_good_candidates,
651 verbose_level - 2);
652 if (f_v) {
653 cout << "hall_system_early_test_function done" << endl;
654 }
655}
656
657
658
659}}}
660
a collection of functions related to sorted vectors
a permutation group in a fixed action.
Definition: actions.h:99
void init_symmetric_group(int degree, int f_no_base, int verbose_level)
void induced_action_on_orbits(action *old_action, groups::schreier *Sch, int f_play_it_safe, int verbose_level)
void induced_action_on_sets(action &old_action, groups::sims *old_G, int nb_sets, int set_size, long int *sets, int f_induce_action, int verbose_level)
Schreier trees for orbits of groups on points.
Definition: groups.h:839
void write_to_file_binary(std::ofstream &fp, int verbose_level)
void read_from_file_binary(std::ifstream &fp, int verbose_level)
void init_generators(data_structures_groups::vector_ge &generators, int verbose_level)
Definition: schreier.cpp:373
void init(actions::action *A, int verbose_level)
Definition: schreier.cpp:308
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
void normalizer_of_a_Hall_reflection(int nb_pairs, int &degree, int verbose_level)
void Hall_reflection(int nb_pairs, int &degree, int verbose_level)
schreier * orbits_on_points_schreier(actions::action *A_given, int verbose_level)
data_structures_groups::vector_ge * gens
Definition: groups.h:1708
to control the behavior of the poset classification algorithm
void initialize_and_allocate_root_node(poset_classification_control *PC_control, poset_with_group_action *Poset, int depth, int verbose_level)
int main(int t0, int schreier_depth, int f_use_invariant_subset_if_available, int f_debug, int verbose_level)
void init_subset_lattice(actions::action *A, actions::action *A2, groups::strong_generators *Strong_gens, int verbose_level)
void add_testing_without_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(* print_function)(std::ostream &ost, int len, long int *S, void *data)
poset_classification::poset_classification_control * Control
void init(int argc, const char **argv, int n, int depth, 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)
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#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
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects