Orbiter 2022
Combinatorial Objects
combinatorics_global.cpp
Go to the documentation of this file.
1/*
2 * combinatorics_global.cpp
3 *
4 * Created on: May 25, 2021
5 * Author: betten
6 */
7
8
9
10#include "orbiter.h"
11
12using namespace std;
13
14namespace orbiter {
15namespace layer5_applications {
16namespace apps_combinatorics {
17
18
20{
21
22}
23
25{
26
27}
28
30 std::string &problem_label,
31 design_tables *&T,
33 int verbose_level)
34{
35 int f_v = (verbose_level >= 1);
36
37 if (f_v) {
38 cout << "combinatorics_global::create_design_table" << endl;
39 }
41
42 if (f_v) {
43 cout << "combinatorics_global::create_design_table design:" << endl;
44 cout << "$$" << endl;
45 L.lint_set_print_tex(cout, DC->set, DC->sz);
46 cout << endl;
47 cout << "$$" << endl;
48
49 if (DC->f_has_group) {
50 cout << "The stabilizer is generated by:" << endl;
51 DC->Sg->print_generators_tex(cout);
52 }
53 }
54
55
56
57
59
60 if (f_v) {
61 cout << "combinatorics_global::create_design_table before T->init" << endl;
62 }
63 T->init(DC->A, DC->A2,
64 DC->set, DC->sz,
65 problem_label,
66 Gens, verbose_level);
67 if (f_v) {
68 cout << "combinatorics_global::create_design_table after T->init" << endl;
69 }
70
71
72
73 if (f_v) {
74 cout << "combinatorics_global::create_design_table done" << endl;
75 }
76}
77
78
79
81 std::string &problem_label,
82 design_tables *&T,
84 int verbose_level)
85{
86 int f_v = (verbose_level >= 1);
87
88 if (f_v) {
89 cout << "combinatorics_global::load_design_table" << endl;
90 }
93 //int *Elt1;
94 int *Elt2;
95
96 A = DC->A;
97
98 Elt2 = NEW_int(A->elt_size_in_int);
99
100
101
102 if (f_v) {
103 cout << "combinatorics_global::load_design_table design:" << endl;
104 cout << "$$" << endl;
105 L.lint_set_print_tex(cout, DC->set, DC->sz);
106 cout << endl;
107 cout << "$$" << endl;
108
109 if (DC->f_has_group) {
110 cout << "The stabilizer is generated by:" << endl;
111 DC->Sg->print_generators_tex(cout);
112 }
113 }
114
115
116
117
119
120 if (f_v) {
121 cout << "combinatorics_global::load_design_table before T->init_from_file" << endl;
122 }
123 T->init_from_file(DC->A, DC->A2,
124 DC->set, DC->sz,
125 problem_label,
126 Gens, verbose_level);
127 if (f_v) {
128 cout << "combinatorics_global::load_design_table after T->init_from_file" << endl;
129 }
130
131 if (f_v) {
132 cout << "combinatorics_global::load_design_table done" << endl;
133 }
134
135}
136
137
138
139#if 0
140 std::string &input_prefix,
141 std::string &design_tables_prefix,
142 std::string &group_label,
143 std::string &group_order,
144 std::string &generators_data,
145#endif
146
147#if 0
148 orbit_of_sets *SetOrb;
149
150 SetOrb = NEW_OBJECT(orbit_of_sets);
151
152 cout << "computing orbit:" << endl;
153 SetOrb->init(DC->A, DC->A2,
154 DC->set, DC->sz, DC->A->Strong_gens->gens,
155 verbose_level);
156 cout << "computing orbit done" << endl;
157
158
160
162
163 int f_lexorder_test = TRUE;
164 char str[1000];
165 string base_fname;
166
167
168 sprintf(str, "LS_%s", DC->prefix);
169 base_fname.assign(str);
170
171 LS->init(DC,
172 input_prefix, base_fname,
173 0 /*search_depth*/,
174 f_lexorder_test,
175 design_tables_prefix,
176 verbose_level);
177
178
179
180
181 LS->init_designs(SetOrb, verbose_level);
182
183
184#if 0
185 if (f_read_classification) {
186 cout << "reading classification at level "
187 << read_classification_level << endl;
188
189 orbit_transversal *T;
190
192 read_classification_level, verbose_level);
193
194 cout << "computing and reporting ago distribution:" << endl;
195
196 T->report_ago_distribution(cout);
197
198 FREE_OBJECT(T);
199 }
200 else if (f_lift_this) {
201 cout << "lifting a given set" << endl;
202 int *lift_starter;
203 int lift_starter_sz;
204
205
206 int_vec_scan(lift_this_set, lift_starter, lift_starter_sz);
207 cout << "lift_starter = ";
208 int_vec_print(cout, lift_starter, lift_starter_sz);
209 cout << endl;
210
211
212 }
213#endif
214 //else if (f_lift_this_with_group) {
215 cout << "lifting a given set with a given group" << endl;
216
217
218#if 0
219 long int *lift_starter;
220 int lift_starter_sz;
221
222
223 lint_vec_scan(lift_this_with_group_set, lift_starter, lift_starter_sz);
224
225 cout << "lift_starter = ";
226 lint_vec_print(cout, lift_starter, lift_starter_sz);
227 cout << endl;
228#endif
229
230
231 int *gens_data;
232 int gens_data_sz;
233 int nb_elements;
234
235 Orbiter->Int_vec.scan(generators_data, gens_data, gens_data_sz);
236 cout << "gens_data = ";
237 Orbiter->Int_vec.print(cout, gens_data, gens_data_sz);
238 cout << endl;
239
240
241 nb_elements = gens_data_sz / A->make_element_size;
242
243 strong_generators *SG;
244 vector_ge *nice_gens;
245 int orbit_length;
246
247 SG = NEW_OBJECT(strong_generators);
248
249 cout << "before SG->init_from_data_with_target_go_ascii" << endl;
250 SG->init_from_data_with_target_go_ascii(A,
251 gens_data,
252 nb_elements, A->make_element_size,
253 group_order.c_str(),
254 nice_gens,
255 verbose_level);
256
257 // computing the normalizer:
258 strong_generators *gens_N;
259 {
260 sims *G;
261 sims *H;
262 char str[1000];
263 string fname_magma_prefix;
264
265 sprintf(str, "%s_normalizer", A->label);
266 fname_magma_prefix.assign(str);
267
268 if (!A->f_has_sims) {
269 cout << "A does not have sims" << endl;
270 exit(1);
271 }
272 G = A->Sims;
273 H = SG->create_sims(verbose_level - 2);
274 A->normalizer_using_MAGMA(fname_magma_prefix,
275 G, H, gens_N, verbose_level);
276 cout << "generators for the normalizer are:" << endl;
277 gens_N->print_generators_tex(cout);
278 FREE_OBJECT(H);
279 }
280
281 orbit_length = SG->group_order_as_lint();
282
283 cout << "The group is generated by the following strong generating set:" << endl;
284 SG->print_elements_latex_ost(cout);
285
286 long int *Large_sets;
287 int nb_large_sets;
288
289 long int *lift_starter = NULL;
290 string solution_file_name;
291 solution_file_name.assign("");
292
293 LS->process_starter_case(lift_starter, 0 /*lift_starter_sz*/,
294 SG, group_label,
295 group_label, orbit_length,
296 FALSE /*f_read_solution_file*/, solution_file_name,
297 Large_sets, nb_large_sets,
298 TRUE /* f_compute_normalizer_orbits */, gens_N,
299 verbose_level);
300 cout << "processing starter case done" << endl;
301
302 FREE_OBJECT(SG);
303 FREE_OBJECT(nice_gens);
304
305 cout << "lifting a given set with a given group done" << endl;
306 //}
307#if 0
308 else if (f_lift_case) {
309 cout << "lifting a single case" << endl;
310
311 set_and_stabilizer *Rep;
312
314 lift_case_level, lift_case, verbose_level);
315
316 cout << "the set in case " << lift_case << " is:" << endl;
317 Rep->print_set_tex(cout);
318 cout << endl;
319
320 cout << "The designs are:" << endl;
321 for (i = 0; i < Rep->sz; i++) {
322 int a;
323
324 a = Rep->data[i];
325 cout << i << " & " << a << " & ";
326 lint_vec_print(cout, LS->Design_table + a * LS->design_size, LS->design_size);
327 cout << endl;
328 }
329
330 cout << "The blocks of the designs are:" << endl;
331 int *block;
332
333 block = NEW_int(LS->DC->k);
334
335 for (i = 0; i < Rep->sz; i++) {
336 int a, b, j;
337
338 a = Rep->data[i];
339 cout << "design " << i << " is " << a << " has the following blocks:" << endl;
340 for (j = 0; j < LS->design_size; j++) {
341 b = LS->Design_table[a * LS->design_size + j];
342 LS->DC->unrank_block_in_PG_2_q(block,
343 b, 0 /*verbose_level*/);
344 cout << "block " << j << " is " << b << " : ";
345 int_vec_print(cout, block, LS->DC->k);
346 cout << endl;
347 }
348 }
349
350 FREE_int(block);
351
352
353 cout << "strong generators are:" << endl;
354 Rep->Strong_gens->print_generators_tex();
355
356 cout << "The elements are:" << endl;
357 Rep->Strong_gens->print_elements_ost(cout);
358
359 sylow_structure *Syl;
360 sims *S;
361
362 cout << "creating Sims:" << endl;
363 S = Rep->Strong_gens->create_sims(0 /* verbose_level */);
364 Syl = NEW_OBJECT(sylow_structure);
365
366 cout << "creating Sylow structure:" << endl;
367 Syl->init(S, 0 /*verbose_level*/);
368 Syl->report(cout);
369
370#if 0
371 cout << "processing starter case with full stabilizer:" << endl;
372 LS->process_starter_case(Rep, Rep->Strong_gens, verbose_level);
373 cout << "processing starter case done" << endl;
374#else
375 int sylow_select;
376
377 for (sylow_select = 0; sylow_select < Syl->nb_primes; sylow_select++) {
378
379 if (f_sylow_select) {
380 if (Syl->primes[sylow_select] != sylow_select_prime) {
381 cout << "skipping this prime because of -sylow_select" << endl;
382 continue;
383 }
384 }
385 cout << "processing starter case with Sylow subgroup "
386 << sylow_select << " / " << Syl->nb_primes << " of stabilizer, "
387 "for p=" << Syl->primes[sylow_select] << endl;
388 char prefix[1000];
389 char group_label[1000];
390 int orbit_length;
391
392 orbit_length = Syl->primes[sylow_select];
393 sprintf(prefix, "Case_%d_", lift_case);
394 sprintf(group_label, "Syl_%d", Syl->primes[sylow_select]);
395
396 long int *Large_sets;
397 int nb_large_sets;
398
399 strong_generators *SG1;
400
401 if (f_cyclic_subgroup_with_n_fixpoints) {
402 cout << "finding cyclic subgroup with n fixpoints, for n = "
403 << cyclic_subgroup_with_n_fixpoints << endl;
404 SG1 = Syl->Sub[sylow_select].SG->find_cyclic_subgroup_with_exactly_n_fixpoints(
405 cyclic_subgroup_with_n_fixpoints, A, verbose_level);
406 }
407 else {
408 SG1 = Syl->Sub[sylow_select].SG;
409 }
410 cout << "considering the group generated by:" << endl;
411 SG1->print_generators_tex();
412 LS->process_starter_case(Rep->data, Rep->sz, SG1,
413 prefix, group_label, orbit_length,
414 f_read_solution_file, solution_file_name,
415 Large_sets, nb_large_sets,
416 FALSE /* f_compute_normalizer_orbits */, NULL /* gens_N */,
417 verbose_level);
418 cout << "processing starter case done" << endl;
419 if (f_read_solution_file) {
420 cout << "We found " << nb_large_sets << " large sets" << endl;
421 lint_matrix_print(Large_sets, nb_large_sets, LS->size_of_large_set);
422 }
423 }
424#endif
425 }
426 else {
427 if (f_depth) {
428 cout << "classification of subsets of size " << depth << endl;
429 LS->gen->depth = depth;
430
431 LS->compute(verbose_level);
432 }
433 }
434#endif
435
436 FREE_int(Elt2);
437
438
439 if (f_v) {
440 cout << "combinatorics_global::lift_design done" << endl;
441 }
442
443}
444#endif
445
446
447
448
449void combinatorics_global::Hill_cap56(
450 char *fname, int &nb_Pts, long int *&Pts,
451 int verbose_level)
452{
453 int f_v = (verbose_level >= 1);
454 int f_vv = (verbose_level >= 2);
455 int epsilon, n, q, w, i;
458 actions::action *An;
463
464 if (f_v) {
465 cout << "combinatorics_global::Hill_cap" << endl;
466 }
467 epsilon = -1;
468 n = 6;
469 q = 3;
470 w = Gg.Witt_index(epsilon, n - 1);
471
476
477 F->finite_field_init(q, FALSE /* f_without_tables */, 0);
478 if (f_v) {
479 cout << "Hill_cap before init_orthogonal" << endl;
480 }
481
482 int f_semilinear;
483
484 if (NT.is_prime(F->q)) {
485 f_semilinear = FALSE;
486 }
487 else {
488 f_semilinear = TRUE;
489 }
490
491 if (f_v) {
492 cout << "f_semilinear=" << f_semilinear << endl;
493 }
494
495 A->init_orthogonal_group(epsilon,
496 n, F,
497 TRUE /* f_on_points */, FALSE /* f_on_lines */,
498 FALSE /* f_on_points_and_lines */,
499 f_semilinear, TRUE /* f_basis */,
500 0/*verbose_level*/);
501
502
503
504
505 if (f_v) {
506 cout << "Hill_cap created action:" << endl;
507 A->print_info();
508 }
509
510
513
514 O = AO->O;
515
516 if (f_v) {
517 cout << "after init_orthogonal" << endl;
518 }
520
521 An->init_projective_group(n, F, TRUE /* f_semilinear */,
522 TRUE /* f_basis */, TRUE /* f_init_sims */,
523 nice_gens,
524 verbose_level - 2);
525
526 FREE_OBJECT(nice_gens);
527
528 if (f_v) {
529 cout << "after init_projective_group" << endl;
530 }
531
532 if (f_v) {
533 cout << "Hill_cap before P.init" << endl;
534 }
535 P->init(A, O, epsilon, n, w, F, w, verbose_level - 2);
536 if (f_v) {
537 cout << "Hill_cap before P.init2" << endl;
538 }
539 P->init2(w, verbose_level - 2);
540 if (f_v) {
541 cout << "Hill_cap before P.compute_orbits" << endl;
542 }
543 int t0 = Os.os_ticks();
544 P->compute_orbits(t0, verbose_level - 2);
545
546 if (f_v) {
547 cout << "we found " << P->nb_orbits
548 << " orbits at depth " << w << endl;
549 }
550
551 //P.compute_cosets(w, 0, verbose_level);
552
553#if 1
554
556 int nb_lines;
557
558 if (f_v) {
559 cout << "Hill_cap before P.dual_polar_graph" << endl;
560 }
561 P->dual_polar_graph(w, 0, Rank_lines, nb_lines, verbose_level - 2);
562
563
564 cout << "there are " << nb_lines << " lines" << endl;
565 for (i = 0; i < nb_lines; i++) {
566 cout << setw(5) << i << " : " << Rank_lines[i] << endl;
567 }
569
570 if (f_v) {
571 cout << "Hill_cap before Grass.init" << endl;
572 }
573 Grass.init(n, w, F, 0 /*verbose_level*/);
574
575 cout << "there are " << nb_lines
576 << " lines, generator matrices are:" << endl;
577 for (i = 0; i < nb_lines; i++) {
578 Grass.unrank_longinteger(Rank_lines[i], 0/*verbose_level - 3*/);
579 cout << setw(5) << i << " : " << Rank_lines[i] << ":" << endl;
580 Int_vec_print_integer_matrix_width(cout, Grass.M, w, n, n, 2);
581 }
582
583#endif
584
585
586
587 groups::sims *S;
589 //int goi;
590 int *Elt;
591
592 Elt = NEW_int(P->A->elt_size_in_int);
593 S = P->A->Sims;
594 S->group_order(go);
595 cout << "found a group of order " << go << endl;
596 //goi = go.as_int();
597
598 if (f_v) {
599 cout << "Hill_cap finding an element of order 7" << endl;
600 }
601 S->random_element_of_order(Elt, 7 /* order */, verbose_level);
602 cout << "an element of order 7 is:" << endl;
603 P->A->element_print_quick(Elt, cout);
604
605
606
607 groups::schreier *Orb;
608 int N;
609
610 if (f_v) {
611 cout << "Hill_cap computing orbits on points" << endl;
612 }
614 Orb->init(P->A, verbose_level - 2);
615 Orb->init_single_generator(Elt, verbose_level - 2);
616 Orb->compute_all_point_orbits(verbose_level - 2);
617 if (f_vv) {
618 cout << "Hill_cap the orbits on points are:" << endl;
619 Orb->print_and_list_orbits(cout);
620 }
621
622
623
624
625
626
627
628
629 int *pt_coords;
630 //int *Good_orbits;
631 int *set;
632 int a, nb_pts, j;
633
634 N = Orb->nb_orbits;
635 nb_pts = P->A->degree;
636 pt_coords = NEW_int(nb_pts * n);
637 set = NEW_int(nb_pts);
638 //Good_orbits = NEW_int(N);
639
640 for (i = 0; i < nb_pts; i++) {
641 O->unrank_point(pt_coords + i * n, 1, i, 0);
642 }
643 cout << "point coordinates:" << endl;
644 Int_vec_print_integer_matrix_width(cout, pt_coords, nb_pts, n, n, 2);
645
646 cout << "evaluating quadratic form:" << endl;
647 for (i = 0; i < nb_pts; i++) {
648 a = O->evaluate_quadratic_form(pt_coords + i * n, 1);
649 cout << setw(3) << i << " : " << a << endl;
650 }
651 int sz[9];
652 int i1, i2, i3, i4, i5, i6, i7, i8, ii;
653 int nb_sol;
654
655 int *Sets; // [max_sol * 56]
656 int max_sol = 100;
658
659 Sets = NEW_int(max_sol * 56);
660
661 sz[0] = 0;
662 nb_sol = 0;
663 for (i1 = 0; i1 < N; i1++) {
664 sz[1] = sz[0];
665 append_orbit_and_adjust_size(Orb, i1, set, sz[1]);
666 //cout << "after append_orbit_and_adjust_size :";
667 //int_vec_print(cout, set, sz[1]);
668 //cout << endl;
669 if (!Gg.test_if_arc(F, pt_coords, set, sz[1], n, verbose_level)) {
670 continue;
671 }
672 for (i2 = i1 + 1; i2 < N; i2++) {
673 sz[2] = sz[1];
674 append_orbit_and_adjust_size(Orb, i2, set, sz[2]);
675 if (!Gg.test_if_arc(F, pt_coords, set, sz[2], n, verbose_level)) {
676 continue;
677 }
678 for (i3 = i2 + 1; i3 < N; i3++) {
679 sz[3] = sz[2];
680 append_orbit_and_adjust_size(Orb, i3, set, sz[3]);
681 if (!Gg.test_if_arc(F, pt_coords, set, sz[3], n, verbose_level)) {
682 continue;
683 }
684 for (i4 = i3 + 1; i4 < N; i4++) {
685 sz[4] = sz[3];
686 append_orbit_and_adjust_size(Orb, i4, set, sz[4]);
687 if (!Gg.test_if_arc(F, pt_coords, set, sz[4], n, verbose_level)) {
688 continue;
689 }
690 for (i5 = i4 + 1; i5 < N; i5++) {
691 sz[5] = sz[4];
692 append_orbit_and_adjust_size(Orb, i5, set, sz[5]);
693 if (!Gg.test_if_arc(F, pt_coords, set, sz[5], n, verbose_level)) {
694 continue;
695 }
696 for (i6 = i5 + 1; i6 < N; i6++) {
697 sz[6] = sz[5];
698 append_orbit_and_adjust_size(Orb, i6, set, sz[6]);
699 if (!Gg.test_if_arc(F, pt_coords, set, sz[6], n, verbose_level)) {
700 continue;
701 }
702 for (i7 = i6 + 1; i7 < N; i7++) {
703 sz[7] = sz[6];
704 append_orbit_and_adjust_size(Orb, i7, set, sz[7]);
705 if (!Gg.test_if_arc(F, pt_coords, set, sz[7], n, verbose_level)) {
706 continue;
707 }
708 for (i8 = i7 + 1; i8 < N; i8++) {
709 sz[8] = sz[7];
710 append_orbit_and_adjust_size(Orb, i8, set, sz[8]);
711 if (!Gg.test_if_arc(F, pt_coords, set, sz[8], n, verbose_level)) {
712 continue;
713 }
714
715 if (sz[8] != 56) {
716 cout << "error, the size of the arc is not 56" << endl;
717 exit(1);
718 }
719 for (ii = 0; ii < sz[8]; ii++) {
720 int rk;
721 O->F->PG_element_rank_modified(pt_coords + set[ii] * n, 1, n, rk);
722 Sets[nb_sol * 56 + ii] = rk;
723 }
724
725 nb_sol++;
726 cout << "solution " << nb_sol << ", a set of size " << sz[8] << " : ";
727 cout << i1 << "," << i2 << "," << i3 << "," << i4 << "," << i5 << "," << i6 << "," << i7 << "," << i8 << endl;
728 Int_vec_print(cout, set, sz[8]);
729 cout << endl;
730
731
732#if 0
733 solution(w, n, A, O, pt_coords,
734 set, sz[8], Rank_lines, nb_lines, verbose_level);
735 cout << endl;
736#endif
737
738 } // next i8
739 } // next i7
740 } // next i6
741 } // next i5
742 } // next i4
743 } // next i3
744 } // next i2
745 } // next i1
746 cout << "there are " << nb_sol << " solutions" << endl;
747 cout << "out of " << Combi.int_n_choose_k(N, 8) << " possibilities" << endl;
748
749
750 for (i = 0; i < nb_sol; i++) {
751 cout << "Solution " << i << ":" << endl;
752 for (j = 0; j < 56; j++) {
753 cout << Sets[i * 56 + j] << " ";
754 }
755 cout << endl;
756 }
757
758 if (nb_sol == 0) {
759 cout << "error, no solution" << endl;
760 exit(1);
761 }
762
763 nb_Pts = 56;
764 Pts = NEW_lint(56);
765 for (j = 0; j < 56; j++) {
766 Pts[j] = Sets[0 * 56 + j];
767 }
768 sprintf(fname, "Hill_cap_56.txt");
769
770 FREE_int(Sets);
771
772 FREE_OBJECT(P);
773 FREE_OBJECT(A);
774 FREE_OBJECT(An);
775 FREE_OBJECT(F);
776
777}
778
779void combinatorics_global::append_orbit_and_adjust_size(groups::schreier *Orb,
780 int idx, int *set, int &sz)
781// Used by Hill_cap56()
782{
783 int f, i, len;
784
785 f = Orb->orbit_first[idx];
786 len = Orb->orbit_len[idx];
787 for (i = 0; i < len; i++) {
788 set[sz++] = Orb->orbit[f + i];
789 }
790}
791
792
793
794void combinatorics_global::classify_objects_using_nauty(
797 std::string &output_fname,
798 int verbose_level)
799{
800 int f_v = (verbose_level >= 1);
801 int input_idx;
802 int t0;
805 int nb_objects_to_test;
806 long int *Ago;
807 vector<vector<long int>> Reps;
808
809
810 if (f_v) {
811 cout << "combinatorics_global::classify_objects_using_nauty" << endl;
812 }
813
814#if 0
815 if (f_v) {
816 cout << "combinatorics_global::classify_objects_using_nauty "
817 "before count_number_of_objects_to_test" << endl;
818 }
819 nb_objects_to_test = Data->count_number_of_objects_to_test(
820 verbose_level - 1);
821
822 t0 = Os.os_ticks();
823
824
825 Ago = NEW_lint(nb_objects_to_test);
826
827 int N_points = -1;
828 int design_b = -1;
829 int design_k = -1;
830 int partition_class_size = -1;
831
832 for (input_idx = 0; input_idx < Data->nb_inputs; input_idx++) {
833 if (f_v) {
834 cout << "combinatorics_global::classify_objects_using_nauty input "
835 << input_idx << " / " << Data->nb_inputs
836 << " is:" << endl;
837 }
838
839 if (Data->input_type[input_idx] == INPUT_TYPE_FILE_OF_DESIGNS) {
840 if (f_v) {
841 cout << "combinatorics_global::classify_objects_using_nauty "
842 "input " << input_idx << " / " << Data->nb_inputs
843 << " from file " << Data->input_string[input_idx]
844 << ":" << endl;
845 }
846
847 if (N_points == -1) {
848 N_points = Data->input_data1[input_idx];
849 design_b = Data->input_data2[input_idx];
850 design_k = Data->input_data3[input_idx];
851 partition_class_size = Data->input_data4[input_idx];
852 }
853 else {
854 if (Data->input_data1[input_idx] != N_points) {
855 cout << "combinatorics_global::classify_objects_using_nauty N_points is not constant" << endl;
856 exit(1);
857 }
858 if (Data->input_data2[input_idx] != design_b) {
859 cout << "combinatorics_global::classify_objects_using_nauty design_b is not constant" << endl;
860 exit(1);
861 }
862 if (Data->input_data3[input_idx] != design_k) {
863 cout << "combinatorics_global::classify_objects_using_nauty design_k is not constant" << endl;
864 exit(1);
865 }
866 }
867
868 handle_input_file(CB, nb_objects_to_test, t0,
869 Data->input_string[input_idx], input_idx, Data->nb_inputs,
870 N_points, design_b, design_k, partition_class_size,
871 Ago, Reps,
872 verbose_level);
873
874 if (f_v) {
875 cout << "combinatorics_global::classify_objects_using_nauty "
876 "input " << input_idx << " / " << Data->nb_inputs
877 << " from file " << Data->input_string[input_idx]
878 << " finished" << endl;
879 }
880 } // if INPUT_TYPE_FILE_OF_DESIGNS
881 else {
882 cout << "combinatorics_global::classify_objects_using_nauty unknown input type" << endl;
883 exit(1);
884 }
885
886 if (f_v) {
887 cout << "combinatorics_global::classify_objects_using_nauty distribution of automorphism group orders of new isomorphism types after file "
888 << input_idx << " / " << Data->nb_inputs << " is:" << endl;
889 tally C;
890
891 C.init_lint(Ago, CB->nb_types, FALSE, 0);
892 C.print_naked(TRUE);
893 cout << endl;
894 }
895
896 } // next input_idx
897
898
899#if 0
900 int t;
901
902 for (t = 0; t < nb_test_perm; t++) {
903 int *perm;
904 int degree;
905 int i;
906
907 cout << "combinatorics_global::classify_objects_using_nauty testing permutation " << test_perm[t] << endl;
908 scan_permutation_from_string(test_perm[t],
909 perm, degree, verbose_level);
910 cout << "the permutation is:" << endl;
911 for (i = 0; i < degree; i++) {
912 cout << i << " -> " << perm[i] << endl;
913 }
914 }
915#endif
916
917 if (N_points == -1) {
918 cout << "N_points == -1" << endl;
919 exit(1);
920 }
921
922 set_of_sets *SoS;
923 int i, j;
924
925 SoS = NEW_OBJECT(set_of_sets);
926
927 cout << "saving" << endl;
928 cout << "combinatorics_global::classify_objects_using_nauty allocating set of sets of size " << Reps.size() << " each of size " << design_b << endl;
929 SoS->init_basic_constant_size(N_points, Reps.size(), design_b, 0 /* verbose_level */);
930
931 for (i = 0; i < Reps.size(); i++) {
932 vector<long int> rep;
933
934 rep = Reps[i];
935 for (j = 0; j < design_b; j++) {
936 SoS->Sets[i][j] = rep[j];
937 }
938 }
939
940 SoS->save_constant_size_csv(output_fname, verbose_level);
941
942#if 0
943 if (f_v) {
944 cout << "combinatorics_global::classify_objects_using_nauty "
945 "before compute_and_print_ago_distribution" << endl;
946 }
947
948 compute_and_print_ago_distribution(cout, CB, verbose_level);
949
950 if (f_v) {
951 cout << "combinatorics_global::classify_objects_using_nauty "
952 "after compute_and_print_ago_distribution" << endl;
953 }
954
955 if (f_v) {
956 cout << "classify_objects_using_nauty before CB->finalize" << endl;
957 }
958
959 //CB->finalize(verbose_level); // computes C_type_of and perm
960#endif
961
962
963#endif
964
965 if (f_v) {
966 cout << "combinatorics_global::classify_objects_using_nauty done" << endl;
967 }
968}
969
970
971
972
973
974void combinatorics_global::handle_input_file(data_structures::classify_bitvectors *CB,
975 int nb_objects_to_test, int t0,
976 std::string &fname, int input_file_idx, int nb_input_files,
977 int N_points, int design_b, int design_k, int partition_class_size,
978 long int *Ago, std::vector<std::vector<long int>> &Reps,
979 int verbose_level)
980{
981 int f_v = (verbose_level >= 1);
982 int f_vv = (verbose_level >= 2);
983 int f_vvv = (verbose_level >= 3);
985
986 int nck;
987 int nb_classes = design_b / partition_class_size;
988 int t1, dt;
989
990 if (f_v) {
991 cout << "combinatorics_global::handle_input_file fname=" << fname << endl;
992 }
993
995
996 nck = Combi.int_n_choose_k(N_points, design_k);
997
999
1001
1002 if (f_v) {
1003 cout << "N_points=" << N_points << endl;
1004 cout << "design_b=" << design_b << endl;
1005 cout << "design_k=" << design_k << endl;
1006 cout << "partition_class_size=" << partition_class_size << endl;
1007 cout << "nb_classes=" << nb_classes << endl;
1008 cout << "combinatorics_global::handle_input_file Reading the file " << fname << endl;
1009 }
1010
1011 SoS->init_from_file(
1012 nck /* underlying_set_size */,
1013 fname, verbose_level);
1014
1015 if (f_v) {
1016 cout << "Read the file " << fname << endl;
1017 }
1018
1019 int h;
1020
1021
1022 if (f_v) {
1023 cout << "combinatorics_global::handle_input_file processing "
1024 << SoS->nb_sets << " objects" << endl;
1025 }
1026
1027 for (h = 0; h < SoS->nb_sets; h++) {
1028
1029 if (f_v) {
1030 cout << "Input set " << h << " / " << SoS->nb_sets << ", "
1031 << input_file_idx << " / " << nb_input_files << ":" << endl;
1032 }
1033
1034 long int *the_set_in;
1035 int set_size_in;
1036
1037
1038 set_size_in = SoS->Set_size[h];
1039 the_set_in = SoS->Sets[h];
1040
1041
1042
1043 if (set_size_in != design_b) {
1044 cout << "handle_input_file "
1045 "set_size_in != design_b" << endl;
1046 exit(1);
1047 }
1048
1049 if (FALSE) {
1050 orbiter_kernel_system::Orbiter->Lint_vec->matrix_print(the_set_in, nb_classes, partition_class_size);
1051 }
1052 if (f_vv || ((h % 1024) == 0)) {
1053 cout << "combinatorics_global::handle_input_file "
1054 "The input set " << h << " / " << SoS->nb_sets << ", "
1055 << input_file_idx << " / " << nb_input_files << " : "
1056 << " has size " << set_size_in << ":" << endl;
1057 }
1058
1059 if (f_vvv) {
1060 cout << "combinatorics_global::handle_input_file "
1061 "The input set is:" << endl;
1062 Lint_vec_print(cout, the_set_in, set_size_in);
1063 cout << endl;
1064 }
1065
1066
1067
1068
1070 int *partition;
1071
1073 Inc->init_large_set(
1074 the_set_in /* blocks */,
1075 N_points, design_b, design_k, partition_class_size,
1076 partition, 0 /*verbose_level*/);
1077
1078#if 0
1079 {
1080 string fname_input;
1081 char str[1000];
1082 string_tools ST;
1083 file_io Fio;
1084
1085 fname_input.assign(fname);
1086 ST.chop_off_extension(fname_input);
1087 sprintf(str, "_input_%d.csv", h);
1088 fname_input.append(str);
1089 Fio.int_matrix_write_csv(fname_input, Inc->M, Inc->nb_rows, Inc->nb_cols);
1090 }
1091#endif
1092
1093
1095
1097 IG->init(Inc,
1098 partition,
1099 0/*verbose_level - 2*/);
1100
1101 int f_found;
1102 int idx;
1104
1106
1107
1108 process_object(
1109 CB,
1110 IG,
1111 Inc_out,
1112 //f_save_incma_in_and_out, save_incma_in_and_out_prefix,
1113 nb_objects_to_test,
1114 f_found, idx,
1115 go,
1116 verbose_level - 2);
1117
1118#if 0
1119 {
1120 string fname_output;
1121 char str[1000];
1122 string_tools ST;
1123 file_io Fio;
1124
1125 fname_output.assign(fname);
1126 ST.chop_off_extension(fname_output);
1127 sprintf(str, "_output_%d.csv", h);
1128 fname_output.append(str);
1129 Fio.int_matrix_write_csv(fname_output, Inc_out->M, Inc_out->nb_rows, Inc_out->nb_cols);
1130 }
1131#endif
1132
1133 FREE_OBJECT(Inc_out);
1134 FREE_OBJECT(IG);
1135 FREE_OBJECT(Inc);
1136 FREE_int(partition);
1137
1138
1139 if (f_found) {
1140
1141 if (f_v) {
1142 cout << "combinatorics_global::handle_input_file input set " << h << " found at position " << idx
1143 << ", corresponding to input object " << CB->Type_rep[idx]
1144 << " and hence is skipped" << endl;
1145 }
1146 }
1147 else {
1148 if (f_v) {
1149 cout << "combinatorics_global::handle_input_file new isomorphism type: ";
1150 Lint_vec_print(cout, the_set_in, set_size_in);
1151 cout << endl;
1152 }
1153 vector<long int> rep;
1154 int i;
1155
1156 for (i = 0; i < set_size_in; i++) {
1157 rep.push_back(the_set_in[i]);
1158 }
1159 Reps.push_back(rep);
1160
1161 t1 = Os.os_ticks();
1162 //cout << "poset_classification::print_level_info t0=" << t0 << endl;
1163 //cout << "poset_classification::print_level_info t1=" << t1 << endl;
1164 dt = t1 - t0;
1165 //cout << "poset_classification::print_level_info dt=" << dt << endl;
1166
1167 if (f_v) {
1168 cout << "Time ";
1169 Os.time_check_delta(cout, dt);
1170 }
1171
1172 //longinteger_object go;
1173
1174 //IG->A_perm->group_order(go);
1175
1176 if (f_v) {
1177 cout << " --- New isomorphism type! input set " << h
1178 << " / " << SoS->nb_sets << ", " << input_file_idx << " / " << nb_input_files << " : "
1179 << " The n e w number of "
1180 "isomorphism types is " << CB->nb_types << " go=" << go << endl;
1181 }
1182
1183 Ago[CB->nb_types - 1] = go.as_lint();
1184
1185 }
1186
1187 if (f_vv) {
1188 cout << "combinatorics_global::handle_input_file after input set " << h << " / "
1189 << SoS->nb_sets << ", " << input_file_idx << " / " << nb_input_files
1190 << ", we have " << CB->nb_types
1191 << " isomorphism types of objects" << endl;
1192 }
1193
1194 } // next h
1195 FREE_OBJECT(SoS);
1196
1197
1198 if (f_v) {
1199 cout << "combinatorics_global::handle_input_file fname=" << fname << ", "
1200 << input_file_idx << " / " << nb_input_files << " done" << endl;
1201 }
1202
1203}
1204
1205
1206void combinatorics_global::process_object(
1210 int nb_objects_to_test,
1211 int &f_found, int &idx,
1213 int verbose_level)
1214// does not store IG
1215{
1216 int f_v = (verbose_level >= 1);
1217
1218 if (f_v) {
1219 cout << "process_object n=" << CB->n << endl;
1220 }
1221
1222 if (f_v) {
1223 cout << "process_object "
1224 "before IG->set_stabilizer_and_canonical_form" << endl;
1225 }
1226
1227
1229 //f_save_incma_in_and_out, save_incma_in_and_out_prefix,
1230 TRUE /* f_compute_canonical_form */,
1231 Inc_out,
1232 verbose_level);
1233
1234
1235 if (f_v) {
1236 cout << "process_object "
1237 "after IG->set_stabilizer_and_canonical_form" << endl;
1238 }
1239
1240
1241 IG->A_perm->group_order(go);
1242
1243 if (FALSE) {
1244 cout << "generators for the automorphism group are:" << endl;
1246 }
1247
1248
1249 if (CB->n == 0) {
1250 cout << "process_object CB->n == 0, calling CB->init with "
1251 "IG->canonical_form_len=" << IG->canonical_form->get_allocated_length() << endl;
1252 CB->init(nb_objects_to_test, IG->canonical_form->get_allocated_length(), verbose_level);
1253 }
1254
1255#if 0
1256 if (f_v) {
1257 cout << "process_object before CB->search_and_add_if_new" << endl;
1258 cout << "canonical_form=";
1259 IG->print_canonical_form(cout);
1260
1261 }
1262#endif
1263
1264 CB->search_and_add_if_new(IG->canonical_form->get_data(), NULL /*IG*/, f_found, idx, verbose_level);
1265
1266
1267 if (f_v) {
1268 cout << "process_object done" << endl;
1269 }
1270}
1271
1272
1273
1274
1275
1276
1277}}}
1278
classification of 0/1 matrices using canonical forms
void search_and_add_if_new(uchar *data, void *extra_data, int &f_found, int &idx, int verbose_level)
description of input data for classification of geometric objects from the command line
void print(std::ostream &ost, std::vector< int > &v)
Definition: int_vec.cpp:413
void scan(std::string &s, int *&v, int &len)
Definition: int_vec.cpp:608
void matrix_print(long int *p, int m, int n)
Definition: lint_vec.cpp:203
void init_from_file(int &underlying_set_size, std::string &fname, int verbose_level)
void PG_element_rank_modified(int *v, int stride, int len, int &a)
void finite_field_init(int q, int f_without_tables, int verbose_level)
various functions related to geometries
Definition: geometry.h:721
int test_if_arc(field_theory::finite_field *Fq, int *pt_coords, int *set, int set_sz, int k, int verbose_level)
to rank and unrank subspaces of a fixed dimension in F_q^n
Definition: geometry.h:892
void unrank_longinteger(ring_theory::longinteger_object &rk, int verbose_level)
Definition: grassmann.cpp:627
void init(int n, int k, field_theory::finite_field *F, int verbose_level)
Definition: grassmann.cpp:70
interface for various incidence geometries
Definition: geometry.h:1099
void init_large_set(long int *blocks, int N_points, int design_b, int design_k, int partition_class_size, int *&partition, int verbose_level)
void lint_set_print_tex(std::ostream &ost, long int *v, int len)
void unrank_point(int *v, int stride, long int rk, int verbose_level)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
a permutation group in a fixed action.
Definition: actions.h:99
void element_print_quick(void *elt, std::ostream &ost)
Definition: action_cb.cpp:353
groups::strong_generators * Strong_gens
Definition: actions.h:130
void init_projective_group(int n, field_theory::finite_field *F, int f_semilinear, int f_basis, int f_init_sims, data_structures_groups::vector_ge *&nice_gens, int verbose_level)
void init_orthogonal_group(int epsilon, int n, field_theory::finite_field *F, int f_on_points, int f_on_lines, int f_on_points_and_lines, int f_semilinear, int f_basis, int verbose_level)
void group_order(ring_theory::longinteger_object &go)
Definition: action.cpp:2223
void init(geometry::incidence_structure *Inc, int *partition, int verbose_level)
void set_stabilizer_and_canonical_form(int f_compute_canonical_form, geometry::incidence_structure *&Inc_out, int verbose_level)
Schreier trees for orbits of groups on points.
Definition: groups.h:839
void compute_all_point_orbits(int verbose_level)
Definition: schreier.cpp:988
void init_single_generator(int *elt, int verbose_level)
Definition: schreier.cpp:360
void init(actions::action *A, int verbose_level)
Definition: schreier.cpp:308
a permutation group represented via a stabilizer chain
Definition: groups.h:1273
void group_order(ring_theory::longinteger_object &go)
Definition: sims.cpp:951
void random_element_of_order(int *elt, int order, int verbose_level)
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
orbit of sets using a Schreier tree, used in packing::make_spread_table
Definition: orbits.h:106
void create_design_table(design_create *DC, std::string &problem_label, design_tables *&T, groups::strong_generators *Gens, int verbose_level)
void load_design_table(design_create *DC, std::string &problem_label, design_tables *&T, groups::strong_generators *Gens, int verbose_level)
to create a known design using a description from class design_create_description
void unrank_block_in_PG_2_q(int *block, int rk, int verbose_level)
void init_from_file(actions::action *A, actions::action *A2, long int *initial_set, int design_size, std::string &label, groups::strong_generators *Strong_generators, int verbose_level)
void init(actions::action *A, actions::action *A2, long int *initial_set, int design_size, std::string &label, groups::strong_generators *Strong_generators, int verbose_level)
void read_classification_single_case(data_structures_groups::set_and_stabilizer *&Rep, int level, int case_nr, int verbose_level)
void init(design_create *DC, design_tables *T, int verbose_level)
void read_classification(data_structures_groups::orbit_transversal *&T, int level, int verbose_level)
the polar space arising from an orthogonal geometry
Definition: tl_geometry.h:709
void init(actions::action *A, orthogonal_geometry::orthogonal *O, int epsilon, int n, int k, field_theory::finite_field *F, int depth, int verbose_level)
Definition: polar.cpp:138
void dual_polar_graph(int depth, int orbit_idx, ring_theory::longinteger_object *&Rank_table, int &nb_maximals, int verbose_level)
Definition: polar.cpp:425
void init2(int depth, int verbose_level)
Definition: polar.cpp:180
void compute_orbits(int t0, int verbose_level)
Definition: polar.cpp:269
#define FREE_int(p)
Definition: foundations.h:640
#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 Int_vec_print_integer_matrix_width(A, B, C, D, E, F)
Definition: foundations.h:691
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define NEW_lint(n)
Definition: foundations.h:628
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects
induced_actions::action_on_orthogonal * AO