Orbiter 2022
Combinatorial Objects
object_with_properties.cpp
Go to the documentation of this file.
1/*
2 * object_with_properties.cpp
3 *
4 * Created on: Dec 8, 2021
5 * Author: betten
6 */
7
8
9
10
11#include "orbiter.h"
12
13using namespace std;
14
15namespace orbiter {
16namespace layer5_applications {
17namespace apps_combinatorics {
18
19
21{
22 OwCF = NULL;
23
24 //std::string label;
25
26 NO = NULL;
27
29 PA = NULL;
30
31 SG = NULL;
32
33 A_perm = NULL;
34
35 TDO = NULL;
36
37 Flags = NULL;
38 Anti_Flags = NULL;
39
40}
41
43{
44
45 if (TDO) {
47 }
48 if (Flags) {
50 }
51 if (Anti_Flags) {
53 }
54}
55
56
60 int f_projective_space,
62 int max_TDO_depth,
63 std::string &label,
64 int verbose_level)
65{
66 int f_v = (verbose_level >= 1);
67
68 if (f_v) {
69 cout << "object_with_properties::init" << endl;
70 }
71
77
79
80 if (f_v) {
81 cout << "object_with_properties::init before Nau.automorphism_group_as_permutation_group" << endl;
82 }
84 NO,
85 A_perm,
86 verbose_level - 2);
87
88 if (f_v) {
89 cout << "object_with_properties::init after Nau.automorphism_group_as_permutation_group" << endl;
90 }
91
92 if (f_v) {
93 cout << "object_with_properties::init "
94 "A_perm:" << endl;
95
99 }
100
101 if (f_projective_space) {
102 if (f_v) {
103 cout << "object_with_properties::init "
104 "before lift_generators_to_matrix_group" << endl;
105 }
106
107 lift_generators_to_matrix_group(verbose_level - 2);
108
109 if (f_v) {
110 cout << "object_with_properties::init "
111 "after lift_generators_to_matrix_group" << endl;
112 }
113 }
114
115 if (f_v) {
116 cout << "object_with_properties::init "
117 "before compute_flag_orbits" << endl;
118 }
119 compute_flag_orbits(verbose_level - 2);
120 if (f_v) {
121 cout << "object_with_properties::init "
122 "after compute_flag_orbits" << endl;
123 }
124
125 if (f_v) {
126 cout << "object_with_properties::init "
127 "before compute_TDO" << endl;
128 }
129 compute_TDO(max_TDO_depth, verbose_level - 2);
130 if (f_v) {
131 cout << "object_with_properties::init "
132 "after compute_TDO" << endl;
133 }
134
135 if (f_v) {
136 cout << "object_with_properties::init done" << endl;
137 }
138}
139
141{
142 int f_v = (verbose_level >= 1);
143
144 if (f_v) {
145 cout << "object_with_properties::compute_flag_orbits" << endl;
146 }
147
150
151 if (f_v) {
152 cout << "object_with_properties::compute_flag_orbits "
153 "before Flags->init" << endl;
154 }
155 Flags->init(this, FALSE, A_perm, A_perm->Strong_gens, verbose_level - 2);
156 if (f_v) {
157 cout << "object_with_properties::compute_flag_orbits "
158 "after Flags->init" << endl;
159 }
160
161 if (f_v) {
162 cout << "object_with_properties::compute_flag_orbits "
163 "before Anti_Flags->init" << endl;
164 }
165 Anti_Flags->init(this, TRUE, A_perm, A_perm->Strong_gens, verbose_level - 2);
166 if (f_v) {
167 cout << "object_with_properties::compute_flag_orbits "
168 "after Anti_Flags->init" << endl;
169 }
170
171 if (f_v) {
172 cout << "object_with_properties::compute_flag_orbits done" << endl;
173 }
174}
175
177{
178 int f_v = (verbose_level >= 1);
179
180 if (f_v) {
181 cout << "object_with_properties::lift_generators_to_matrix_group" << endl;
182 }
183 //strong_generators *SG;
185
187
188 if (f_v) {
189 cout << "object_with_properties::lift_generators_to_matrix_group "
190 "before Naug.reverse_engineer_linear_group_from_permutation_group" << endl;
191 }
192
194 PA->A /* A_linear */,
195 PA->P,
196 SG,
197 A_perm,
198 NO,
199 verbose_level);
200
201 if (f_v) {
202 cout << "object_with_properties::lift_generators_to_matrix_group "
203 "after Naug.reverse_engineer_linear_group_from_permutation_group" << endl;
204 }
205
206
208
209 if (f_v) {
210 cout << "object_with_properties::lift_generators_to_matrix_group done" << endl;
211 }
212}
213
218 std::string &label,
219 int verbose_level)
220{
221 int f_v = (verbose_level >= 1);
222
223 if (f_v) {
224 cout << "object_with_properties::init_object_in_projective_space" << endl;
225 }
226
230
231
233 actions::action *A_linear;
234
235 A_linear = PA->A;
236
237 if (f_v) {
238 cout << "object_with_properties::init_object_in_projective_space "
239 "before Nau.reverse_engineer_linear_group_from_permutation_group" << endl;
240 }
242 A_linear,
243 PA->P,
244 SG,
245 A_perm,
246 NO,
247 verbose_level);
248 if (f_v) {
249 cout << "object_with_properties::init_object_in_projective_space "
250 "after Nau.reverse_engineer_linear_group_from_permutation_group" << endl;
251 }
252
253
254 if (f_v) {
255 cout << "object_with_properties::init_object_in_projective_space done" << endl;
256 }
257
258}
259
262 int verbose_level)
263{
264 int f_v = (verbose_level >= 1);
265
266 if (f_v) {
267 cout << "object_with_properties::latex_report" << endl;
268 }
269
270 ost << "Generators for the automorphism group: \\\\" << endl;
271 if (A_perm->degree < 100) {
273 }
274 else {
275 ost << "permutation degree is too large to print. \\\\" << endl;
276
277 }
278
279 if (f_projective_space) {
280
281 ost << "Generators for the automorphism group as matrix group: \\\\" << endl;
282
283 if (f_v) {
284 cout << "object_with_properties::latex_report before SG->print_generators_in_latex_individually" << endl;
285 }
287 if (f_v) {
288 cout << "object_with_properties::latex_report after SG->print_generators_in_latex_individually" << endl;
289 }
290 }
291
292
293 if (Report_options->f_export_group) {
294
295 std::string fname;
296 std::string label_txt;
297 std::string label_tex;
298
299
300 fname.assign(label);
301 fname.append("_aut.makefile");
302 label_txt.assign(label);
303 label_txt.append("_aut");
304 label_tex.assign(label);
305 label_tex.append("\\_aut");
306
307 if (f_v) {
308 cout << "object_with_properties::latex_report before A_perm->Strong_gens->export_to_orbiter_as_bsgs" << endl;
309 }
311 A_perm,
312 fname, label, label_tex,
313 verbose_level);
314 if (f_v) {
315 cout << "object_with_properties::latex_report after A_perm->Strong_gens->export_to_orbiter_as_bsgs" << endl;
316 }
317 }
318
319
320
321
322 groups::schreier *Sch;
323
324
325 if (f_v) {
326 cout << "object_with_properties::latex_report before orbits_on_points_schreier" << endl;
327 }
329 verbose_level);
330 if (f_v) {
331 cout << "object_with_properties::latex_report after orbits_on_points_schreier" << endl;
332 }
333
334
335 if (Report_options->f_export_flag_orbits) {
336 if (f_v) {
337 cout << "object_with_properties::latex_report before export_INP_with_flag_orbits" << endl;
338 }
340 Sch,
341 verbose_level);
342 if (f_v) {
343 cout << "object_with_properties::latex_report after export_INP_with_flag_orbits" << endl;
344 }
345
346 if (f_v) {
347 cout << "object_with_properties::latex_report before export_TDA_with_flag_orbits" << endl;
348 }
350 Sch,
351 verbose_level);
352 if (f_v) {
353 cout << "object_with_properties::latex_report after export_TDA_with_flag_orbits" << endl;
354 }
355 }
356
357 if (Report_options->f_show_TDO) {
358
359 ost << "Decomposition by combinatorial refinement:\\\\" << endl;
360
361 if (f_v) {
362 cout << "object_with_properties::latex_report before Sch->print_TDA" << endl;
363 }
364 print_TDO(ost, Report_options);
365 if (f_v) {
366 cout << "object_with_properties::latex_report after Sch->print_TDA" << endl;
367 }
368 }
369
370 if (Report_options->f_show_TDA) {
371
372 ost << "Decomposition by automorphism group:\\\\" << endl;
373
374 if (f_v) {
375 cout << "object_with_properties::latex_report before Sch->print_TDA" << endl;
376 }
377 Sch->print_TDA(ost, OwCF, Report_options, verbose_level);
378 if (f_v) {
379 cout << "object_with_properties::latex_report after Sch->print_TDA" << endl;
380 }
381 }
382
383 ost << "Canonical labeling:\\\\" << endl;
386
387 if (f_v) {
388 cout << "object_with_properties::latex_report before OwCF->encode_incma" << endl;
389 }
390 OwCF->encode_incma(Enc, verbose_level);
391 if (f_v) {
392 cout << "object_with_properties::latex_report after OwCF->encode_incma" << endl;
393 }
394
395
397
398 Enc2->init_canonical_form(Enc, NO, verbose_level);
399
400
401
402 int canonical_row;
403 int canonical_orbit;
404
405 canonical_row = NO->canonical_labeling[Enc->nb_rows - 1];
406
407 canonical_orbit = Sch->orbit_number(canonical_row);
408
409 ost << "canonical row = " << canonical_row << "\\\\" << endl;
410 ost << "canonical orbit number = " << canonical_orbit << "\\\\" << endl;
411
412 Enc2->latex_set_system_by_rows(ost, verbose_level);
413
414 FREE_OBJECT(Enc2);
415
416 if (Report_options->f_show_incidence_matrices) {
417
418 int v = Enc->nb_rows;
419 int b = Enc->nb_cols;
420
421 std::string *point_labels;
422 std::string *block_labels;
423
424
425 point_labels = new string [v];
426 block_labels = new string [b];
427
428 int i, j, a;
429
430 char str[1000];
431
432 for (i = 0; i < v; i++) {
433
434 a = NO->canonical_labeling[i];
435 if (Sch->orbit_number(a) == canonical_orbit) {
436 sprintf(str, "*%d", a);
437 }
438 else {
439 sprintf(str, "%d", a);
440 }
441 point_labels[i].assign(str);
442 }
443 for (j = 0; j < b; j++) {
444 sprintf(str, "%d", NO->canonical_labeling[v + j]);
445 block_labels[j].assign(str);
446 }
447
449 point_labels,
450 block_labels,
451 verbose_level);
452
453 delete [] point_labels;
454 delete [] block_labels;
455
456 FREE_OBJECT(Enc);
457 }
458
459 ost << "Flag orbits:\\\\" << endl;
460 Flags->report(ost, verbose_level);
461
462 ost << "Anti-Flag orbits:\\\\" << endl;
463 Anti_Flags->report(ost, verbose_level);
464
465
466 if (Report_options->f_lex_least) {
467
468 if (f_v) {
469 cout << "object_with_properties::latex_report f_lex_least" << endl;
470 }
471 int idx;
472
474
476
478 if (t != t_geometry_builder) {
479 cout << "object_with_properties::latex_report "
480 << Report_options->lex_least_geometry_builder
481 << " is not of type geometry_builder" << endl;
482 exit(1);
483 }
484
486 int f_found;
488 data_structures::bitvector *Canonical_form;
489
491
492
493 if (f_v) {
494 cout << "object_with_properties::latex_report before find_object, "
495 "OwCF->v=" << OwCF->v << endl;
496 }
497
499 OwCF,
500 f_found, idx,
501 NO,
502 Canonical_form,
503 verbose_level);
504
505 if (f_v) {
506 cout << "object_with_properties::latex_report after find_object" << endl;
507 }
508
509 // if f_found is TRUE, B[idx] agrees with the given object
510
511
512 if (!f_found) {
513 cout << "object_with_properties::latex_report "
514 "cannot find object in geometry_builder" << endl;
515 exit(1);
516 }
517
520
521 if (f_v) {
522 cout << "object_with_properties::latex_report before FREE_OBJECT(NO)" << endl;
523 }
525 if (f_v) {
526 cout << "object_with_properties::latex_report after FREE_OBJECT(NO)" << endl;
527 }
528 FREE_OBJECT(Canonical_form);
529 if (f_v) {
530 cout << "object_with_properties::latex_report after FREE_OBJECT(Canonical_form)" << endl;
531 }
532
533 ost << "Is isomorphic to object " << idx << " in the list:\\\\" << endl;
534 ost << "Lex-least form is:\\\\" << endl;
535
536 OwCF2->print_tex_detailed(ost,
537 Report_options->f_show_incidence_matrices,
538 verbose_level);
539 }
540
541
542 if (f_v) {
543 cout << "object_with_properties::latex_report done" << endl;
544 }
545
546}
547
548void object_with_properties::compute_TDO(int max_TDO_depth, int verbose_level)
549{
550 int f_v = (verbose_level >= 1);
551
552 if (f_v) {
553 cout << "object_with_properties::compute_TDO" << endl;
554 }
556
557 OwCF->encode_incma(Enc, verbose_level);
558
559
560
562
563 TDO->init(Enc, max_TDO_depth, verbose_level);
564
565
566 //latex_TDA(ost, Enc, verbose_level);
567
568 FREE_OBJECT(Enc);
569 if (f_v) {
570 cout << "object_with_properties::compute_TDO done" << endl;
571 }
572
573}
574
577{
578
579 TDO->print_schemes(ost);
580
581}
582
584 groups::schreier *Sch,
585 int verbose_level)
586{
587 int f_v = (verbose_level >= 1);
588
589 if (f_v) {
590 cout << "object_with_properties::export_TDA_with_flag_orbits" << endl;
591 }
592
594
595 OwCF->encode_incma(Enc, verbose_level);
596
598 string fname;
599
600
601 int *Inc2;
602 int i0, j0;
603 int i, j;
604
605 Inc2 = NEW_int(Enc->nb_rows * Enc->nb_cols);
606 Int_vec_zero(Inc2, Enc->nb_rows * Enc->nb_cols);
607
609 int *Inc_flag_orbits;
610 int nb_orbits_on_flags;
611 int idx;
612 int orbit_idx;
613
614 Inc_flag_orbits = NEW_int(Enc->nb_rows * Enc->nb_cols);
615 nb_orbits_on_flags = Flags->Orb->Sch->nb_orbits;
616 for (i = 0; i < Enc->nb_rows; i++) {
617 i0 = Sch->orbit[i];
618 for (j = 0; j < Enc->nb_cols; j++) {
619 j0 = Sch->orbit[Enc->nb_rows + j] - Enc->nb_rows;
620 if (Enc->get_incidence_ij(i0, j0)) {
621 idx = Flags->find_flag(i0, j0 + Enc->nb_rows);
622 orbit_idx = Flags->Orb->Sch->orbit_number(idx);
623 Inc_flag_orbits[i * Enc->nb_cols + j] = orbit_idx + 1;
624 }
625 else {
626 idx = Anti_Flags->find_flag(i0, j0 + Enc->nb_rows);
627 orbit_idx = Anti_Flags->Orb->Sch->orbit_number(idx);
628 Inc_flag_orbits[i * Enc->nb_cols + j] = nb_orbits_on_flags + orbit_idx + 1;
629 }
630 }
631 }
632
633 fname.assign(label);
634 fname.append("_TDA.csv");
635
636 fname.assign(label);
637 fname.append("_TDA_flag_orbits.csv");
638
639 Fio.int_matrix_write_csv(fname, Inc_flag_orbits, Enc->nb_rows, Enc->nb_cols);
640 if (f_v) {
641 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
642 }
643
644 FREE_int(Inc_flag_orbits);
645
646 }
647
648 // +1 avoids the color white
649
650 for (i = 0; i < Enc->nb_rows; i++) {
651 i0 = Sch->orbit[i];
652 for (j = 0; j < Enc->nb_cols; j++) {
653 j0 = Sch->orbit[Enc->nb_rows + j] - Enc->nb_rows;
654 if (Enc->get_incidence_ij(i0, j0)) {
655 Inc2[i * Enc->nb_cols + j] = 1;
656 }
657 else {
658 Inc2[i * Enc->nb_cols + j] = 0;
659 }
660 }
661
662 }
663
664
665 fname.assign(label);
666 fname.append("_INP.csv");
667
668 Fio.int_matrix_write_csv(fname, Inc2, Enc->nb_rows, Enc->nb_cols);
669 if (f_v) {
670 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
671 }
672
673
674
675 FREE_int(Inc2);
676 FREE_OBJECT(Enc);
677
678 if (f_v) {
679 cout << "object_with_properties::export_TDA_with_flag_orbits done" << endl;
680 }
681}
682
684 groups::schreier *Sch,
685 int verbose_level)
686// INP = input geometry
687{
688 int f_v = (verbose_level >= 1);
689
690 if (f_v) {
691 cout << "object_with_properties::export_INP_with_flag_orbits" << endl;
692 }
693
695
696 if (f_v) {
697 cout << "object_with_properties::export_INP_with_flag_orbits before OwCF->encode_incma" << endl;
698 }
699 OwCF->encode_incma(Enc, verbose_level);
700 if (f_v) {
701 cout << "object_with_properties::export_INP_with_flag_orbits after OwCF->encode_incma" << endl;
702 cout << "object_with_properties::export_INP_with_flag_orbits Enc->nb_rows = " << Enc->nb_rows << endl;
703 cout << "object_with_properties::export_INP_with_flag_orbits Enc->nb_cols = " << Enc->nb_cols << endl;
704 }
705
707 string fname;
708
709
710 int *Inc2;
711 int i0, j0;
712 int i, j;
713
714 Inc2 = NEW_int(Enc->nb_rows * Enc->nb_cols);
715 Int_vec_zero(Inc2, Enc->nb_rows * Enc->nb_cols);
716
718 int *Inc_flag_orbits;
719 int nb_orbits_on_flags;
720 int idx;
721 int orbit_idx;
722
723 Inc_flag_orbits = NEW_int(Enc->nb_rows * Enc->nb_cols);
724 nb_orbits_on_flags = Flags->Orb->Sch->nb_orbits;
725 for (i = 0; i < Enc->nb_rows; i++) {
726 i0 = i;
727 for (j = 0; j < Enc->nb_cols; j++) {
728 j0 = j;
729 if (Enc->get_incidence_ij(i0, j0)) {
730 idx = Flags->find_flag(i0, j0 + Enc->nb_rows);
731 orbit_idx = Flags->Orb->Sch->orbit_number(idx);
732 Inc_flag_orbits[i * Enc->nb_cols + j] = orbit_idx + 1;
733 }
734 else {
735 idx = Anti_Flags->find_flag(i0, j0 + Enc->nb_rows);
736 orbit_idx = Anti_Flags->Orb->Sch->orbit_number(idx);
737 Inc_flag_orbits[i * Enc->nb_cols + j] = nb_orbits_on_flags + orbit_idx + 1;
738 }
739 }
740 }
741
742 fname.assign(label);
743 fname.append("_INP.csv");
744
745 fname.assign(label);
746 fname.append("_INP_flag_orbits.csv");
747
748 Fio.int_matrix_write_csv(fname, Inc_flag_orbits, Enc->nb_rows, Enc->nb_cols);
749 if (f_v) {
750 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
751 }
752
753 FREE_int(Inc_flag_orbits);
754
755 }
756
757 // +1 avoids the color white
758
759 for (i = 0; i < Enc->nb_rows; i++) {
760 i0 = i;
761 for (j = 0; j < Enc->nb_cols; j++) {
762 j0 = j;
763 if (Enc->get_incidence_ij(i0, j0)) {
764 Inc2[i * Enc->nb_cols + j] = 1;
765 }
766 else {
767 Inc2[i * Enc->nb_cols + j] = 0;
768 }
769 }
770
771 }
772
773
774 fname.assign(label);
775 fname.append("_INP.csv");
776
777 Fio.int_matrix_write_csv(fname, Inc2, Enc->nb_rows, Enc->nb_cols);
778 if (f_v) {
779 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
780 }
781
782
783
784 FREE_int(Inc2);
785 FREE_OBJECT(Enc);
786
787 if (f_v) {
788 cout << "object_with_properties::export_INP_with_flag_orbits done" << endl;
789 }
790}
791
792
793}}}
options for the report for a classification of combinatorial objects
encoding of combinatorial object for use with nauty
void init_canonical_form(encoded_combinatorial_object *Enc, data_structures::nauty_output *NO, int verbose_level)
void latex_canonical_form_with_labels(std::ostream &ost, data_structures::nauty_output *NO, std::string *row_labels, std::string *col_labels, int verbose_level)
tactical decomposition of an incidence structure obtained by refinement
void init(encoded_combinatorial_object *Enc, int max_depth, int verbose_level)
compact storage of 0/1-data as bitvectors
void find_object(geometry::object_with_canonical_form *OwCF, int &f_found, int &idx, nauty_output *&NO, bitvector *&Canonical_form, int verbose_level)
a combinatorial object for which a canonical form can be computed using Nauty
Definition: geometry.h:1487
void encode_incma(combinatorics::encoded_combinatorial_object *&Enc, int verbose_level)
void print_tex_detailed(std::ostream &ost, int f_show_incma, int verbose_level)
data_structures::classify_using_canonical_forms * Canonical_forms
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
Definition: file_io.cpp:1300
a permutation group in a fixed action.
Definition: actions.h:99
groups::strong_generators * Strong_gens
Definition: actions.h:130
Interface to the graph canonization software Nauty.
Definition: actions.h:1154
void automorphism_group_as_permutation_group(data_structures::nauty_output *NO, actions::action *&A_perm, int verbose_level)
void reverse_engineer_linear_group_from_permutation_group(actions::action *A_linear, geometry::projective_space *P, groups::strong_generators *&SG, actions::action *&A_perm, data_structures::nauty_output *NO, int verbose_level)
Schreier trees for orbits of groups on points.
Definition: groups.h:839
void print_TDA(std::ostream &ost, geometry::object_with_canonical_form *OwCF, combinatorics::classification_of_objects_report_options *Report_options, int verbose_level)
Definition: schreier.cpp:3342
schreier * orbits_on_points_schreier(actions::action *A_given, int verbose_level)
void export_to_orbiter_as_bsgs(actions::action *A2, std::string &fname, std::string &label, std::string &label_tex, int verbose_level)
void init(object_with_properties *OwP, int f_anti_flags, actions::action *A_perm, groups::strong_generators *SG, int verbose_level)
void print_TDO(std::ostream &ost, combinatorics::classification_of_objects_report_options *Report_options)
void init_object_in_projective_space(geometry::object_with_canonical_form *OwCF, data_structures::nauty_output *NO, projective_geometry::projective_space_with_action *PA, std::string &label, int verbose_level)
void export_TDA_with_flag_orbits(std::ostream &ost, groups::schreier *Sch, int verbose_level)
void export_INP_with_flag_orbits(std::ostream &ost, groups::schreier *Sch, int verbose_level)
void init(geometry::object_with_canonical_form *OwCF, data_structures::nauty_output *NO, int f_projective_space, projective_geometry::projective_space_with_action *PA, int max_TDO_depth, std::string &label, int verbose_level)
projective_geometry::projective_space_with_action * PA
void latex_report(std::ostream &ost, combinatorics::classification_of_objects_report_options *Report_options, int verbose_level)
projective space PG(n,q) with automorphism group PGGL(n+1,q)
#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 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
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects