Orbiter 2022
Combinatorial Objects
poset_classification_classify.cpp
Go to the documentation of this file.
1// poset_classification_classify.cpp
2//
3// Anton Betten
4//
5// moved here from poset_classification.cpp
6// July 19, 2014
7
8
10#include "discreta/discreta.h"
13
14using namespace std;
15
16namespace orbiter {
17namespace layer4_classification {
18namespace poset_classification {
19
20
21void poset_classification::compute_orbits_on_subsets(
22 int target_depth,
25 int verbose_level)
26{
27 int f_v = (verbose_level >= 1);
28 //int nb_poset_orbit_nodes = 1000;
29 int schreier_depth = target_depth;
30 int f_use_invariant_subset_if_available = TRUE;
31 int f_debug = FALSE;
33 int t0 = Os.os_ticks();
34
35
36 if (f_v) {
37 cout << "poset_classification::compute_orbits_on_subsets "
38 "verbose_level=" << verbose_level << endl;
39 }
40
41 depth = target_depth;
42 downstep_orbits_print_max_orbits = 50;
43 downstep_orbits_print_max_points_per_orbit = INT_MAX;
44
45
46 // !!!
47 f_allowed_to_show_group_elements = FALSE;
48
49 if (f_v) {
50 cout << "poset_classification::compute_orbits_on_subsets "
51 "calling initialize_and_allocate_root_node" << endl;
52 }
54 Poset,
55 target_depth, verbose_level - 1);
56
57
58 //init_poset_orbit_node(nb_poset_orbit_nodes, verbose_level - 1);
59 //init_root_node(verbose_level - 1);
60
61 if (f_v) {
62 cout << "poset_classification::compute_orbits_on_subsets "
63 "calling main" << endl;
64 }
65 main(t0,
66 schreier_depth,
67 f_use_invariant_subset_if_available,
68 f_debug,
69 verbose_level);
70 if (f_v) {
71 cout << "poset_classification::compute_orbits_on_subsets "
72 "after main" << endl;
73 }
74
75 int i, fst, len;
76
77 if (f_v) {
78 cout << "poset_classification::compute_orbits_on_subsets done" << endl;
79 cout << "depth : number of orbits" << endl;
80 }
81 for (i = 0; i < target_depth + 1; i++) {
82 fst = Poo->first_node_at_level(i);
83 len = Poo->first_node_at_level(i + 1) - fst;
84 if (f_v) {
85 cout << i << " : " << len << endl;
86 }
87 }
88
89 long int N, F, level;
90
91 N = 0;
92 F = 0;
93 for (level = 0; level <= target_depth; level++) {
94 N += nb_orbits_at_level(level);
95 }
96 for (level = 0; level < target_depth; level++) {
98 }
99 if (f_v) {
100 cout << "poset_classification::compute_orbits_on_subsets N=" << N << endl;
101 cout << "poset_classification::compute_orbits_on_subsets F=" << F << endl;
102 }
103
104 if (f_v) {
105 cout << "poset_classification::compute_orbits_on_subsets "
106 "done" << endl;
107 }
108}
109
110
111
113 int schreier_depth,
114 int f_use_invariant_subset_if_available,
115 int f_debug,
116 int verbose_level)
117// f_use_invariant_subset_if_available
118// is an option that affects the downstep.
119// if FALSE, the orbits of the stabilizer on all points are computed.
120// if TRUE, the orbits of the stabilizer on the set of points that were
121// possible in the previous level are computed only
122// (using Schreier.orbits_on_invariant_subset_fast).
123// The set of possible points is stored
124// inside the schreier vector data structure (sv).
125{
126 int f_v = (verbose_level >= 1);
127 int size, depth_completed = 0;
128 //int f_create_schreier_vector;
129 int target_depth;
130 //int f_write_files;
131 //int f_embedded = TRUE;
133
134 if (f_v) {
135 cout << "poset_classification::main" << endl;
136 cout << "poset_classification::main ";
138 cout << " depth = " << depth << endl;
139 cout << "f_W = " << Control->f_W << endl;
140 cout << "f_w = " << Control->f_w << endl;
141 cout << "verbose_level = " << verbose_level << endl;
142 Control->print();
143 }
144 if (Control->f_recover) {
145 if (f_v) {
146 cout << "poset_classification::main: recovering from file "
147 << Control->recover_fname << endl;
148 }
149
150
151 int t1, dt;
152 t1 = Os.os_ticks();
153 dt = t1 - t0;
154
155 cout << "Time ";
156 Os.time_check_delta(cout, dt);
157 cout << endl;
158
159
160 recover(Control->recover_fname, depth_completed, verbose_level - 1);
161
162 if (f_v) {
163 cout << "depth_completed = " << depth_completed << endl;
164 cout << "poset_classification::main: "
165 "recreating schreier vectors "
166 "to depth " << depth_completed - 1 << endl;
167 }
168
169 recreate_schreier_vectors_up_to_level(depth_completed - 1,
170 verbose_level /*MINIMUM(verbose_level, 1)*/);
171 }
172 if (f_base_case) {
173 depth_completed = Base_case->size;
174 }
175
176
177 if (Control->f_depth) {
178 target_depth = Control->depth;
179 }
180 else {
181 target_depth = depth;
182 }
183 if (f_v) {
184 cout << "poset_classification::main "
185 "target_depth=" << target_depth << endl;
186 }
187
188
189
190 if (f_v) {
191 cout << "poset_classification::main before compute_orbits" << endl;
192 }
193 size = compute_orbits(depth_completed, target_depth,
194 schreier_depth,
195 f_use_invariant_subset_if_available,
196 verbose_level);
197 if (f_v) {
198 cout << "poset_classification::main after compute_orbits" << endl;
199 }
200
201
202
203
204 if (f_v) {
205 cout << "poset_classification::main before post_processing" << endl;
206 }
207 post_processing(size, verbose_level);
208 if (f_v) {
209 cout << "poset_classification::main after post_processing" << endl;
210 }
211
212 if (f_v) {
213 cout << "poset_classification::main done" << endl;
214 }
215 return size;
216}
217
218int poset_classification::compute_orbits(int from_level, int to_level,
219 int schreier_depth,
220 int f_use_invariant_subset_if_available,
221 int verbose_level)
222// returns the last level that has at least one orbit
223{
224 int f_v = (verbose_level >= 1);
225 int level;
226 int f_create_schreier_vector = TRUE;
227 int f_debug = FALSE;
228 int f_write_files;
230
231
232 if (f_v) {
233 cout << "poset_classification::compute_orbits ";
235 cout << " from " << from_level << " to " << to_level << endl;
236 cout << "f_lex=" << Control->f_lex << endl;
237 cout << "problem_label_with_path=" << problem_label_with_path << endl;
238 cout << "schreier_depth=" << schreier_depth << endl;
239 cout << "f_use_invariant_subset_if_available=" << f_use_invariant_subset_if_available << endl;
240 cout << "poset_classification_control:" << endl;
241 Control->print();
242 }
243
244
245 for (level = from_level; level < to_level; level++) {
246
247 if (f_v) {
248 cout << "poset_classification::compute_orbits: ";
250 cout << " level " << level << endl;
251 }
252
253 int f_write_candidate_file = FALSE;
254
255#if 1
256 if (Control->f_W && level) {
257 f_write_candidate_file = TRUE;
258 }
259
260 if (Control->f_w && level == to_level - 1) {
261 f_write_candidate_file = TRUE;
262 }
263#endif
264
265 if (level <= schreier_depth) {
266 f_create_schreier_vector = TRUE;
267 if (f_v) {
268 cout << "poset_classification::compute_orbits "
269 "we will store schreier vectors "
270 "for this level" << endl;
271 }
272 }
273 else {
274 if (f_v) {
275 cout << "poset_classification::compute_orbits "
276 "we will NOT store schreier vectors "
277 "for this level" << endl;
278 }
279 f_create_schreier_vector = FALSE;
280 }
281
282 if (f_v) {
283 cout << "poset_classification::compute_orbits: ";
285 cout << " before extend_level" << endl;
286 }
287 extend_level(level,
288 f_create_schreier_vector,
289 f_use_invariant_subset_if_available,
290 f_debug,
291 f_write_candidate_file,
292 verbose_level - 1);
293 if (f_v) {
294 cout << "poset_classification::compute_orbits: ";
296 cout << " after extend_level" << endl;
297 }
298
299
300 f_write_files = (Control->f_W || (Control->f_w && level == to_level - 1));
301
302
303 if (f_write_files) {
304
305 if (f_v) {
306 cout << "poset_classification::compute_orbits before write_reps_csv" << endl;
307 }
308 write_reps_csv(level + 1, verbose_level - 1);
309 if (f_v) {
310 cout << "poset_classification::compute_orbits after write_reps_csv" << endl;
311 }
312 }
313
314 if (Control->f_write_data_files) {
315 if (f_v) {
316 cout << "poset_classification::compute_orbits before housekeeping f_write_files = TRUE" << endl;
317 }
318 housekeeping(level + 1, f_write_files,
319 Os.os_ticks(), verbose_level - 1);
320 if (f_v) {
321 cout << "poset_classification::compute_orbits after housekeeping" << endl;
322 }
323 }
324 else {
325 if (f_v) {
326 cout << "poset_classification::compute_orbits before housekeeping_no_data_file" << endl;
327 }
329 Os.os_ticks(), verbose_level - 1);
330 if (f_v) {
331 cout << "poset_classification::compute_orbits after housekeeping_no_data_file" << endl;
332 }
333 }
334
335
336 int nb_nodes;
337 nb_nodes = nb_orbits_at_level(level + 1);
338 if (nb_nodes == 0) {
339 int j;
340 for (j = level + 2; j <= to_level + 1; j++) {
342 Poo->first_node_at_level(j - 1));
343 }
344 break;
345 }
346
347 } // next level
348
349
350 if (f_v) {
351 cout << "poset_classification::compute_orbits from "
352 << from_level << " to " << to_level << " done, "
353 "last level with nodes is " << level << endl;
354 }
355 return level;
356}
357
358
359void poset_classification::post_processing(int actual_size, int verbose_level)
360{
361 int f_v = (verbose_level >= 1);
362
363 if (f_v) {
364 cout << "poset_classification::post_processing problem_label_with_path=" << problem_label_with_path << " verbose_level=" << verbose_level << endl;
365 }
366
367 if (Control->f_write_tree) {
368 Poo->print_tree();
370 problem_label_with_path, depth,
371 Control->draw_options,
372 verbose_level - 1);
373
374 //return 0;
375 }
376 if (Control->f_table_of_nodes) {
377 if (f_v) {
378 cout << "poset_classification::post_processing f_table_of_nodes" << endl;
379 }
380 Poo->make_tabe_of_nodes(verbose_level);
381 }
382
383 if (Control->f_list_all) {
384 if (f_v) {
385 cout << "poset_classification::post_processing f_list_all" << endl;
386 }
387
388 int d;
389
390 for (d = 0; d <= depth; d++) {
391 cout << "There are " << nb_orbits_at_level(d)
392 << " orbits on subsets of size " << d << ":" << endl;
393
394#if 0
395 if (d < Descr->orbits_on_subsets_size) {
396 //continue;
397 }
398#endif
399
401 FALSE /* f_has_print_function */,
402 NULL /* void (*print_function)(ostream &ost, int len, int *S, void *data)*/,
403 NULL /* void *print_function_data*/,
404 Control->f_show_orbit_decomposition /* f_show_orbit_decomposition */,
405 Control->f_show_stab /* f_show_stab */,
406 Control->f_save_stab /* f_save_stab */,
407 Control->f_show_whole_orbits /* f_show_whole_orbit*/);
408 }
409 }
410
411 if (Control->f_list) {
412 if (f_v) {
413 cout << "poset_classification::post_processing f_list" << endl;
414 }
415#if 1
416 //int f_show_orbit_decomposition = TRUE;
417 //int f_show_stab = TRUE;
418 //int f_save_stab = TRUE;
419 //int f_show_whole_orbit = FALSE;
420
421 if (f_v) {
422 cout << "poset_classification::post_processing before "
423 "list_all_orbits_at_level" << endl;
424 }
425 list_all_orbits_at_level(actual_size,
426 FALSE,
427 NULL,
428 this,
430 Control->f_show_stab,
431 Control->f_save_stab,
432 Control->f_show_whole_orbits);
433
434 if (f_v) {
435 cout << "poset_classification::post_processing after "
436 "list_all_orbits_at_level" << endl;
437 }
438
439#if 0
440 int d;
441 for (d = 0; d < 3; d++) {
442 gen->print_schreier_vectors_at_depth(d, verbose_level);
443 }
444#endif
445#endif
446 }
447
448 if (Control->f_level_summary_csv) {
449 if (f_v) {
450 cout << "poset_classification::post_processing preparing level spreadsheet" << endl;
451 }
452 {
454 make_spreadsheet_of_level_info(Sp, actual_size, verbose_level);
455 string fname_csv;
456 char str[1000];
457
458 fname_csv.assign(problem_label_with_path);
459 sprintf(str, "_levels_%d.csv", actual_size);
460 fname_csv.append(str);
461 Sp->save(fname_csv, verbose_level);
462 FREE_OBJECT(Sp);
463 }
464 if (f_v) {
465 cout << "poset_classification::post_processing preparing level spreadsheet done" << endl;
466 }
467 }
468
469
470 if (Control->f_orbit_reps_csv) {
471 if (f_v) {
472 cout << "poset_classification::post_processing preparing orbit spreadsheet" << endl;
473 }
474 {
476 make_spreadsheet_of_orbit_reps(Sp, actual_size);
477 string fname_csv;
478 char str[1000];
479
480 fname_csv.assign(problem_label_with_path);
481 sprintf(str, "_orbits_at_level_%d.csv", actual_size);
482 fname_csv.append(str);
483 Sp->save(fname_csv, verbose_level);
484 FREE_OBJECT(Sp);
485 }
486 if (f_v) {
487 cout << "poset_classification::post_processing preparing orbit spreadsheet done" << endl;
488 }
489 }
490
491
492 if (Control->f_draw_poset) {
493 if (f_v) {
494 cout << "poset_classification::post_processing before draw_poset" << endl;
495 }
496 if (!Control->f_draw_options) {
497 cout << "poset_classification::post_processing Control->f_draw_poset && !Control->f_draw_options" << endl;
498 exit(1);
499 }
501 0 /* data1 */,
502 Control->draw_options,
503 verbose_level);
504 if (f_v) {
505 cout << "poset_classification::post_processing after draw_poset" << endl;
506 }
507 }
508
509 if (Control->f_draw_full_poset) {
510 if (f_v) {
511 cout << "poset_classification::post_processing before draw_full_poset" << endl;
512 }
514 0 /* data1 */,
515 Control->draw_options,
516 1 /* x_stretch */, verbose_level);
517 if (f_v) {
518 cout << "poset_classification::post_processing after draw_full_poset" << endl;
519 }
520 }
522 string fname_prefix;
523
524
525 fname_prefix.assign(problem_label_with_path);
526 fname_prefix.append("_flag_orbits");
527
528 if (f_v) {
529 cout << "poset_classification::post_processing before make_flag_orbits_on_relations" << endl;
530 }
532 depth, fname_prefix.c_str(), verbose_level);
533 if (f_v) {
534 cout << "poset_classification::post_processing after make_flag_orbits_on_relations" << endl;
535 }
536 }
537 if (Control->recognize.size()) {
538 int h;
539
540 for (h = 0; h < Control->recognize.size(); h++) {
541
542 recognize(Control->recognize[h],
543 h, Control->recognize.size(),
544 verbose_level);
545 }
546 }
547 if (Control->f_print_data_structure) {
548 if (f_v) {
549 cout << "poset_classification::post_processing f_print_data_structure" << endl;
550 }
551 print_data_structure_tex(actual_size, verbose_level);
552 }
553
554
555 if (Control->f_Kramer_Mesner_matrix) {
556
557 if (f_v) {
558 cout << "poset_classification::post_processing computing "
559 "Kramer Mesner matrices" << endl;
560 }
561
562 // compute Kramer Mesner matrices
563 long int **pM;
564 int *Nb_rows, *Nb_cols;
565 int h;
566
567 pM = NEW_plint(Control->Kramer_Mesner_k);
568 Nb_rows = NEW_int(Control->Kramer_Mesner_k);
569 Nb_cols = NEW_int(Control->Kramer_Mesner_k);
570 for (h = 0; h < Control->Kramer_Mesner_k; h++) {
571 Kramer_Mesner_matrix_neighboring(h, pM[h], Nb_rows[h], Nb_cols[h], verbose_level - 2);
572 if (f_v) {
573 cout << "poset_classification::post_processing matrix "
574 "level " << h << " computed" << endl;
575#if 0
576 int j;
577 for (i = 0; i < Nb_rows[h]; i++) {
578 for (j = 0; j < Nb_cols[h]; j++) {
579 cout << pM[h][i * Nb_cols[h] + j];
580 if (j < Nb_cols[h]) {
581 cout << ",";
582 }
583 }
584 cout << endl;
585 }
586#endif
587 }
588 }
589
590 long int *Mtk;
591 int nb_r, nb_c;
592
593
594 if (f_v) {
595 cout << "poset_classification::post_processing before Mtk_from_MM" << endl;
596 }
597 Mtk_from_MM(pM, Nb_rows, Nb_cols,
598 Control->Kramer_Mesner_t, Control->Kramer_Mesner_k,
599 Mtk,
600 nb_r, nb_c,
601 verbose_level);
602 if (f_v) {
603 cout << "poset_classification::post_processing after Mtk_from_MM" << endl;
604 cout << "poset_classification::post_processing M_{" << Control->Kramer_Mesner_t << ","
605 << Control->Kramer_Mesner_k << "} has size " << nb_r << " x "
606 << nb_c << "." << endl;
607
608#if 0
609 int j;
610 for (i = 0; i < nb_r; i++) {
611 for (j = 0; j < nb_c; j++) {
612 cout << Mtk[i * nb_c + j];
613 if (j < nb_c - 1) {
614 cout << ",";
615 }
616 }
617 cout << endl;
618 }
619#endif
620
621 }
622
623
625 int i;
626
627 string fname;
628 char str[1000];
629
630 fname.assign(problem_label);
631 sprintf(str, "_KM_%d_%d.csv",
632 Control->Kramer_Mesner_t, Control->Kramer_Mesner_k);
633 fname.append(str);
634 Fio.lint_matrix_write_csv(fname, Mtk, nb_r, nb_c);
635 //Mtk.print(cout);
636 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
637
638 if (f_v) {
639 cout << "poset_classification::post_processing computing "
640 "Kramer Mesner matrices done" << endl;
641 }
642 for (i = 0; i < Control->Kramer_Mesner_k; i++) {
643 FREE_lint(pM[i]);
644 }
645 FREE_plint(pM);
646 FREE_lint(Mtk);
647
648
649 }
650
651 if (Control->f_report) {
652
653 if (f_v) {
654 cout << "poset_classification::post_processing f_report" << endl;
655 }
656 {
657 string fname_report;
658 fname_report.assign(problem_label);
659 fname_report.append("_poset.tex");
662
663 {
664 ofstream ost(fname_report);
665 L.head_easy(ost);
666
667 if (f_v) {
668 cout << "poset_classification::post_processing "
669 "before get_A()->report" << endl;
670 }
671
672 get_A2()->report(ost,
673 FALSE /* f_sims */, NULL,
674 FALSE /* f_strong_gens */, NULL,
675 Control->draw_options,
676 verbose_level - 1);
677
678 if (f_v) {
679 cout << "poset_classification::post_processing "
680 "after LG->A_linear->report" << endl;
681 }
682
683 if (f_v) {
684 cout << "poset_classification::post_processing "
685 "before report" << endl;
686 }
687 report(ost, Control->report_options, verbose_level);
688 if (f_v) {
689 cout << "poset_classification::post_processing "
690 "after report" << endl;
691 }
692
693 L.foot(ost);
694 }
695 cout << "Written file " << fname_report << " of size "
696 << Fio.file_size(fname_report) << endl;
697 }
698
699 }
702 }
703
704 if (f_v) {
705 cout << "poset_classification::post_processing done" << endl;
706 }
707}
708
709void poset_classification::recognize(std::string &set_to_recognize,
710 int h, int nb_to_recognize, int verbose_level)
711{
712 int f_v = (verbose_level >= 1);
713
714 if (f_v) {
715 cout << "poset_classification::recognize" << endl;
716 }
717 long int *recognize_set;
718 int recognize_set_sz;
719 int orb;
720 long int *canonical_set;
721 int *Elt_transporter;
722 int *Elt_transporter_inv;
723
724 cout << "recognize " << h << " / " << nb_to_recognize << endl;
725 Lint_vec_scan(set_to_recognize, recognize_set, recognize_set_sz);
726 cout << "input set = " << h << " / " << nb_to_recognize << " : ";
727 Lint_vec_print(cout, recognize_set, recognize_set_sz);
728 cout << endl;
729
730 canonical_set = NEW_lint(recognize_set_sz);
731 Elt_transporter = NEW_int(get_A()->elt_size_in_int);
732 Elt_transporter_inv = NEW_int(get_A()->elt_size_in_int);
733
734
736 int orbit_at_level;
737
738
740 recognize_set, recognize_set_sz, Elt_transporter,
741 orbit_at_level,
742 verbose_level);
743
744
745 orb = trace_set(recognize_set,
746 recognize_set_sz, recognize_set_sz /* level */,
747 canonical_set, Elt_transporter,
748 0 /*verbose_level */);
749
750 cout << "recognize " << h << " / " << nb_to_recognize << endl;
751 cout << "canonical set = ";
752 Lint_vec_print(cout, canonical_set, recognize_set_sz);
753 cout << endl;
754 cout << "is orbit " << orb << endl;
755 cout << "recognize " << h << " / " << nb_to_recognize << endl;
756 cout << "transporter:" << endl;
757 get_A()->element_print_quick(Elt_transporter, cout);
758
759 get_A()->element_invert(Elt_transporter, Elt_transporter_inv, 0);
760 cout << "recognize " << h << " / " << nb_to_recognize << endl;
761 cout << "transporter inverse:" << endl;
762 get_A()->element_print_quick(Elt_transporter_inv, cout);
763
764 SaS->print_generators_tex(cout);
765
766 FREE_lint(canonical_set);
767 FREE_int(Elt_transporter);
768 FREE_int(Elt_transporter_inv);
769 FREE_lint(recognize_set);
770
771 if (f_v) {
772 cout << "poset_classification::recognize done" << endl;
773 }
774}
775
776void poset_classification::extend_level(int size,
777 int f_create_schreier_vector,
778 int f_use_invariant_subset_if_available,
779 int f_debug,
780 int f_write_candidate_file,
781 int verbose_level)
782// calls downstep, upstep
783{
784 int f_v = (verbose_level >= 1);
785
786 if (f_v) {
787 cout << "####################################################"
788 "##############################################" << endl;
790 cout << endl;
791 cout << "poset_classification::extend_level "
792 "constructing orbits at depth "
793 << size + 1 << endl;
794 cout << "poset_classification::extend_level from "
795 << nb_orbits_at_level(size)
796 << " nodes at depth " << size << endl;
797 //cout << "f_create_schreier_vector="
798 //<< f_create_schreier_vector << endl;
799 //cout << "f_use_invariant_subset_if_available="
800 //<< f_use_invariant_subset_if_available << endl;
801 //cout << "f_debug=" << f_debug << endl;
802 //cout << "f_write_candidate_file="
803 //<< f_write_candidate_file << endl;
804 cout << "verbose_level=" << verbose_level << endl;
805 }
806
807 if (f_v) {
808 cout << "poset_classification::extend_level size = " << size
809 << " calling compute_flag_orbits" << endl;
810 }
812 f_create_schreier_vector,
813 f_use_invariant_subset_if_available,
814 verbose_level - 1);
815 if (f_v) {
816 cout << "poset_classification::extend_level size = " << size <<
817 "after compute_flag_orbits" << endl;
818 }
819
820 if (f_write_candidate_file) {
821 if (f_v) {
822 cout << "poset_classification::extend_level "
823 "size = " << size
824 << " before write_candidates_binary_using_sv" << endl;
825 }
826 Poo->write_candidates_binary_using_sv(problem_label_with_path.c_str(),
827 size, t0, verbose_level - 1);
828 if (f_v) {
829 cout << "poset_classification::extend_level "
830 "size = " << size
831 << " after write_candidates_binary_using_sv" << endl;
832 }
833 }
834
835 if (f_v) {
836 cout << "poset_classification::extend_level "
837 "calling upstep" << endl;
838 }
839 upstep(size,
840 f_debug,
841 verbose_level - 1);
842 if (f_v) {
843 cout << "poset_classification::extend_level "
844 "after upstep" << endl;
845 }
846
847
848}
849
850void poset_classification::compute_flag_orbits(int size,
851 int f_create_schreier_vector,
852 int f_use_invariant_subset_if_available,
853 int verbose_level)
854// calls root[prev].downstep_subspace_action
855// or root[prev].downstep
856{
857 int f_v = (verbose_level >= 1);
858 int f_vv = (verbose_level >= 2);
859 int f_v4 = (verbose_level >= 4);
860 int f, cur, l, prev, u;
861 int f_print = f_v;
862 double progress;
863
864 f = Poo->first_node_at_level(size);
865 cur = Poo->first_node_at_level(size + 1);
866 l = cur - f;
867
868 if (f_v) {
869 cout << "################################################"
870 "##################################################" << endl;
872 cout << endl;
873 cout << "poset_classification::compute_flag_orbits at level " << size
874 << " creating orbits at level " << size + 1
875 << " verbose_level=" << verbose_level << endl;
876 }
877 progress_last_time = 0;
878 progress = 0;
879
880 for (u = 0; u < l; u++) {
881
882
883
884 prev = f + u;
885
886 if (f_print) {
887 print_level_info(size, prev);
888 cout << " poset_classification::compute_flag_orbits "
889 "level " << size << " node " << u << " / " << l
890 << " starting" << endl;
891 }
892
893 if (Poset->f_subspace_lattice) {
894 if (f_v) {
895 cout << "poset_classification::compute_flag_orbits "
896 "level " << size << " before compute_flag_orbits_subspace_action" << endl;
897 }
898 Poo->get_node(prev)->compute_flag_orbits_subspace_action(this, size,
899 f_create_schreier_vector,
900 f_use_invariant_subset_if_available,
901 Control->f_lex,
902 verbose_level - 1);
903 if (f_v) {
904 cout << "poset_classification::compute_flag_orbits "
905 "level " << size << " after compute_flag_orbits_subspace_action" << endl;
906 }
907 }
908 else {
909 if (f_v4) {
910 cout << "poset_classification::compute_flag_orbits "
911 "level " << size << " before compute_flag_orbits" << endl;
912 }
913 Poo->get_node(prev)->compute_flag_orbits(this, size,
914 f_create_schreier_vector,
915 f_use_invariant_subset_if_available,
916 Control->f_lex,
917 verbose_level - 1);
918 if (f_v4) {
919 cout << "poset_classification::compute_flag_orbits "
920 "level " << size << " after compute_flag_orbits" << endl;
921 }
922 }
923 if (f_print) {
924 //cout << endl;
925 print_level_info(size, prev);
926 cout << " compute_flag_orbits level " << size << " node " << u << " / " << l
927 << " finished : ";
928 if (Poo->get_node(prev)->has_Schreier_vector()) {
929 //int nb = root[prev].sv[0];
930 int nb = Poo->get_node(prev)->get_nb_of_live_points();
931 cout << " found " << nb << " live points in "
932 << Poo->node_get_nb_of_extensions(prev) << " orbits : ";
933
934 if (FALSE) {
935 int *live_points = Poo->get_node(prev)->live_points();
936 cout << "The live points are : ";
937 Int_vec_print(cout, live_points, nb);
938 }
939 cout << endl;
940 }
941 if (f_vv) {
942 print_level_info(size, prev);
943 cout << " compute_flag_orbits level " << size << " node " << u << " / " << l
944 << " the extensions are : ";
945 if (FALSE) {
946 Poo->get_node(prev)->print_extensions(this);
947 }
948 }
949 print_progress(progress);
950 //cout << endl;
951 }
952
953 progress = (double) u / (double) l;
954
955 if (f_v && ABS(progress - progress_last_time) > progress_epsilon) {
956 f_print = TRUE;
957 progress_last_time = progress;
958 }
959 else {
960 f_print = FALSE;
961 }
962
963
964 }
965
966 if (f_v) {
967 cout << "poset_classification::compute_flag_orbits at "
968 "level " << size << " done" << endl;
969 }
970
971}
972
973void poset_classification::upstep(int size,
974 int f_debug,
975 int verbose_level)
976// calls extend_node
977{
978 int f_v = (verbose_level >= 1);
979 int f_vv = (verbose_level >= 2);
980 int f, cur, l, prev, u;
981 int f_indicate_not_canonicals = FALSE;
982 int f_print = f_v;
983
984 if (f_v) {
985 cout << "poset_classification::upstep at level " << size << endl;
986 cout << "verbose_level = " << verbose_level << endl;
987 }
988
989
990
991 f = Poo->first_node_at_level(size);
992 cur = Poo->first_node_at_level(size + 1);
993 l = cur - f;
994
995 progress_last_time = 0;
996
997 if (f_v) {
998 cout << "#################################################"
999 "#################################################" << endl;
1001 cout << endl;
1002 cout << "extension step at level " << size << endl;
1003 cout << "verbose_level=" << verbose_level << endl;
1004 cout << "f_indicate_not_canonicals="
1005 << f_indicate_not_canonicals << endl;
1006 }
1008 if (f_v) {
1009 cout << "with " << Poo->get_nb_extension_nodes_at_level_total(size)
1010 << " extension nodes" << endl;
1011 }
1012 for (u = 0; u < l; u++) {
1013
1014 if (f_vv) {
1015 cout << "poset_classification::upstep level " << size <<
1016 " case " << u << " / " << l << endl;
1017 }
1018 prev = f + u;
1019
1020 if (f_print) {
1021 print_level_info(size, prev);
1022 cout << " Upstep : " << endl;
1023 }
1024 else {
1025 }
1026
1027#if 0
1028 if (f_v4) {
1029 cout << "poset_classification::upstep "
1030 "before extend_node" << endl;
1031 print_extensions_at_level(cout, size);
1032 }
1033#endif
1034
1035 if (f_vv) {
1036 cout << "poset_classification::upstep level " << size <<
1037 " case " << u << " / " << l << " before extend_node" << endl;
1038 }
1039 extend_node(size, prev, cur,
1040 f_debug,
1041 f_indicate_not_canonicals,
1042 verbose_level - 2);
1043
1044#if 1
1045 if (f_vv) {
1046 cout << "poset_classification::upstep level " << size <<
1047 " after extend_node, size="
1048 << size << endl;
1049 }
1050#endif
1051
1052 double progress;
1053
1054
1055 progress = level_progress(size);
1056
1057 if (f_print) {
1058 print_level_info(size, prev);
1059 cout << " Upstep : ";
1060 print_progress(progress);
1061 }
1062
1063 if (f_v &&
1064 ABS(progress - progress_last_time) > progress_epsilon) {
1065 f_print = TRUE;
1066 progress_last_time = progress;
1067 }
1068 else {
1069 f_print = FALSE;
1070 }
1071
1072 }
1073
1074 Poo->set_first_node_at_level(size + 2, cur);
1076
1077
1078
1079 if (f_v) {
1080 cout << "poset_classification::upstep at level " << size << " done" << endl;
1081 }
1082
1083
1084}
1085
1086void poset_classification::extend_node(
1087 int size, int prev, int &cur,
1088 int f_debug,
1089 int f_indicate_not_canonicals,
1090 int verbose_level)
1091// called by poset_classification::upstep
1092// Uses an upstep_work structure to handle the work.
1093// Calls upstep_work::handle_extension
1094{
1095 int nb_fuse_cur, nb_ext_cur, prev_ex;
1096 int f_v = (verbose_level >= 1);
1097 int f_vv = (verbose_level >= 2);
1098 int f_vvv = (verbose_level >= 3);
1099
1100 if (f_v) {
1101 cout << "poset_classification::extend_node prev=" << prev
1102 << " cur=" << cur << endl;
1103 }
1104
1105 while (cur + Poo->node_get_nb_of_extensions(prev) + 10 >=
1107 print_level_info(size, prev);
1108 if (f_v) {
1109 cout << "poset_classification::extend_node "
1110 "running out of nodes" << endl;
1111 cout << "cur = " << cur << endl;
1112 cout << "allocated nodes = "
1113 << Poo->get_nb_poset_orbit_nodes_allocated() << endl;
1114 cout << "reallocating" << endl;
1115 }
1116 Poo->reallocate();
1117 if (f_v) {
1118 cout << "allocated nodes = "
1119 << Poo->get_nb_poset_orbit_nodes_allocated() << endl;
1120 }
1121 }
1122
1123 nb_fuse_cur = 0;
1124 nb_ext_cur = 0;
1125
1126 if (f_vv) {
1128
1129 print_level_info(size, prev);
1130 //cout << "Level " << size << " Node " << cur << " : ";
1131 cout << " extending set ";
1132
1133 print_set(prev);
1134
1135 if (Poo->get_node(prev)->has_Schreier_vector()) {
1136 //int nb = root[prev].sv[0];
1137 int nb = Poo->get_node(prev)->get_nb_of_live_points();
1138 cout << " with " << nb << " live points" << endl;
1139 }
1140
1141 cout << " with " << Poo->node_get_nb_of_extensions(prev)
1142 << " extensions" << endl;
1143 cout << " verbose_level=" << verbose_level << endl;
1144 if (FALSE) {
1145 cout << "poset_classification::extend_node prev=" << prev
1146 << " cur=" << cur << " extensions:" << endl;
1147 Poo->get_node(prev)->print_extensions(this);
1148 }
1149 }
1150
1151
1152
1153 int f_show_progress = FALSE;
1154 if (Poo->node_get_nb_of_extensions(prev) > 10000) {
1155 f_show_progress = TRUE;
1156 }
1157 int nb_flags_10;
1158
1159 nb_flags_10 = Poo->node_get_nb_of_extensions(prev) / 10 + 1;
1160
1161 for (prev_ex = 0; prev_ex < Poo->node_get_nb_of_extensions(prev); prev_ex++) {
1162
1163 if (f_show_progress && (prev_ex % nb_flags_10) == 0) {
1164 print_level_info(size, prev);
1165 cout << "poset_classification::extend_node "
1166 "working on extension "
1167 << prev_ex << " / " << Poo->node_get_nb_of_extensions(prev)
1168 << " : progress " << prev_ex / nb_flags_10 << " * 10 %" << endl;
1169
1170
1171 }
1172
1173 if (FALSE) {
1174 print_level_info(size, prev);
1175 cout << "poset_classification::extend_node "
1176 "working on extension "
1177 << prev_ex << " / " << Poo->node_get_nb_of_extensions(prev)
1178 << ":" << endl;
1179 }
1180
1181
1182 {
1183 upstep_work Work;
1184
1185
1186#if 0
1187 if (FALSE /*prev == 32 && prev_ex == 3*/) {
1188 cout << "poset_classification::extend_node "
1189 "we are at node (32,3)" << endl;
1190 verbose_level_down = verbose_level + 20;
1191 }
1192 else {
1193 verbose_level_down = verbose_level - 2;
1194 }
1195#endif
1196 //verbose_level_down = verbose_level - 4;
1197
1198 if (f_vv) {
1199 print_level_info(size, prev);
1200 cout << "poset_classification::extend_node "
1201 "working on extension "
1202 << prev_ex << " / " << Poo->node_get_nb_of_extensions(prev)
1203 << ": before Work.init" << endl;
1204 }
1205
1206 Work.init(this, size, prev, prev_ex, cur,
1207 f_debug,
1208 Control->f_lex,
1209 f_indicate_not_canonicals,
1210 verbose_level - 2);
1211
1212 if (f_vv) {
1213 print_level_info(size, prev);
1214 cout << "poset_classification::extend_node "
1215 "working on extension "
1216 << prev_ex << " / " << Poo->node_get_nb_of_extensions(prev)
1217 << ": after Work.init" << endl;
1218 }
1219
1220
1221
1222 if (f_vvv) {
1223 if ((prev_ex % Work.mod_for_printing) == 0 && prev_ex) {
1225 prev, prev_ex, nb_ext_cur, nb_fuse_cur);
1226 }
1227 }
1228 if (FALSE) {
1229 print_level_info(size, prev);
1230 cout << "poset_classification::extend_node "
1231 "working on extension "
1232 << prev_ex << " / " << Poo->node_get_nb_of_extensions(prev)
1233 << ": before Work.handle_extension nb_ext_cur="
1234 << nb_ext_cur << endl;
1235 }
1236 Work.handle_extension(nb_fuse_cur, nb_ext_cur,
1237 verbose_level - 2);
1238 // in upstep_work.cpp
1239
1240 if (FALSE) {
1241 print_level_info(size, prev);
1242 cout << "poset_classification::extend_node after "
1243 "Work.handle_extension" << endl;
1244 }
1245
1246
1247 cur = Work.cur;
1248
1249 } // end of upstep_work Work
1250
1251
1252 if (f_vvv) {
1253 print_level_info(size, prev);
1254 cout << "poset_classification::extend_node "
1255 "working on extension "
1256 << prev_ex << " / " << Poo->node_get_nb_of_extensions(prev)
1257 << ":" << endl;
1258 cout << "poset_classification::extend_node "
1259 "after freeing Work" << endl;
1260 }
1261
1262 }
1263
1264
1265 if (f_v) {
1266 print_progress(size, cur, prev, nb_ext_cur, nb_fuse_cur);
1267 //cout << "cur=" << cur << endl;
1268 }
1269 if (f_v) {
1270 cout << "poset_classification::extend_node prev=" << prev
1271 << " cur=" << cur << " done" << endl;
1272 }
1273}
1274
1275}}}
1276
1277
1278
void save(std::string &fname, int verbose_level)
void lint_matrix_write_csv(std::string &fname, long int *M, int m, int n)
Definition: file_io.cpp:1323
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
void element_print_quick(void *elt, std::ostream &ost)
Definition: action_cb.cpp:353
void report(std::ostream &ost, int f_sims, groups::sims *S, int f_strong_gens, groups::strong_generators *SG, graphics::layered_graph_draw_options *LG_Draw_options, int verbose_level)
Definition: action_io.cpp:22
void element_invert(void *a, void *av, int verbose_level)
Definition: action_cb.cpp:322
to control the behavior of the poset classification algorithm
void print_progress_by_extension(int size, int cur, int prev, int cur_ex, int nb_ext_cur, int nb_fuse_cur)
void initialize_and_allocate_root_node(poset_classification_control *PC_control, poset_with_group_action *Poset, int depth, int verbose_level)
int compute_orbits(int from_level, int to_level, int schreier_depth, int f_use_invariant_subset_if_available, int verbose_level)
int trace_set(long int *set, int size, int level, long int *canonical_set, int *Elt_transporter, int verbose_level)
void print_progress(int size, int cur, int prev, int nb_ext_cur, int nb_fuse_cur)
void extend_level(int size, int f_create_schreier_vector, int f_use_invariant_subset_if_available, int f_debug, int f_write_candidate_file, int verbose_level)
void make_spreadsheet_of_level_info(data_structures::spreadsheet *&Sp, int max_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 housekeeping(int i, int f_write_files, int t0, int verbose_level)
void extend_node(int size, int prev, int &cur, int f_debug, int f_indicate_not_canonicals, int verbose_level)
void list_all_orbits_at_level(int depth, int f_has_print_function, void(*print_function)(std::ostream &ost, int len, long int *S, void *data), void *print_function_data, int f_show_orbit_decomposition, int f_show_stab, int f_save_stab, int f_show_whole_orbit)
data_structures_groups::set_and_stabilizer * identify_and_get_stabilizer(long int *set, int sz, int *transporter, int &orbit_at_level, int verbose_level)
void write_treefile(std::string &fname_base, int lvl, graphics::layered_graph_draw_options *draw_options, int verbose_level)
void make_flag_orbits_on_relations(int depth, const char *fname_prefix, int verbose_level)
void make_spreadsheet_of_orbit_reps(data_structures::spreadsheet *&Sp, int max_depth)
void Kramer_Mesner_matrix_neighboring(int level, long int *&M, int &nb_rows, int &nb_cols, int verbose_level)
void compute_flag_orbits(int size, int f_create_schreier_vector, int f_use_invariant_subset_if_available, int verbose_level)
void recover(std::string &recover_fname, int &depth_completed, int verbose_level)
void draw_poset(std::string &fname_base, int depth, int data, graphics::layered_graph_draw_options *LG_Draw_options, int verbose_level)
void report(std::ostream &ost, poset_classification_report_options *Opt, int verbose_level)
void recognize(std::string &set_to_recognize, int h, int nb_to_recognize, int verbose_level)
void Mtk_from_MM(long int **pM, int *Nb_rows, int *Nb_cols, int t, int k, long int *&Mtk, int &nb_r, int &nb_c, int verbose_level)
void draw_poset_full(std::string &fname_base, int depth, int data, graphics::layered_graph_draw_options *LG_Draw_options, double x_stretch, int verbose_level)
void write_candidates_binary_using_sv(const char *fname_base, int lvl, int t0, int verbose_level)
void compute_flag_orbits_subspace_action(poset_classification *gen, int lvl, int f_create_schreier_vector, int f_use_invariant_subset_if_available, int f_implicit_fusion, int verbose_level)
void compute_flag_orbits(poset_classification *gen, int lvl, int f_create_schreier_vector, int f_use_invariant_subset_if_available, int f_implicit_fusion, int verbose_level)
auxiliary class for the poset classification algorithm to deal with flag orbits
void init(poset_classification *gen, int size, int prev, int prev_ex, int cur, int f_debug, int f_implicit_fusion, int f_indicate_not_canonicals, int verbose_level)
Definition: upstep_work.cpp:94
void handle_extension(int &nb_fuse_cur, int &nb_ext_cur, int verbose_level)
#define NEW_plint(n)
Definition: foundations.h:629
#define FREE_int(p)
Definition: foundations.h:640
#define Lint_vec_scan(A, B, C)
Definition: foundations.h:717
#define FREE_plint(p)
Definition: foundations.h:643
#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 ABS(x)
Definition: foundations.h:220
#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
int main(int argc, const char **argv)
This is the Orbiter front-end. It passes the command line on to the user interface.
Definition: orbiter.cpp:20