Orbiter 2022
Combinatorial Objects
geometry_builder.h
Go to the documentation of this file.
1/*
2 * geometry_builder.h
3 *
4 * Created on: Aug 24, 2021
5 * Author: betten
6 */
7
8#ifndef SRC_LIB_FOUNDATIONS_GEOMETRY_BUILDER_GEOMETRY_BUILDER_H_
9#define SRC_LIB_FOUNDATIONS_GEOMETRY_BUILDER_GEOMETRY_BUILDER_H_
10
11
12namespace orbiter {
13namespace layer1_foundations {
14namespace geometry_builder {
15
16
17#define COLOR_RED 2
18#define COLOR_GREEN 3
19
20// pick color codes from the list below:
21// the list is taken from void mp_graphics::color_tikz(ofstream &fp, int color)
22// line 2600
23
24#if 0
25if (color == 0)
26 fp << "white";
27else if (color == 1)
28 fp << "black";
29else if (color == 2)
30 fp << "red";
31else if (color == 3)
32 fp << "green";
33else if (color == 4)
34 fp << "blue";
35else if (color == 5)
36 fp << "cyan";
37else if (color == 6)
38 fp << "magenta";
39else if (color == 7)
40 fp << "pink";
41else if (color == 8)
42 fp << "orange";
43else if (color == 9)
44 fp << "lightgray";
45else if (color == 10)
46 fp << "brown";
47else if (color == 11)
48 fp << "lime";
49else if (color == 12)
50 fp << "olive";
51else if (color == 13)
52 fp << "gray";
53else if (color == 14)
54 fp << "purple";
55else if (color == 15)
56 fp << "teal";
57else if (color == 16)
58 fp << "violet";
59else if (color == 17)
60 fp << "darkgray";
61else if (color == 18)
62 fp << "lightgray";
63else if (color == 19)
64 fp << "yellow";
65else if (color == 20)
66 fp << "green!50!red";
67else if (color == 21)
68 fp << "violet!50!red";
69else if (color == 22)
70 fp << "cyan!50!red";
71else if (color == 23)
72 fp << "green!50!blue";
73else if (color == 24)
74 fp << "brown!50!red";
75else if (color == 25)
76 fp << "purple!50!red";
77else {
78#endif
79
80
81
82
83
84
85// #############################################################################
86// cperm.cpp
87// #############################################################################
88
90
91
92class cperm {
93
94public:
95 int l;
96 int *data;
97 // a permutation of { 0, 1 ... l - 1 }
98
99 cperm();
100 ~cperm();
101 void init_and_identity(int l);
102 void free();
103 void move_to(cperm *q);
104 void identity();
105 void mult(cperm *b, cperm *c);
106 void inverse(cperm *b);
107 void power(cperm *res, int exp);
108 void print();
109 void mult_apply_forwc_r(int i, int l);
110 /* a := a (i i+1 ... i+l-1). */
111 void mult_apply_tau_r(int i, int j);
112 /* a := a (i j). */
113 void mult_apply_tau_l(int i, int j);
114 /* a := (i j) a. */
115 void mult_apply_backwc_l(int i, int l);
116 /* a := (i+l-1 i+l-2 ... i+1 i) a. */
117
118};
119
120
121
122
123
124
125
126// #############################################################################
127// decomposition_with_fuse.cpp
128// #############################################################################
129
131
133
134public:
135
137
139 int *Fuse_first; // [nb_fuse]
140 int *Fuse_len; // [nb_fuse]
141
142 int *K0; // [gg->GB->v_len * gg->GB->b_len]
143 int *KK; // [gg->GB->v_len * gg->GB->b_len]
144 int *K1; // [gg->GB->v_len * gg->GB->b_len]
145 int *F_last_k_in_col; // [gg->GB->v_len * gg->GB->b_len]
146
147
148 gen_geo_conf *Conf; //[gg->GB->v_len * gg->GB->b_len]
149
150 // partition for Nauty:
152 // row partition: 1111011110...
153 // where the 0's indicate the end of a block
154 // The blocks are defined by the initial TDO decomposition.
156 // likewise, but for columns
157 // The blocks are defined by the initial TDO decomposition.
159 // [gg->GB->V + 1]
160 // combination of row and column partition,
161 // but with only i rows, so that it can be used
162 // for computing the canonical form of the partial geometry
163 // consisting of the first i rows only
165
166
169 gen_geo_conf *get_conf_IJ(int I, int J);
170 void init(gen_geo *gg, int verbose_level);
171 void TDO_init(int *v, int *b, int *theTDO, int verbose_level);
172 void init_tdo_line(int fuse_idx,
173 int tdo_line, int v, int *b, int *r, int verbose_level);
174 void print_conf();
175 void init_fuse(int verbose_level);
176 void init_k(int verbose_level);
177 void conf_init_last_non_zero_flag(int verbose_level);
178 void init_partition(int verbose_level);
179
180
181};
182
183
184
185// #############################################################################
186// gen_geo_conf.cpp
187// #############################################################################
188
190
191
193
194public:
196
197 int v;
198 int b;
199 int r;
200
201 int r0;
202 int i0;
203 int j0;
205 // only valid if J=0,
206 // that is, for those in the first column
207
208 gen_geo_conf();
210 void print(std::ostream &ost);
211
212};
213
214// #############################################################################
215// gen_geo.cpp
216// #############################################################################
217
219
220
221class gen_geo {
222
223public:
224
226
228
230
232
233 std::string inc_file_name;
234
235 // record the search tree in text files for later processing:
236 std::string fname_search_tree;
237 std::ofstream *ost_search_tree;
239 std::ofstream *ost_search_tree_flags;
240
242
244
246
247 gen_geo();
248 ~gen_geo();
249 void init(geometry_builder *GB, int verbose_level);
250 void init_semicanonical(int verbose_level);
251 void print_pairs(int line);
252 void main2(int verbose_level);
253 void generate_all(int verbose_level);
254 void setup_output_files(int verbose_level);
255 void close_output_files(int verbose_level);
256 void record_tree(int i1, int f_already_there);
257 void print_I_m(int I, int m);
258 void print(int v);
259 void increment_pairs_point(int i1, int col, int k);
260 void decrement_pairs_point(int i1, int col, int k);
261 void girth_test_add_incidence(int i, int j_idx, int j);
262 void girth_test_delete_incidence(int i, int j_idx, int j);
263 void girth_Floyd(int i, int verbose_level);
264 int check_girth_condition(int i, int j_idx, int j, int verbose_level);
265 int apply_tests(int I, int m, int J, int n, int j, int verbose_level);
266 void print(std::ostream &ost, int v, int v_cut);
267 void print_override_theX(std::ostream &ost, int *theX, int v, int v_cut);
268
269};
270
271// #############################################################################
272// geometric_backtrack_search.cpp
273// #############################################################################
274
276
277
279
280public:
281
283
286
289 void init(gen_geo *gg, int verbose_level);
290
291 int First(int verbose_level);
292 int Next(int verbose_level);
293 int BlockFirst(int I, int verbose_level);
294 int BlockNext(int I, int verbose_level);
295 int RowFirstSplit(int I, int m, int verbose_level);
296 int RowNextSplit(int I, int m, int verbose_level);
297 int geo_back_test(int I, int verbose_level);
298 int RowFirst0(int I, int m, int verbose_level);
299 int RowNext0(int I, int m, int verbose_level);
300 int RowFirst(int I, int m, int verbose_level);
301 int RowNext(int I, int m, int verbose_level);
302 int RowFirstLexLeast(int I, int m, int verbose_level);
303 int RowNextLexLeast(int I, int m, int verbose_level);
304 int RowFirstOrderly(int I, int m, int verbose_level);
305 void place_row(int I, int m, int idx, int verbose_level);
306 int RowNextOrderly(int I, int m, int verbose_level);
307 void RowClear(int I, int m);
308 int ConfFirst(int I, int m, int J, int verbose_level);
309 int ConfNext(int I, int m, int J, int verbose_level);
310 void ConfClear(int I, int m, int J);
311 int XFirst(int I, int m, int J, int n, int verbose_level);
312 int XNext(int I, int m, int J, int n, int verbose_level);
313 void XClear(int I, int m, int J, int n);
314 int X_First(int I, int m, int J, int n, int j, int verbose_level);
315 int TryToPlace(int I, int m, int J, int n, int j, int verbose_level);
316
317};
318
319
320
321// #############################################################################
322// geometry_builder_description.cpp
323// #############################################################################
324
326
327
329public:
330
331 int f_V;
332 std::string V_text;
333 int f_B;
334 std::string B_text;
335 int f_TDO;
336 std::string TDO_text;
338 std::string fuse_text;
339
341 int girth;
342
343 // f_lambda and f_find_square are mutually exclusive!
344
347
350
353
355
356 std::vector<std::string> test_lines;
357
358 std::vector<std::string> test2_lines;
359
364
365 std::vector<int> print_at_line;
366
368 std::string fname_GEO;
369
372 int read_arguments(
373 int argc, std::string *argv,
374 int verbose_level);
375 void print();
376
377};
378
379
380
381// #############################################################################
382// geometry_builder.cpp
383// #############################################################################
384
386
387
388
389
390
392
393public:
394
396
397
398 // the row partition:
399 int *v;
400 int v_len;
401
402 // the column partition:
403 int *b;
404 int b_len;
405
406 // a coarse grain partition of the row partition
407 int *fuse;
409
410 // the structure constants (# of incidences in a row)
411 int *TDO;
413
414
415 int V;
416 // = sum(i = 0; i < v_len; i++) v[i]
417 int B;
418 // = sum(i= 0; i < b_len; i++) b[i]
419
420 int *R; // [V]
421
422
425 std::string fname;
426
427 std::string control_file_name;
428 int no;
432
436 int verbose_level);
437 void compute_VBR(int verbose_level);
438 void print_tdo();
439 void isot(int line, int verbose_level);
440 void isot_no_vhbars(int verbose_level);
441 void isot2(int line, int verbose_level);
442 void set_split(int line, int remainder, int modulo);
443
444};
445
446
447
448
449
450// #############################################################################
451// girth_test.cpp
452// #############################################################################
453
455
456
457
458
459
461
462public:
463
465
466 int girth;
467 int V; // = gg->GB->V
468
469 int **S; // [V][V * V]
470 int **D; // [V][V * V]
471
472 girth_test();
473 ~girth_test();
474 void init(gen_geo *gg, int girth, int verbose_level);
475 void Floyd(int row, int verbose_level);
476 void add_incidence(int i, int j_idx, int j);
477 void delete_incidence(int i, int j_idx, int j);
478 int check_girth_condition(int i, int j_idx, int j, int verbose_level);
479 void print_Si(int i);
480 void print_Di(int i);
481
482};
483
484
485
486
487// #############################################################################
488// inc_encoding.cpp
489// #############################################################################
490
492
494
495public:
496 int *theX; // [v * dim_n]
497 int dim_n;
498 int v; // # of rows
499 int b; // # of columns
500 int *R; // [v]
501 // R[i] is the number of incidences in row i
502
503 inc_encoding();
505 int &theX_ir(int i, int r);
506 void init(int v, int b, int *R, int verbose_level);
507 long int rank_row(int row);
508 void get_flags(int row, std::vector<int> &flags);
509 int find_square(int m, int n);
511 std::ostream &ost, gen_geo *gg, int f_print_isot, iso_type *it);
513 std::ostream &ost, int v_cur, int v_cut,
514 gen_geo *gg, int f_print_isot);
516 std::ostream &ost, int v_cur, int v_cut,
517 gen_geo *gg, int *the_X, int f_print_isot);
518 void print_permuted(cperm *pv, cperm *qv);
519 void apply_permutation(incidence *inc, int v,
520 int *theY, cperm *p, cperm *q, int verbose_level);
521
522
523};
524
525
526
527
528
529// #############################################################################
530// incidence.cpp
531// #############################################################################
532
534
535
537
538public:
539
542
543 int *K; //[gg->GB->B]
544 // K[j] is the current sum of incidences in column j
545
546 int **theY; //[gg->GB->B][gg->GB->V];
547
548 int **pairs;
549 //[gg->GB->V][];
550 // pairs[i][i1]
551 // is the number of blocks containing {i1,i}
552 // where 0 \le i1 < i.
553
554
555
557
558 iso_type **iso_type_at_line; // [gg->GB->V]
560
562
563
564 incidence();
565 ~incidence();
566 void init(gen_geo *gg, int v, int b, int *R, int verbose_level);
567 void init_pairs(int verbose_level);
568 void print_pairs(int v);
569 int find_square(int m, int n);
570 void print_param();
571 void free_isot();
572 void print_R(int v, cperm *p, cperm *q);
574 int f_orderly, int verbose_level);
576 int f_orderly, int verbose_level);
577 void set_split(int row, int remainder, int modulo);
578 void print_geo(std::ostream &ost, int v, int *theGEO);
579 void print_inc(std::ostream &ost, int v, long int *theInc);
580 void print_blocks(std::ostream &ost, int v, long int *theInc);
581 void compute_blocks(long int *&Blocks, int *&K, int v, long int *theInc);
582 void compute_blocks_ranked(long int *&Blocks, int v, long int *theInc);
583 int compute_k(int v, long int *theInc);
584 int is_block_tactical(int v, long int *theInc);
585 void geo_to_inc(int v, int *theGEO, long int *theInc, int nb_flags);
586 void inc_to_geo(int v, long int *theInc, int *theGEO, int nb_flags);
587
588
589};
590
591
592
593
594
595// #############################################################################
596// iso_type.cpp
597// #############################################################################
598
600
601class iso_type {
602
603public:
604
606
607 int v;
608 int sum_R;
610
612
613 // test of the first or the second kind:
614 // (second kind means we only check those geometries
615 // that are completely realizable
618
622
623
624 std::string fname;
625
627
630
631 iso_type();
632 ~iso_type();
633 void init(gen_geo *gg, int v,
634 int f_orderly, int verbose_level);
635 void add_geometry(
636 inc_encoding *Encoding,
637 int f_partition_fixing_last,
638 int &f_already_there,
639 int verbose_level);
640 void find_and_add_geo(
641 int *theY,
642 int f_partition_fixing_last,
643 int &f_new_object, int verbose_level);
644 void second();
645 void set_split(int remainder, int modulo);
646 void print_geos(int verbose_level);
647 void write_inc_file(std::string &fname, int verbose_level);
648 void write_blocks_file(std::string &fname, int verbose_level);
649 void write_blocks_file_long(std::string &fname, int verbose_level);
650 void print_GEO(int *pc, int v, incidence *inc);
651 void print_status(std::ostream &ost, int f_with_flags);
652 void print_flags(std::ostream &ost);
653 void print_geometry(inc_encoding *Encoding, int v, incidence *inc);
654
655};
656
657
658
659
660
661// #############################################################################
662// test_semicanonical.cpp
663// #############################################################################
664
666
667
668
669
670
672
673public:
674
676
677 int MAX_V;
678
679 // initial vertical and horizontal bars
680 // to create semi-canonical partial geometries
682 int *i_vbar;
684 int *i_hbar;
685
686
687 int *f_vbar; // [gg->GB->V * gg->inc->Encoding->dim_n]
688 int *vbar; // [gg->GB->V]
689 int *hbar; // [gg->GB->B]
690
693 void init(gen_geo *gg, int MAX_V, int verbose_level);
694 void init_bars(int verbose_level);
695 void print();
696 void markers_update(int I, int m, int J, int n, int j,
697 int i1, int j0, int r,
698 int verbose_level);
699 void marker_move_on(int I, int m, int J, int n, int j,
700 int i1, int j0, int r,
701 int verbose_level);
702 int row_starter(int I, int m, int J, int n,
703 int i1, int j0, int r,
704 int verbose_level);
705 void row_init(int I, int m, int J,
706 int i1,
707 int verbose_level);
708 int col_marker_test(int j0, int j, int i1);
709 void col_marker_remove(int I, int m, int J, int n,
710 int i1, int j0, int r, int old_x);
711 void row_test_continue(int I, int m, int J, int i1);
712
713};
714
715
716
717
718
719
720
721}}}
722
723
724
725#endif /* SRC_LIB_FOUNDATIONS_GEOMETRY_BUILDER_GEOMETRY_BUILDER_H_ */
a permutation for use in class gen_geo
a row-tactical decomposition with fuse, to be used by the geometry_builder
void init_tdo_line(int fuse_idx, int tdo_line, int v, int *b, int *r, int verbose_level)
description of a configuration which is part of class decomposition_with_fuse
classification of geometries with a given row-tactical decomposition
void decrement_pairs_point(int i1, int col, int k)
Definition: gen_geo.cpp:572
void init(geometry_builder *GB, int verbose_level)
Definition: gen_geo.cpp:75
void girth_test_delete_incidence(int i, int j_idx, int j)
Definition: gen_geo.cpp:589
int apply_tests(int I, int m, int J, int n, int j, int verbose_level)
Definition: gen_geo.cpp:619
void increment_pairs_point(int i1, int col, int k)
Definition: gen_geo.cpp:562
void print_override_theX(std::ostream &ost, int *theX, int v, int v_cut)
Definition: gen_geo.cpp:823
void girth_test_add_incidence(int i, int j_idx, int j)
Definition: gen_geo.cpp:582
int check_girth_condition(int i, int j_idx, int j, int verbose_level)
Definition: gen_geo.cpp:603
void record_tree(int i1, int f_already_there)
Definition: gen_geo.cpp:500
classification of geometries with a given row-tactical decomposition
int TryToPlace(int I, int m, int J, int n, int j, int verbose_level)
void init_description(geometry_builder_description *Descr, int verbose_level)
int check_girth_condition(int i, int j_idx, int j, int verbose_level)
Definition: girth_test.cpp:150
void init(gen_geo *gg, int girth, int verbose_level)
Definition: girth_test.cpp:46
row-by-row encoding of an incidence geometry
void get_flags(int row, std::vector< int > &flags)
void print_partitioned(std::ostream &ost, int v_cur, int v_cut, gen_geo *gg, int f_print_isot)
void print_horizontal_bar(std::ostream &ost, gen_geo *gg, int f_print_isot, iso_type *it)
void init(int v, int b, int *R, int verbose_level)
void apply_permutation(incidence *inc, int v, int *theY, cperm *p, cperm *q, int verbose_level)
void print_partitioned_override_theX(std::ostream &ost, int v_cur, int v_cut, gen_geo *gg, int *the_X, int f_print_isot)
encoding of an incidence geometry during classification
void print_blocks(std::ostream &ost, int v, long int *theInc)
Definition: incidence.cpp:348
void print_inc(std::ostream &ost, int v, long int *theInc)
Definition: incidence.cpp:333
void init(gen_geo *gg, int v, int b, int *R, int verbose_level)
Definition: incidence.cpp:79
void print_geo(std::ostream &ost, int v, int *theGEO)
Definition: incidence.cpp:319
void inc_to_geo(int v, long int *theInc, int *theGEO, int nb_flags)
Definition: incidence.cpp:560
void compute_blocks_ranked(long int *&Blocks, int v, long int *theInc)
Definition: incidence.cpp:404
void geo_to_inc(int v, int *theGEO, long int *theInc, int nb_flags)
Definition: incidence.cpp:542
void set_split(int row, int remainder, int modulo)
Definition: incidence.cpp:305
void install_isomorphism_test_after_a_given_row(int i, int f_orderly, int verbose_level)
Definition: incidence.cpp:259
void install_isomorphism_test_of_second_kind_after_a_given_row(int i, int f_orderly, int verbose_level)
Definition: incidence.cpp:281
void compute_blocks(long int *&Blocks, int *&K, int v, long int *theInc)
Definition: incidence.cpp:363
classification of geometries based on canonical forms
void write_blocks_file(std::string &fname, int verbose_level)
Definition: iso_type.cpp:364
void print_GEO(int *pc, int v, incidence *inc)
Definition: iso_type.cpp:514
data_structures::classify_using_canonical_forms * Canonical_forms
void write_inc_file(std::string &fname, int verbose_level)
Definition: iso_type.cpp:319
void print_geometry(inc_encoding *Encoding, int v, incidence *inc)
Definition: iso_type.cpp:565
void print_status(std::ostream &ost, int f_with_flags)
Definition: iso_type.cpp:523
void add_geometry(inc_encoding *Encoding, int f_partition_fixing_last, int &f_already_there, int verbose_level)
Definition: iso_type.cpp:95
void init(gen_geo *gg, int v, int f_orderly, int verbose_level)
Definition: iso_type.cpp:55
void find_and_add_geo(int *theY, int f_partition_fixing_last, int &f_new_object, int verbose_level)
Definition: iso_type.cpp:158
void write_blocks_file_long(std::string &fname, int verbose_level)
Definition: iso_type.cpp:422
void col_marker_remove(int I, int m, int J, int n, int i1, int j0, int r, int old_x)
void row_init(int I, int m, int J, int i1, int verbose_level)
int row_starter(int I, int m, int J, int n, int i1, int j0, int r, int verbose_level)
void init(gen_geo *gg, int MAX_V, int verbose_level)
void marker_move_on(int I, int m, int J, int n, int j, int i1, int j0, int r, int verbose_level)
void markers_update(int I, int m, int J, int n, int j, int i1, int j0, int r, int verbose_level)
the orbiter library for the classification of combinatorial objects