Orbiter 2022
Combinatorial Objects
poset_classification_io.cpp
Go to the documentation of this file.
1// poset_classification_io.cpp
2//
3// Anton Betten
4//
5// moved here from DISCRETA/snakesandladders.cpp
6// December 27, 2008
7// renamed from io.cpp to poset_classification_io.cpp Aug 24, 2011
8
9
11#include "discreta/discreta.h"
14
15using namespace std;
16
17namespace orbiter {
18namespace layer4_classification {
19namespace poset_classification {
20
21
22void poset_classification::print_set_verbose(int node)
23{
24 Poo->get_node(node)->print_set_verbose(this);
25}
26
27void poset_classification::print_set_verbose(int level, int orbit)
28{
29 int node;
30
31 node = Poo->first_node_at_level(level) + orbit;
32 Poo->get_node(node)->print_set_verbose(this);
33}
34
35void poset_classification::print_set(int node)
36{
37 Poo->get_node(node)->print_set(this);
38}
39
40void poset_classification::print_set(int level, int orbit)
41{
42 int node;
43
44 node = Poo->first_node_at_level(level) + orbit;
45 Poo->get_node(node)->print_set(this);
46}
47
48
49void poset_classification::print_progress_by_extension(
50 int size,
51 int cur, int prev, int cur_ex,
52 int nb_ext_cur, int nb_fuse_cur)
53{
54 double progress;
55
56
57 progress = level_progress(size);
58
59 print_level_info(size, prev);
60 cout << " **** Upstep extension " << cur_ex << " / "
61 << Poo->node_get_nb_of_extensions(prev) << " with "
62 << nb_ext_cur << " n e w orbits and "
63 << nb_fuse_cur << " fusion nodes. We now have "
64 << cur - Poo->first_node_at_level(size)
65 << " nodes at level " << size;
66 cout << ", ";
67 print_progress(progress);
69}
70
71void poset_classification::print_progress(
72 int size,
73 int cur, int prev,
74 int nb_ext_cur, int nb_fuse_cur)
75{
76 double progress;
77
78
79 progress = level_progress(size);
80
81 print_level_info(size, prev);
82 cout << " **** Upstep finished with "
83 << nb_ext_cur << " n e w orbits and "
84 << nb_fuse_cur << " fusion nodes. We now have "
85 << cur - Poo->first_node_at_level(size)
86 << " nodes at level " << size;
87 cout << ", ";
88 print_progress(progress);
90}
91
92void poset_classification::print_progress(double progress)
93{
94 double progress0;
95 long int progress1, progress2;
96
97 progress0 = progress * 100.;
98 progress2 = (long int) (progress0 * 100.);
99 progress1 = progress2 / 100;
100 progress2 = progress2 % 100;
101 cout << "progress: " << progress1 << "."
102 << setw(2) << progress2 << " % " << endl;
103}
104
105void poset_classification::print_progress_by_level(int lvl)
106{
107
108 Poo->print_progress_by_level(lvl);
109}
110
111void poset_classification::print_orbit_numbers(int depth)
112{
113 int nb_nodes, j;
114
115 nb_nodes = nb_orbits_at_level(depth);
116 cout << "###########################################################"
117 "#######################################" << endl;
119 cout << "Found " << nb_nodes << " orbits at depth " << depth << endl;
120 for (j = 0; j <= depth; j++) {
121 cout << j << " : " << nb_orbits_at_level(j) << " orbits" << endl;
122 }
123 cout << "total: " << Poo->first_node_at_level(depth + 1) << endl;
124 //gen->print_statistic_on_callbacks();
126}
127
128void poset_classification::print()
129{
130 int nb_nodes, j;
131
132 cout << "Poset classification:" << endl;
134 cout << "Action:" << endl;
135 Poset->A->print_info();
136 cout << "Action2:" << endl;
137 Poset->A2->print_info();
138 cout << "Group order:" << Poset->go << endl;
139 cout << "Degree:" << Poset->A2->degree << endl;
140 cout << "depth:" << depth << endl;
141 nb_nodes = nb_orbits_at_level(depth);
142 cout << "Found " << nb_nodes << " orbits at depth " << depth << endl;
143 for (j = 0; j <= depth; j++) {
144 cout << j << " : " << nb_orbits_at_level(j) << " orbits" << endl;
145 }
146 cout << "total: " << Poo->first_node_at_level(depth + 1) << endl;
147}
148
149void poset_classification::print_statistic_on_callbacks_naked()
150{
151 cout << Poset->A->ptr->nb_times_image_of_called - nb_times_image_of_called0 << "/";
152 cout << Poset->A->ptr->nb_times_mult_called - nb_times_mult_called0 << "/";
153 cout << Poset->A->ptr->nb_times_invert_called - nb_times_invert_called0 << "/";
154 cout << Poset->A->ptr->nb_times_retrieve_called - nb_times_retrieve_called0 << "/";
155 cout << Poset->A->ptr->nb_times_store_called - nb_times_store_called0;
156}
157
158void poset_classification::print_statistic_on_callbacks()
159{
160 cout << "# of calls to image_of/mult/invert/retrieve/store: ";
162 cout << endl;
163}
164
165
166void poset_classification::prepare_fname_data_file(std::string &fname,
167 std::string &fname_base, int depth_completed)
168{
169 char str[1000];
170
171 fname.assign(fname_base);
172 sprintf(str, "_%d.data", depth_completed);
173 fname.append(str);
174}
175
176void poset_classification::print_representatives_at_level(int lvl)
177{
178 int i, l;
179
180 l = nb_orbits_at_level(lvl);
181 cout << "The " << l << " representatives at level "
182 << lvl << " are:" << endl;
183 for (i = 0; i < l; i++) {
184 cout << i << " / " << l << " : ";
185 Poo->get_node_ij(lvl, i)->print_set(this);
186 cout << endl;
187 }
188}
189
190void poset_classification::print_lex_rank(long int *set, int sz)
191{
192#if 0
193 int r1, r2;
194 int n;
195 combinatorics_domain Combi;
196
197 // ToDo
198 n = Poset->A2->degree;
199 r1 = Combi.rank_subset(set, sz, n);
200 r2 = Combi.rank_k_subset(set, n, sz);
201
202 cout << "lex rank = " << r1 << " lex rank as "
203 << sz << "-subset = " << r2;
204#endif
205}
206
207
208void poset_classification::print_problem_label()
209{
210 if (problem_label[0]) {
211 cout << problem_label << " ";
212 }
213}
214
215void poset_classification::print_level_info(int prev_level, int prev)
216{
217 int t1, dt;
219
220 t1 = Os.os_ticks();
221 //cout << "poset_classification::print_level_info t0=" << t0 << endl;
222 //cout << "poset_classification::print_level_info t1=" << t1 << endl;
223 dt = t1 - t0;
224 //cout << "poset_classification::print_level_info dt=" << dt << endl;
225
226 cout << "Time ";
227 Os.time_check_delta(cout, dt);
229 cout << " : Level " << prev_level << " Node " << prev << " = "
230 << prev - Poo->first_node_at_level(prev_level)
231 << " / "
232 << nb_orbits_at_level(prev_level)
233 << " : ";
234}
235
236void poset_classification::print_level_extension_info(
237 int prev_level,
238 int prev, int cur_extension)
239{
240 cout << "Level " << prev_level << " Node " << prev << " = "
241 << prev - Poo->first_node_at_level(prev_level)
242 << " / "
243 << nb_orbits_at_level(prev_level)
244 << " Extension " << cur_extension
245 << " / "
246 << Poo->node_get_nb_of_extensions(prev)
247 << " : ";
248}
249
250void poset_classification::print_level_extension_coset_info(
251 int prev_level,
252 int prev, int cur_extension, int coset, int nb_cosets)
253{
254 cout << "Level " << prev_level << " Node " << prev << " = "
255 << prev - Poo->first_node_at_level(prev_level)
256 << " / "
257 << nb_orbits_at_level(prev_level)
258 << " Extension " << cur_extension
259 << " / "
260 << Poo->node_get_nb_of_extensions(prev)
261 << " : "
262 << "Coset " << coset << " / " << nb_cosets << " : ";
263}
264
265void poset_classification::print_node(int node)
266{
267 cout << "poset_classification::print_node "
268 "node " << node << ":" << endl;
269 Poo->get_node(node)->print_node(this);
270}
271
272void poset_classification::print_extensions_at_level(
273 ostream &ost, int lvl)
274{
275 int i, node;
276 int fst, len;
278
279 ost << "extensions at level " << lvl << ":" << endl;
280 fst = Poo->first_node_at_level(lvl);
281 len = nb_orbits_at_level(lvl);
282 ost << "there are " << len << " nodes at level " << lvl << ":" << endl;
283 for (i = 0; i < len; i++) {
284 node = fst + i;
285 O = Poo->get_node(node);
286 ost << "Node " << i << " / " << len << " = " << node << ":" << endl;
287 O->print_extensions(ost);
288 }
289}
290
291void poset_classification::print_fusion_nodes(int depth)
292{
293 int i, f, l, j, h;
294
295 for (i = 0; i <= depth; i++) {
296 f = Poo->first_node_at_level(i);
297 l = nb_orbits_at_level(i);
298 for (j = 0; j < l; j++) {
300
301 O = Poo->get_node(f + j);
302 for (h = 0; h < O->get_nb_of_extensions(); h++) {
303 extension *E = O->get_E(h);
304
305 if (E->get_type() == EXTENSION_TYPE_FUSION) {
306 cout << "fusion (" << f + j << "/" << h
307 << ") -> (" << E->get_data1() << "/"
308 << E->get_data2() << ")" << endl;
309 }
310 }
311 }
312 }
313}
314
315
316void poset_classification::read_data_file(int &depth_completed,
317 std::string &fname, int verbose_level)
318{
319 int f_v = TRUE; //(verbose_level >= 1);
320 long int size;
321 int nb_group_elements;
324
325
326 if (f_v) {
327 cout << "poset_classification::read_data_file "
328 "fname = " << fname << endl;
329 cout << "Poset->A->elt_size_in_int = "
330 << Poset->A->elt_size_in_int << endl;
331 cout << "Poset->A->coded_elt_size_in_char = "
332 << Poset->A->coded_elt_size_in_char << endl;
333 cout << "verbose_level=" << verbose_level << endl;
334 }
335 size = Fio.file_size(fname);
336 if (f_v) {
337 cout << "file size = " << size << endl;
338 }
339 if (size == -1) {
340 cout << "error: the file does not exist" << endl;
341 exit(1);
342 }
343 if (f_v) {
344 cout << "poset_classification::read_data_file "
345 "before m->alloc" << endl;
346 }
347
349 m->alloc(size, 0);
350
351 if (f_v) {
352 cout << "poset_classification::read_data_file "
353 "after m->alloc" << endl;
354 }
355
356 m->used_length = 0;
357
358
359 if (f_v) {
360 cout << "poset_classification::read_data_file "
361 "Before reading file " << fname << " of size "
362 << Fio.file_size(fname) << endl;
363 }
364 {
365 ifstream fp(fname, ios::binary);
366
367 fp.read((char *) m->data, size);
368 }
369 if (f_v) {
370 cout << "poset_classification::read_data_file "
371 "Read file " << fname << " of size "
372 << Fio.file_size(fname) << endl;
373 }
374
375 m->used_length = size;
376 m->cur_pointer = 0;
377
378 if (f_v) {
379 cout << "poset_classification::read_data_file "
380 "before read_memory_object" << endl;
381 }
382 Poo->read_memory_object(depth_completed, m,
383 nb_group_elements, verbose_level - 2);
384 if (f_v) {
385 cout << "poset_classification::read_data_file "
386 "after poset_classification_read_memory" << endl;
387 }
388
389 FREE_OBJECT(m);
390 if (f_v) {
391 cout << "poset_classification::read_data_file done" <<endl;
392 }
393
394}
395
396void poset_classification::write_data_file(int depth_completed,
397 std::string &fname_base, int verbose_level)
398{
400 int f_v = TRUE; //(verbose_level >= 1);
401 string fname;
402 int nb_group_elements;
403 long int size0;
404 int verbose_level1;
406
407 prepare_fname_data_file(fname, fname_base, depth_completed);
408 //sprintf(fname, "%s_%d.data", fname_base, depth_completed);
409
410 if (f_v) {
411 cout << "poset_classification::write_data_file "
412 "fname = " << fname << endl;
413 cout << "Poset->A->elt_size_in_int = "
414 << Poset->A->elt_size_in_int << endl;
415 cout << "Poset->A->coded_elt_size_in_char = "
416 << Poset->A->coded_elt_size_in_char << endl;
417 }
418 size0 = Poo->calc_size_on_file(
419 depth_completed, verbose_level);
420 if (f_v) {
421 cout << "size on file = " << size0 << endl;
422 }
423
424 verbose_level1 = verbose_level;
425 if (size0 > 1000 * ONE_MILLION) {
426 cout << "poset_classification::write_data_file "
427 "file=" << fname << endl;
428 cout << "size on file = " << size0 << endl;
429 cout << "the size is very big (> 1 GB)" << endl;
430 verbose_level1 = 2;
431 }
432
434 //m->alloc(10, 0);
435 m->alloc(size0, 0);
436 m->used_length = 0;
437
438 if (f_v) {
439 cout << "poset_classification::write_data_file "
440 "before write_memory_object" << endl;
441 }
443 depth_completed, m,
444 nb_group_elements, verbose_level1);
445 if (f_v) {
446 cout << "poset_classification::write_data_file "
447 "after write_memory_object, written " << nb_group_elements
448 << " group elements" << endl;
449 cout << "m->alloc_length=" << m->alloc_length << endl;
450 cout << "m->used_length=" << m->used_length << endl;
451 cout << "size0=" << size0 << endl;
452 }
453 if (m->used_length != size0) {
454 cout << "poset_classification::write_data_file "
455 "m->used_length != size0" << endl;
456 exit(1);
457 }
458
459 if (f_v) {
460 cout << "poset_classification::write_data_file "
461 "Writing data of size " << m->used_length
462 << " to file " << fname << endl;
463 }
464 {
465 ofstream fp(fname, ios::binary);
466
467 fp.write(m->data, m->used_length);
468 }
469 if (f_v) {
470 cout << "poset_classification::write_data_file "
471 "Written file " << fname << " of size "
472 << Fio.file_size(fname) << endl;
473 }
474
475
476 FREE_OBJECT(m);
477
478 if (f_v) {
479 cout << "poset_classification::write_data_file "
480 "finished written file "
481 << fname << " of size " << Fio.file_size(fname) << endl;
482 cout << " nb_group_elements=" << nb_group_elements << endl;
483 }
484}
485
486void poset_classification::write_file(
487 ofstream &fp,
488 int depth_completed, int verbose_level)
489{
491 int f_v = (verbose_level >= 1);
492 long int size0;
493 int nb_group_elements = 0;
494
495
496 if (f_v) {
497 cout << "poset_classification::write_file "
498 "depth_completed=" << depth_completed << endl;
499 }
500 size0 = Poo->calc_size_on_file(depth_completed, 0 /*verbose_level*/);
501 if (f_v) {
502 cout << "poset_classification::write_file size on file = " << size0 << endl;
503 }
504
505 if (size0 > 1000 * ONE_MILLION) {
506 cout << "poset_classification::write_file" << endl;
507 cout << "size on file = " << size0 << endl;
508 cout << "the size is very big (> 1 GB)" << endl;
509 }
510
512 m->alloc(10, 0);
513 //m->alloc(size0, 0);
514 m->used_length = 0;
515
516 if (f_v) {
517 cout << "poset_classification::write_file "
518 "before write_memory_object" << endl;
519 }
520 Poo->write_memory_object(depth_completed, m,
521 nb_group_elements, 0 /*verbose_level*/);
522 if (TRUE) {
523 cout << "poset_classification::write_file "
524 "after write_memory_object" << endl;
525 cout << "m->used_length=" << m->used_length << endl;
526 cout << "m->alloc_length=" << m->alloc_length << endl;
527 }
528 if (m->used_length != size0) {
529 cout << "poset_classification::write_file "
530 "m->used_length != size0" << endl;
531 cout << "m->used_length=" << m->used_length << endl;
532 cout << "size0" << size0 << endl;
533 exit(1);
534 }
535
536 long int size;
537 size = m->used_length;
538
539 if (size != size0) {
540 cout << "poset_classification::write_file size != size0" << endl;
541 cout << "poset_classification::write_file size = " << size << endl;
542 cout << "poset_classification::write_file size0 = " << size0 << endl;
543 exit(1);
544
545 }
546
547 if (f_v) {
548 cout << "poset_classification::write_file "
549 "before fp.write" << endl;
550 }
551 fp.write((char *) &depth_completed, sizeof(int));
552 fp.write((char *) &size, sizeof(long int));
553 fp.write(m->data, size);
554 if (f_v) {
555 cout << "poset_classification::write_file "
556 "after fp.write" << endl;
557 }
558
559 FREE_OBJECT(m);
560
561 if (f_v) {
562 cout << "poset_classification::write_file done" << endl;
563 }
564}
565
566void poset_classification::read_file(
567 ifstream &fp,
568 int &depth_completed, int verbose_level)
569{
571 int f_v = (verbose_level >= 1);
572 long int size;
573 int nb_group_elements;
574
575 if (f_v) {
576 cout << "poset_classification::read_file" << endl;
577 }
578
579
580 fp.read((char *) &depth_completed, sizeof(int));
581 fp.read((char *) &size, sizeof(long int));
582
583 if (f_v) {
584 cout << "poset_classification::read_file "
585 "size = " << size << endl;
586 }
587
589
590 m->alloc(size, 0);
591 m->used_length = 0;
592
593 fp.read(m->data, size);
594
595
596 m->used_length = size;
597 m->cur_pointer = 0;
598
599 if (f_v) {
600 cout << "poset_classification::read_file "
601 "before poset_classification_read_memory" << endl;
602 }
603 Poo->read_memory_object(depth_completed, m,
604 nb_group_elements, verbose_level - 0);
605 if (f_v) {
606 cout << "poset_classification::read_file "
607 "after poset_classification_read_memory" << endl;
608 }
609
610 FREE_OBJECT(m);
611
612 if (f_v) {
613 cout << "poset_classification::read_file done, "
614 "depth_completed=" << depth_completed << endl;
615 }
616}
617
618void poset_classification::housekeeping(int i,
619 int f_write_files, int t0, int verbose_level)
620{
621 int j, nb_nodes;
622 int f_v = (verbose_level >= 1);
623 int f_vv = (verbose_level >= 2);
624 int f_v5 = (verbose_level >= 5);
625 //int f_embedded = TRUE;
626
627 if (f_v) {
628 cout << "poset_classification::housekeeping "
629 "level=" << i << endl;
630 cout << "poset_classification::housekeeping "
631 "verbose_level=" << verbose_level << endl;
632 cout << "poset_classification::housekeeping "
633 "problem_label_with_path=" << problem_label_with_path << endl;
634 }
635 nb_nodes = nb_orbits_at_level(i);
636 if (f_v) {
637 cout << "###################################################"
638 "###############################################" << endl;
640 cout << "Found " << nb_nodes << " orbits at depth " << i << endl;
641
642 if (f_v5) {
643 cout << "orbits at level " << i << ":" << endl;
645 }
646
647 for (j = 0; j <= i; j++) {
648 cout << j << " : " << nb_orbits_at_level(j) << " orbits" << endl;
649 }
650 cout << "total: " << Poo->first_node_at_level(i + 1) << endl;
651
652
653
654 //print_statistic_on_callbacks();
656 //registry_dump_sorted();
657 //registry_dump_sorted_by_size();
658 //cout << "nb_times_trace=" << nb_times_trace << endl;
659 //cout << "nb_times_trace_was_saved="
660 // << nb_times_trace_was_saved << endl;
661 //cout << "f_write_files=" << f_write_files << endl;
662 int nb1, nb2;
663
664 nb1 = Schreier_vector_handler->nb_calls_to_coset_rep_inv;
665 nb2 = Schreier_vector_handler->nb_calls_to_coset_rep_inv_recursion;
666 cout << "nb_calls_to_coset_rep_inv="
667 << nb1 << endl;
668 cout << "nb_calls_to_coset_rep_inv_recursion="
669 << nb2 << endl;
670 cout << "average word length=" <<
671 (double) nb2 / (double) nb1 << endl;
672 }
673 if (Control->f_find_node_by_stabilizer_order) {
675 Control->find_node_by_stabilizer_order, verbose_level);
676 }
677 if (f_vv) {
678 if (nb_nodes < 1000) {
679 int f_with_strong_generators = FALSE;
680 int f_long_version = FALSE;
681 Poo->write_lvl(cout, i, t0, f_with_strong_generators,
682 f_long_version, verbose_level - 2);
683 }
684 }
685
686 if (f_write_files) {
687 string my_fname_base;
688
689 if (f_v) {
690 cout << "poset_classification_housekeeping "
691 "writing files" << endl;
692 }
693
694
695
696
697#if 1
698
699 string fname_reps_csv;
700 char str[1000];
701
702 fname_reps_csv.assign(problem_label_with_path);
703 sprintf(str, "_reps_lvl_%d", i);
704 fname_reps_csv.append(str);
705 fname_reps_csv.append(".csv");
706
707 Poo->save_representatives_at_level_to_csv(fname_reps_csv, i, verbose_level);
708
709
710 my_fname_base.assign(problem_label_with_path);
711 my_fname_base.append("a");
712 if (f_v) {
713 cout << "poset_classification_housekeeping "
714 "my_fname_base=" << my_fname_base << endl;
715 cout << "poset_classification_housekeeping "
716 "before write_level_file_binary" << endl;
717 }
718 write_level_file_binary(i, my_fname_base,
719 0/*verbose_level*/);
720 if (f_v) {
721 cout << "poset_classification_housekeeping "
722 "after write_level_file_binary" << endl;
723 }
724 if (i) {
725 my_fname_base.assign(problem_label_with_path);
726 my_fname_base.append("b");
727 if (f_v) {
728 cout << "poset_classification_housekeeping "
729 "my_fname_base=" << my_fname_base << endl;
730 cout << "poset_classification_housekeeping "
731 "before write_level_file_binary" << endl;
732 }
733 write_level_file_binary(i - 1, my_fname_base, 0/*verbose_level*/);
734 if (f_v) {
735 cout << "poset_classification_housekeeping "
736 "my_fname_base=" << my_fname_base << endl;
737 cout << "poset_classification_housekeeping "
738 "before write_sv_level_file_binary" << endl;
739 }
740 write_sv_level_file_binary(i - 1, my_fname_base,
741 FALSE, 0, 0, 0 /*verbose_level*/);
742 }
743#endif
744 if (f_v) {
745 cout << "poset_classification_housekeeping "
746 "before write_lvl_file" << endl;
747 }
748 Poo->write_lvl_file(problem_label_with_path, i, t0,
749 FALSE /* f_with_strong_generators */,
750 FALSE /* f_long_version */, 0);
751 if (f_v) {
752 cout << "poset_classification_housekeeping "
753 "after write_lvl_file" << endl;
754 }
755 if (f_v) {
756 cout << "poset_classification_housekeeping "
757 "before poset_classification::write_data_file" << endl;
758 }
759 poset_classification::write_data_file(i /* depth_completed */,
760 problem_label_with_path, verbose_level);
761
762 if (f_v) {
763 cout << "poset_classification::housekeeping "
764 "after poset_classification::write_data_file" << endl;
765 }
766 }
767 else {
768 if (f_v) {
769 cout << "poset_classification_housekeeping "
770 "not writing files" << endl;
771 }
772 }
773
774#if 0
775 if (Control->f_Log) {
776 int verbose_level = 1;
777 int f = first_poset_orbit_node_at_level[i];
778 int len = nb_orbits_at_level(i);
780 cout << "There are " << len
781 << " nodes at level " << i << ":" << endl;
782 for (j = 0; j < len; j++) {
783 Log_nodes(f + j, i, cout, FALSE, verbose_level);
784 }
785 }
786
787 if (Control->f_log && i == sz) {
788 int verbose_level = 1;
789 int ii;
790
791 for (ii = 0; ii <= sz; ii++) {
792 int f = first_poset_orbit_node_at_level[ii];
793 int len = nb_orbits_at_level(ii);
795 cout << "There are " << len
796 << " nodes at level " << ii << ":" << endl;
797 for (j = 0; j < len; j++) {
798 Log_nodes(f + j, ii, cout, FALSE, verbose_level);
799 }
800 }
801 }
802#endif
803
804 if (Control->f_T || (Control->f_t && i == sz)) {
805 if (f_v) {
806 cout << "poset_classification::housekeeping "
807 "before write_treefile_and_draw_tree" << endl;
808 }
809
810 write_treefile(problem_label_with_path, i,
811 Control->draw_options,
812 //Control->xmax, Control->ymax, Control->radius, f_embedded,
813 0 /*verbose_level - 1*/);
814 // in poset_classification_draw.cpp
815
816 if (f_v) {
817 cout << "poset_classification::housekeeping "
818 "after write_treefile_and_draw_tree" << endl;
819 }
820 }
821 else {
822 if (f_v) {
823 cout << "poset_classification_housekeeping "
824 "not writing tree" << endl;
825 }
826 }
827
828 if (f_v) {
829 cout << "poset_classification::housekeeping done" << endl;
830 }
831}
832
833void poset_classification::housekeeping_no_data_file(int i,
834 int t0, int verbose_level)
835{
836 int j;
837 int f_v = (verbose_level >= 1);
838 int f_v5 = (verbose_level >= 5);
839 //int f_embedded = TRUE;
840
841 if (f_v) {
842 cout << "poset_classification::"
843 "housekeeping_no_data_file "
844 "verbose_level=" << verbose_level << endl;
845 }
846 if (f_v) {
847 cout << "######################################################"
848 "############################################" << endl;
849 cout << "depth " << i << " completed, found "
850 << nb_orbits_at_level(i) << " orbits" << endl;
851
852
853 if (f_v5) {
854 cout << "orbits at level " << i << ":" << endl;
856 }
857
858
859
860 for (j = 0; j <= i; j++) {
861 cout << j << " : " << nb_orbits_at_level(j)
862 << " orbits" << endl;
863 }
864 cout << "total: " << Poo->first_node_at_level(i + 1) << endl;
866 }
867
868 if (Control->f_W || (Control->f_w && i == sz)) {
869#if 0
870 char fname_base2[1000];
871
872 sprintf(fname_base2, "%sa", fname_base);
873 write_level_file_binary(i, fname_base2, 1/*verbose_level*/);
874 if (i) {
875 sprintf(fname_base2, "%sb", fname_base);
876 write_level_file_binary(i - 1, fname_base2, 1/*verbose_level*/);
878 fname_base, FALSE, 0, 0, 1/*verbose_level*/);
879 }
880#endif
881
882 Poo->write_lvl_file(problem_label_with_path, i, t0,
883 FALSE /* f_with_strong_generators */,
884 FALSE /* f_long_version */, 0);
885
886 //poset_classification_write_data_file(gen,
887 // i /* depth_completed */, gen->fname_base, 0);
888
889 }
890
891 if (Control->f_T || (Control->f_t && i == sz)) {
892 write_treefile(problem_label_with_path, i,
893 Control->draw_options,
894 //Control->xmax, Control->ymax, Control->radius, f_embedded,
895 verbose_level - 1);
896 }
897 if (f_v) {
898 cout << "poset_classification::"
899 "housekeeping_no_data_file done" << endl;
900 }
901}
902
903void poset_classification::create_fname_sv_level_file_binary(std::string &fname,
904 std::string &fname_base, int level)
905{
906 char str[1000];
907
908 fname.assign(fname_base);
909 sprintf(str, "_lvl_%d_sv.data", level);
910 fname.append(str);
911
912}
913
914int poset_classification::test_sv_level_file_binary(
915 int level, std::string &fname_base)
916{
917 string fname;
919
920 create_fname_sv_level_file_binary(fname, fname_base, level);
921 //sprintf(fname, "%s_lvl_%d_sv.data", fname_base, level);
922 if (Fio.file_size(fname) >= 1) {
923 return TRUE;
924 }
925 else {
926 return FALSE;
927 }
928}
929
930void poset_classification::read_sv_level_file_binary(
931 int level, std::string &fname_base,
932 int f_split, int split_mod, int split_case,
933 int f_recreate_extensions, int f_dont_keep_sv,
934 int verbose_level)
935{
936 int f_v = (verbose_level >= 1);
937 string fname;
939
940 create_fname_sv_level_file_binary(fname, fname_base, level);
941 //sprintf(fname, "%s_lvl_%d_sv.data", fname_base, level);
942
943 if (f_v) {
944 cout << "poset_classification::read_sv_level_file_binary "
945 "reading file " << fname << " of size "
946 << Fio.file_size(fname) << endl;
947 }
948
949 {
950 ifstream fp(fname, ios::binary);
951
952 Poo->read_sv_level_file_binary2(level, fp,
953 f_split, split_mod, split_case,
954 f_recreate_extensions, f_dont_keep_sv,
955 verbose_level - 1);
956 }
957
958}
959
960void poset_classification::write_sv_level_file_binary(
961 int level, std::string &fname_base,
962 int f_split, int split_mod, int split_case,
963 int verbose_level)
964{
965 int f_v = (verbose_level >= 1);
966 string fname;
968
969 create_fname_sv_level_file_binary(fname, fname_base, level);
970 //sprintf(fname, "%s_lvl_%d_sv.data", fname_base, level);
971
972 if (f_v) {
973 cout << "poset_classification::write_sv_level_file_binary "
974 "fname = " << fname << endl;
975 }
976
977
978 {
979 ofstream fp(fname, ios::binary);
980
981 Poo->write_sv_level_file_binary2(level, fp,
982 f_split, split_mod, split_case,
983 verbose_level);
984 }
985
986 if (f_v) {
987 cout << "poset_classification::write_sv_level_file_binary "
988 "finished written file "
989 << fname << " of size " << Fio.file_size(fname) << endl;
990 }
991}
992
993void poset_classification::read_level_file_binary(int level,
994 std::string &fname_base, int verbose_level)
995{
996 int f_v = (verbose_level >= 1);
997 string fname;
998 char str[1000];
999 int nb_group_elements;
1001
1002 fname.assign(fname_base);
1003 sprintf(str, "_lvl_%d.data", level);
1004 fname.append(str);
1005
1006 if (f_v) {
1007 cout << "poset_classification::read_level_file_binary "
1008 "reading file " << fname << " of size "
1009 << Fio.file_size(fname) << endl;
1010 }
1011
1012 if (Fio.file_size(fname) < 0) {
1013 cout << "poset_classification::read_level_file_binary "
1014 "probems while reading file " << fname << endl;
1015 exit(1);
1016 }
1017
1018 {
1019 ifstream fp(fname, ios::binary);
1020
1021 Poo->read_level_file_binary2(level, fp,
1022 nb_group_elements, verbose_level);
1023 }
1024
1025}
1026
1027void poset_classification::write_level_file_binary(int level,
1028 std::string &fname_base, int verbose_level)
1029{
1030 int f_v = (verbose_level >= 1);
1031 string fname;
1032 char str[1000];
1033 int nb_group_elements;
1035
1036 fname.assign(fname_base);
1037 sprintf(str, "_lvl_%d.data", level);
1038 fname.append(str);
1039
1040 if (f_v) {
1041 cout << "poset_classification::write_level_file_binary "
1042 "fname = " << fname << endl;
1043 }
1044
1045
1046
1047 {
1048 ofstream fp(fname, ios::binary);
1049
1050 Poo->write_level_file_binary2(level, fp,
1051 nb_group_elements, verbose_level);
1052 }
1053
1054 if (f_v) {
1055 cout << "poset_classification::write_level_file_binary "
1056 "finished written file "
1057 << fname << " of size " << Fio.file_size(fname)
1058 << " nb_group_elements=" << nb_group_elements << endl;
1059 }
1060}
1061
1062
1063void poset_classification::recover(
1064 std::string &recover_fname,
1065 int &depth_completed, int verbose_level)
1066{
1067 int f_v = (verbose_level >= 1);
1068
1069 if (f_v) {
1070 cout << "poset_classification::recover "
1071 "recovering from file " << recover_fname << endl;
1072 }
1073 read_data_file(depth_completed, recover_fname, verbose_level);
1074 if (f_v) {
1075 cout << "poset_classification::recover "
1076 "recovering finished, "
1077 "depth_completed = " << depth_completed << endl;
1078 }
1079}
1080
1081void poset_classification::make_fname_lvl_file_candidates(std::string &fname,
1082 std::string &fname_base, int lvl)
1083{
1084 char str[1000];
1085
1086 fname.assign(fname_base);
1087 sprintf(str, "_lvl_%d_candidates.txt", lvl);
1088 fname.append(str);
1089
1090}
1091
1092void poset_classification::make_fname_lvl_file(std::string &fname,
1093 std::string &fname_base, int lvl)
1094{
1095 char str[1000];
1096
1097 fname.assign(fname_base);
1098 sprintf(str, "_lvl_%d", lvl);
1099 fname.append(str);
1100
1101}
1102
1103void poset_classification::make_fname_lvl_reps_file(std::string &fname,
1104 std::string &fname_base, int lvl)
1105{
1106 char str[1000];
1107
1108 fname.assign(fname_base);
1109 sprintf(str, "_lvl_%d_reps", lvl);
1110 fname.append(str);
1111
1112}
1113
1114
1115#if 0
1116void poset_classification::Log_nodes(int cur, int depth,
1117 ostream &f, int f_recurse,
1118 int verbose_level)
1119{
1120 int f_v = (verbose_level >= 1);
1121 int i, next;
1122 poset_orbit_node *node = &root[cur];
1123
1124
1125 if (f_v) {
1126 cout << "Log_nodes cur=" << cur << endl;
1127 }
1128 if (f_base_case && cur < Base_case->size) {
1129 return; // !!!
1130 }
1131 if (f_v) {
1132 f << "Node " << cur << endl;
1133 f << "===============" << endl;
1134 node->log_current_node(this, depth, f,
1135 FALSE /* f_with_strong_generators */,
1136 verbose_level);
1137 //f << "the stabilizer has order ";
1138 //G.print_group_order(f);
1139 //f << endl;
1140
1141 f << "with " << node->nb_strong_generators
1142 << " strong poset_classifications:" << endl;
1143 if (f_v) {
1144 cout << "Log_nodes cur=" << cur
1145 << " printing strong poset_classifications" << endl;
1146 }
1147 for (i = 0; i < node->nb_strong_generators; i++) {
1148 Poset->A->element_retrieve(
1149 node->hdl_strong_generators[i], Elt1, 0);
1150 Poset->A->element_print_quick(Elt1, f);
1151 f << endl;
1152 if (Poset->A->degree < 100) {
1153 Poset->A->element_print_as_permutation(Elt1, f);
1154 f << endl;
1155 }
1156 }
1157
1158 if (node->nb_strong_generators) {
1159 if (f_v) {
1160 cout << "Log_nodes cur=" << cur
1161 << " printing tl" << endl;
1162 }
1163 f << "tl: ";
1164 int_vec_print(f, node->tl, Poset->A->base_len());
1165 f << endl;
1166 }
1167
1168 if (f_v) {
1169 cout << "Log_nodes cur=" << cur
1170 << " printing extensions" << endl;
1171 }
1172 node->print_extensions(f);
1173 f << endl;
1174
1175 for (i = 0; i < node->get_nb_of_extensions(); i++) {
1176 if (node->get_E(i)->get_type() == EXTENSION_TYPE_FUSION) {
1177 f << "fusion node " << i << ":" << endl;
1178 Poset->A->element_retrieve(node->get_E(i)->get_data(), Elt1, 0);
1179 Poset->A->element_print_verbose(Elt1, f);
1180 f << endl;
1181 }
1182 }
1183 }
1184 else {
1185 //cout << "log_current_node node=" << node->node
1186 // << " prev=" << node->prev << endl;
1187 node->log_current_node(this, depth, f,
1188 FALSE /* f_with_strong_generators */, 0);
1189 }
1190
1191 if (f_recurse) {
1192 //cout << "recursing into dependent nodes" << endl;
1193 for (i = 0; i < node->get_nb_of_extensions(); i++) {
1194 if (node->get_E(i)->get_type() == EXTENSION_TYPE_EXTENSION) {
1195 if (node->get_E(i)->get_data() >= 0) {
1196 next = node->get_E(i)->get_data();
1197 Log_nodes(next, depth + 1, f, TRUE, verbose_level);
1198 }
1199 }
1200 }
1201 }
1202}
1203#endif
1204
1205void poset_classification::log_current_node(ostream &f, int size)
1206{
1207 //longinteger_object go;
1208 int i;
1209
1210
1211 f << size << " ";
1212 for (i = 0; i < size; i++) {
1213 f << set_S[i] << " ";
1214 }
1215 f << endl;
1216
1217}
1218
1219
1220
1221void poset_classification::make_spreadsheet_of_orbit_reps(
1222 data_structures::spreadsheet *&Sp, int max_depth)
1223{
1224 int Nb_orbits, nb_orbits, i, level, first;
1225 pchar *Text_level;
1226 pchar *Text_node;
1227 pchar *Text_orbit_reps;
1228 pchar *Text_stab_order;
1229 pchar *Text_orbit_length;
1230 pchar *Text_schreier_vector_length;
1232 int schreier_vector_length;
1233 long int *rep;
1234 char str[1000];
1236
1237 Nb_orbits = 0;
1238 for (level = 0; level <= max_depth; level++) {
1239 Nb_orbits += nb_orbits_at_level(level);
1240 }
1241
1242 rep = NEW_lint(max_depth);
1243 Text_level = NEW_pchar(Nb_orbits);
1244 Text_node = NEW_pchar(Nb_orbits);
1245 Text_orbit_reps = NEW_pchar(Nb_orbits);
1246 Text_stab_order = NEW_pchar(Nb_orbits);
1247 Text_orbit_length = NEW_pchar(Nb_orbits);
1248 Text_schreier_vector_length = NEW_pchar(Nb_orbits);
1249
1250 first = 0;
1251 for (level = 0; level <= max_depth; level++) {
1252 first = Poo->first_node_at_level(level);
1253 nb_orbits = nb_orbits_at_level(level);
1254 for (i = 0; i < nb_orbits; i++) {
1255 snprintf(str,1000, "%d", level);
1256 Text_level[first + i] = NEW_char(strlen(str) + 1);
1257 strcpy(Text_level[first + i], str);
1258
1259 snprintf(str, 1000, "%d", i);
1260 Text_node[first + i] = NEW_char(strlen(str) + 1);
1261 strcpy(Text_node[first + i], str);
1262
1263 get_set_by_level(level, i, rep);
1264 Lint_vec_print_to_str(str, rep, level);
1265 Text_orbit_reps[first + i] = NEW_char(strlen(str) + 1);
1266 strcpy(Text_orbit_reps[first + i], str);
1267
1269 stab_order, orbit_length);
1270 stab_order.print_to_string(str);
1271 Text_stab_order[first + i] = NEW_char(strlen(str) + 1);
1272 strcpy(Text_stab_order[first + i], str);
1273
1274 orbit_length.print_to_string(str);
1275 Text_orbit_length[first + i] = NEW_char(strlen(str) + 1);
1276 strcpy(Text_orbit_length[first + i], str);
1277
1278 O = get_node_ij(level, i);
1279 if (O->has_Schreier_vector()) {
1280 schreier_vector_length = O->get_nb_of_live_points();
1281 }
1282 else {
1283 schreier_vector_length = 0;
1284 }
1285 snprintf(str, 1000, "%d", schreier_vector_length);
1286 Text_schreier_vector_length[first + i] = NEW_char(strlen(str) + 1);
1287 strcpy(Text_schreier_vector_length[first + i], str);
1288 }
1289 }
1291 Sp->init_empty_table(Nb_orbits + 1, 7);
1292 Sp->fill_column_with_row_index(0, "Line");
1293 Sp->fill_column_with_text(1, (const char **)
1294 Text_level, "Level");
1295 Sp->fill_column_with_text(2, (const char **)
1296 Text_node, "Node");
1297 Sp->fill_column_with_text(3, (const char **)
1298 Text_orbit_reps, "Orbit rep");
1299 Sp->fill_column_with_text(4, (const char **)
1300 Text_stab_order, "Stab order");
1301 Sp->fill_column_with_text(5, (const char **)
1302 Text_orbit_length, "Orbit length");
1303 Sp->fill_column_with_text(6, (const char **)
1304 Text_schreier_vector_length, "Schreier vector length");
1305
1306#if 0
1307 cout << "before Sp->save " << fname_csv << endl;
1308 Sp->save(fname_csv, verbose_level);
1309 cout << "after Sp->save " << fname_csv << endl;
1310#endif
1311
1312 FREE_lint(rep);
1313 for (i = 0; i < Nb_orbits; i++) {
1314 FREE_char(Text_level[i]);
1315 }
1316 FREE_pchar(Text_level);
1317 for (i = 0; i < Nb_orbits; i++) {
1318 FREE_char(Text_node[i]);
1319 }
1320 FREE_pchar(Text_node);
1321 for (i = 0; i < Nb_orbits; i++) {
1322 FREE_char(Text_orbit_reps[i]);
1323 }
1324 FREE_pchar(Text_orbit_reps);
1325 for (i = 0; i < Nb_orbits; i++) {
1326 FREE_char(Text_stab_order[i]);
1327 }
1328 FREE_pchar(Text_stab_order);
1329 for (i = 0; i < Nb_orbits; i++) {
1330 FREE_char(Text_orbit_length[i]);
1331 }
1332 FREE_pchar(Text_orbit_length);
1333 for (i = 0; i < Nb_orbits; i++) {
1334 FREE_char(Text_schreier_vector_length[i]);
1335 }
1336 FREE_pchar(Text_schreier_vector_length);
1337
1338}
1339
1340void poset_classification::make_spreadsheet_of_level_info(
1341 data_structures::spreadsheet *&Sp, int max_depth,
1342 int verbose_level)
1343{
1344 int f_v = (verbose_level >= 1);
1345 //int f_vv = FALSE; //(verbose_level >= 1);
1346 int nb_rows, Nb_orbits, nb_orbits, i, level;
1347 pchar *Text_label;
1348 pchar *Text_nb_orbits;
1349 pchar *Text_orbit_length_sum;
1350 pchar *Text_schreier_vector_length_sum;
1351 pchar *Text_binomial;
1353 orbit_length_sum, orbit_length_total;
1357 int schreier_vector_length_int;
1358 ring_theory::longinteger_object schreier_vector_length,
1359 schreier_vector_length_sum, schreier_vector_length_total;
1360 int *rep;
1361 char str[1000];
1363
1364 if (f_v) {
1365 cout << "poset_classification::"
1366 "make_spreadsheet_of_level_info" << endl;
1367 }
1368 nb_rows = max_depth + 2; // one extra row for totals
1369 rep = NEW_int(max_depth);
1370 Text_label = NEW_pchar(nb_rows);
1371 Text_nb_orbits = NEW_pchar(nb_rows);
1372 Text_orbit_length_sum = NEW_pchar(nb_rows);
1373 Text_schreier_vector_length_sum = NEW_pchar(nb_rows);
1374 Text_binomial = NEW_pchar(nb_rows);
1375
1376 Nb_orbits = 0;
1377 orbit_length_total.create(0, __FILE__, __LINE__);
1378 schreier_vector_length_total.create(0, __FILE__, __LINE__);
1379 a_total.create(0, __FILE__, __LINE__);
1380
1381 for (level = 0; level <= max_depth; level++) {
1382
1383 if (f_v) {
1384 cout << "poset_classification::"
1385 "make_spreadsheet_of_level_info "
1386 "level = " << level << " / " << max_depth << endl;
1387 }
1388 nb_orbits = nb_orbits_at_level(level);
1389
1390
1391 snprintf(str, 1000, "%d", level);
1392 Text_label[level] = NEW_char(strlen(str) + 1);
1393 strcpy(Text_label[level], str);
1394
1395 snprintf(str, 1000, "%d", nb_orbits);
1396 Text_nb_orbits[level] = NEW_char(strlen(str) + 1);
1397 strcpy(Text_nb_orbits[level], str);
1398
1399 orbit_length_sum.create(0, __FILE__, __LINE__);
1400 schreier_vector_length_sum.create(0, __FILE__, __LINE__);
1401
1402 for (i = 0; i < nb_orbits; i++) {
1403
1404 if (FALSE) {
1405 cout << "poset_classification::"
1406 "make_spreadsheet_of_level_info "
1407 "level = " << level << " / " << max_depth
1408 << " orbit " << i << " / " << nb_orbits << endl;
1409 }
1411 stab_order, orbit_length);
1412
1413 D.add_in_place(orbit_length_sum, orbit_length);
1414
1415
1416 O = get_node_ij(level, i);
1417
1418 if (O->has_Schreier_vector()) {
1419 schreier_vector_length_int = O->get_nb_of_live_points();
1420
1421
1422 }
1423 else {
1424 //cout << "node " << level << " / " << i
1425 // << " does not have a Schreier vector" << endl;
1426 schreier_vector_length_int = 1;
1427 }
1428 if (schreier_vector_length_int <= 0) {
1429 schreier_vector_length_int = 1;
1430 }
1431 schreier_vector_length.create(schreier_vector_length_int, __FILE__, __LINE__);
1432
1433 if (schreier_vector_length_int >= 0) {
1434 D.add_in_place(schreier_vector_length_sum,
1435 schreier_vector_length);
1436 }
1437
1438 }
1439
1440 //cout << "poset_classification::make_spreadsheet_of_level_info
1441 // computing binomial coeffcient" << endl;
1442 C.binomial(a, Poset->A2->degree, level, FALSE);
1443
1444 Nb_orbits += nb_orbits;
1445 D.add_in_place(orbit_length_total, orbit_length_sum);
1446 D.add_in_place(schreier_vector_length_total,
1447 schreier_vector_length_sum);
1448 D.add_in_place(a_total, a);
1449
1450 orbit_length_sum.print_to_string(str);
1451 Text_orbit_length_sum[level] = NEW_char(strlen(str) + 1);
1452 strcpy(Text_orbit_length_sum[level], str);
1453
1454 schreier_vector_length_sum.print_to_string(str);
1455 Text_schreier_vector_length_sum[level] = NEW_char(strlen(str) + 1);
1456 strcpy(Text_schreier_vector_length_sum[level], str);
1457
1458 a.print_to_string(str);
1459 Text_binomial[level] = NEW_char(strlen(str) + 1);
1460 strcpy(Text_binomial[level], str);
1461
1462 }
1463
1464 level = max_depth + 1;
1465 snprintf(str, 1000, "total");
1466 Text_label[level] = NEW_char(strlen(str) + 1);
1467 strcpy(Text_label[level], str);
1468
1469 snprintf(str, 1000, "%d", Nb_orbits);
1470 Text_nb_orbits[level] = NEW_char(strlen(str) + 1);
1471 strcpy(Text_nb_orbits[level], str);
1472
1473 orbit_length_total.print_to_string(str);
1474 Text_orbit_length_sum[level] = NEW_char(strlen(str) + 1);
1475 strcpy(Text_orbit_length_sum[level], str);
1476
1477 schreier_vector_length_total.print_to_string(str);
1478 Text_schreier_vector_length_sum[level] = NEW_char(strlen(str) + 1);
1479 strcpy(Text_schreier_vector_length_sum[level], str);
1480
1481 a_total.print_to_string(str);
1482 Text_binomial[level] = NEW_char(strlen(str) + 1);
1483 strcpy(Text_binomial[level], str);
1484
1485
1487 Sp->init_empty_table(nb_rows + 1, 6);
1488 Sp->fill_column_with_row_index(0, "Line");
1489 Sp->fill_column_with_text(1, (const char **) Text_label, "Level");
1490 Sp->fill_column_with_text(2, (const char **) Text_nb_orbits, "Nb_orbits");
1491 Sp->fill_column_with_text(3, (const char **) Text_orbit_length_sum, "Orbit_length_sum");
1492 Sp->fill_column_with_text(4, (const char **) Text_schreier_vector_length_sum, "Schreier_vector_length_sum");
1493 Sp->fill_column_with_text(5, (const char **) Text_binomial, "Binomial");
1494
1495
1496
1497#if 0
1498 cout << "before Sp->save " << fname_csv << endl;
1499 Sp->save(fname_csv, verbose_level);
1500 cout << "after Sp->save " << fname_csv << endl;
1501#endif
1502
1503 FREE_int(rep);
1504 for (i = 0; i < nb_rows; i++) {
1505 FREE_char(Text_label[i]);
1506 }
1507 FREE_pchar(Text_label);
1508 for (i = 0; i < nb_rows; i++) {
1509 FREE_char(Text_nb_orbits[i]);
1510 }
1511 FREE_pchar(Text_nb_orbits);
1512 for (i = 0; i < nb_rows; i++) {
1513 FREE_char(Text_orbit_length_sum[i]);
1514 }
1515 FREE_pchar(Text_orbit_length_sum);
1516 for (i = 0; i < nb_rows; i++) {
1517 FREE_char(Text_schreier_vector_length_sum[i]);
1518 }
1519 FREE_pchar(Text_schreier_vector_length_sum);
1520 for (i = 0; i < nb_rows; i++) {
1521 FREE_char(Text_binomial[i]);
1522 }
1523 FREE_pchar(Text_binomial);
1524
1525}
1526
1527
1528
1529
1530void poset_classification::create_schreier_tree_fname_mask_base(
1531 std::string &fname_mask)
1532{
1533
1534 fname_mask.assign(problem_label_with_path);
1535 fname_mask.append(Control->schreier_tree_prefix);
1536 fname_mask.append("schreier_tree_node_%d_%d");
1537}
1538
1539void poset_classification::create_schreier_tree_fname_mask_base_tex(
1540 std::string &fname_mask)
1541{
1542
1543 fname_mask.assign(problem_label_with_path);
1544 fname_mask.append(Control->schreier_tree_prefix);
1545 fname_mask.append("schreier_tree_node_%d.tex");
1546}
1547
1548void poset_classification::create_shallow_schreier_tree_fname_mask_base(
1549 std::string &fname_mask)
1550{
1551
1552 fname_mask.assign(problem_label_with_path);
1553 fname_mask.append(Control->schreier_tree_prefix);
1554 fname_mask.append("shallow_schreier_tree_node_%d_%d");
1555
1556}
1557
1558void poset_classification::create_shallow_schreier_tree_fname_mask(
1559 std::string &fname, int node)
1560{
1561
1562 char str[1000];
1563
1564 sprintf(str, "%d", node);
1565 fname.assign(problem_label_with_path);
1566 fname.append(Control->schreier_tree_prefix);
1567 fname.append("shallow_schreier_tree_node_");
1568 fname.append(str);
1569 fname.append("_%d");
1570
1571}
1572
1573void poset_classification::make_fname_candidates_file_default(
1574 char *fname2000, int level)
1575{
1576 snprintf(fname2000, 2000, "%s_lvl_%d_candidates.bin",
1577 problem_label_with_path.c_str(), level);
1578}
1579
1580
1581void poset_classification::wedge_product_export_magma(
1582 int n, int q, int vector_space_dimension,
1583 int level, int verbose_level)
1584{
1585 int f_v = (verbose_level >= 1);
1587
1588
1589 if (f_v) {
1590 cout << "poset_classification::wedge_product_export_magma" << endl;
1591 }
1592
1593 //int level;
1594 long int *the_set;
1595 int *v;
1596 int a, i, j, h, fst, len, ii, jj;
1598 int *Elt;
1599
1600 //level = depth_completed + 1;
1601
1602
1603 the_set = NEW_lint(level);
1604 v = NEW_int(vector_space_dimension);
1605 Elt = NEW_int(Poset->A->elt_size_in_int);
1606
1607 fst = Poo->first_node_at_level(level);
1608 len = Poo->first_node_at_level(level + 1) - fst;
1609 if (f_v) {
1610 cout << "exporting to magma" << endl;
1611 cout << "fst=" << fst << " len=" << len << endl;
1612 }
1614 char fname[1000];
1615
1616 snprintf(fname, 1000, "Wedge_n%d_q%d_d%d.magma", n, q, level);
1617
1618 {
1619 ofstream f(fname);
1620
1621 f << "// file " << fname << endl;
1622 f << "n := " << n << ";" << endl;
1623 f << "q := " << q << ";" << endl;
1624 f << "d := " << level << ";" << endl;
1625 f << "n2 := " << vector_space_dimension << ";" << endl;
1626 f << "V := VectorSpace (GF (q), n2);" << endl;
1627 f << endl;
1628 f << "/* list of orbit reps */" << endl;
1629 f << "L := [" << endl;
1630 f << endl;
1631
1632 for (i = 0; i < len; i++) {
1633 O = Poo->get_node(fst + i);
1634
1635 f << "// orbit rep " << i << endl;
1636 f << "[" << endl;
1637 O->store_set_to(this, level - 1, the_set);
1638 for (j = 0; j < level; j++) {
1639 a = the_set[j];
1640 unrank_point(v, a);
1641 f << "[ ";
1642 for (h = 0; h < vector_space_dimension; h++) {
1643 f << v[h];
1644 if (h < vector_space_dimension - 1) {
1645 f << ", ";
1646 }
1647 }
1648 f << " ]";
1649 if (j < level - 1) {
1650 f << "," << endl;
1651 }
1652 else {
1653 f << "]" << endl;
1654 }
1655 }
1656 if (i < len - 1) {
1657 f << "," << endl << endl;
1658 }
1659 else {
1660 f << endl << "];" << endl << endl;
1661 }
1662 } // next i
1663
1664 f << "// list of orbit lengths " << endl;
1665 f << "len := \[";
1666
1667 for (i = 0; i < len; i++) {
1668
1669 if ((i % 20) == 0) {
1670 f << endl;
1671 f << "// orbits " << i << " and following:" << endl;
1672 }
1673
1674 orbit_length(i, level, go);
1675 f << go;
1676 if (i < len - 1) {
1677 f << ", ";
1678 }
1679 }
1680 f << "];" << endl << endl;
1681
1682
1683 f << "// subspaces of vector space " << endl;
1684 f << "L := [sub< V | L[i]>: i in [1..#L]];" << endl;
1685
1686 f << "// stabilisers " << endl;
1687 f << "P := GL(n, q);" << endl;
1688 f << "E := ExteriorSquare (P);" << endl;
1689
1690
1691 f << "// base:" << endl;
1692 f << "BV := VectorSpace (GF (q), n);" << endl;
1693 f << "B := [ BV | " << endl;
1694 for (i = 0; i < Poset->A->base_len(); i++) {
1695 a = Poset->A->base_i(i);
1696 Poset->VS->F->PG_element_unrank_modified(v, 1, n, a);
1697 //(*Gen->unrank_point_func)(v, a, Gen->rank_point_data);
1698 f << "[ ";
1699 for (h = 0; h < n; h++) {
1700 f << v[h];
1701 if (h < n - 1) {
1702 f << ", ";
1703 }
1704 }
1705 if (i < Poset->A->base_len() - 1) {
1706 f << "], " << endl;
1707 }
1708 else {
1709 f << " ]" << endl;
1710 }
1711 }
1712 f << "];" << endl;
1713 f << endl;
1714 f << "P`Base := B;" << endl;
1715
1716 f << "// list of stabilizer generators" << endl;
1717 f << "S := [" << endl;
1718 f << endl;
1719
1720 for (i = 0; i < len; i++) {
1721 O = Poo->get_node(fst + i);
1722
1723 std::vector<int> gen_hdl;
1724 std::vector<int> tl;
1725
1726 O->get_strong_generators_handle(gen_hdl, verbose_level);
1727
1728 O->get_tl(tl, this, verbose_level);
1729
1730 f << "// orbit rep " << i << " has "
1731 << gen_hdl.size() << " strong generators";
1732 if (gen_hdl.size()) {
1733 f << ", transversal lengths: ";
1734 //int_vec_print(f, O->tl, Poset->A->base_len());
1735 for (h = 0; h < tl.size(); h++) {
1736 f << tl[h];
1737 }
1738 }
1739 f << endl;
1740 f << "[" << endl;
1741
1742 for (j = 0; j < gen_hdl.size(); j++) {
1743
1744 Poset->A->element_retrieve(gen_hdl[j], Elt, 0);
1745
1746 f << "[";
1747 //Gen->A->element_print_quick(Elt, f);
1748 for (ii = 0; ii < n; ii++) {
1749 f << "[";
1750 for (jj = 0; jj < n; jj++) {
1751 a = Elt[ii * n + jj];
1752 f << a;
1753 if (jj < n - 1) {
1754 f << ", ";
1755 }
1756 else {
1757 f << "]";
1758 }
1759 }
1760 if (ii < n - 1) {
1761 f << "," << endl;
1762 }
1763 else {
1764 f << "]";
1765 }
1766 }
1767
1768 if (j < gen_hdl.size() - 1) {
1769 f << "," << endl;
1770 }
1771 }
1772 f << "]" << endl;
1773 if (i < len - 1) {
1774 f << "," << endl << endl;
1775 }
1776 else {
1777 f << endl << "];" << endl << endl;
1778 }
1779 } // next i
1780
1781 f << endl << "T := [sub<GL(n, q) | [&cat (s): "
1782 "s in S[i]]> : i in [1..#S]];"
1783 << endl << endl;
1784 } // file f
1785
1786 FREE_lint(the_set);
1787 FREE_int(v);
1788 FREE_int(Elt);
1789
1790 if (f_v) {
1791 cout << "written file " << fname << " of size "
1792 << Fio.file_size(fname) << endl;
1793 }
1794 if (f_v) {
1795 cout << "poset_classification::wedge_product_export_magma "
1796 "done" << endl;
1797 }
1798}
1799
1800void poset_classification::write_reps_csv(int lvl, int verbose_level)
1801{
1802 int f_v = (verbose_level >= 1);
1803 string fname_reps_csv;
1804 char str[1000];
1805
1806 if (f_v) {
1807 cout << "poset_classification::write_reps_csv" << endl;
1808 }
1809 fname_reps_csv.assign(problem_label_with_path);
1810 sprintf(str, "_reps_lvl_%d", lvl);
1811 fname_reps_csv.append(str);
1812 fname_reps_csv.append(".csv");
1813
1814 Poo->save_representatives_at_level_to_csv(fname_reps_csv, lvl, verbose_level);
1815
1816 if (f_v) {
1817 cout << "poset_classification::write_reps_csv done" << endl;
1818 }
1819
1820}
1821
1822
1823
1824
1825}}}
1826
1827
void binomial(ring_theory::longinteger_object &a, int n, int k, int verbose_level)
void fill_column_with_text(int col_idx, const char **text, const char *heading)
void fill_column_with_row_index(int col_idx, const char *heading)
void save(std::string &fname, int verbose_level)
void PG_element_unrank_modified(int *v, int stride, int len, int a)
domain to compute with objects of type longinteger
Definition: ring_theory.h:240
void add_in_place(longinteger_object &a, longinteger_object &b)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
void create(long int i, const char *file, int line)
void element_print_quick(void *elt, std::ostream &ost)
Definition: action_cb.cpp:353
void element_retrieve(int hdl, void *elt, int verbose_level)
Definition: action_cb.cpp:301
void element_print_as_permutation(void *elt, std::ostream &ost)
Definition: action_cb.cpp:421
void element_print_verbose(void *elt, std::ostream &ost)
Definition: action_cb.cpp:397
represents a flag in the poset classification algorithm; related to poset_orbit_node
void print_progress(int size, int cur, int prev, int nb_ext_cur, int nb_fuse_cur)
void orbit_length(int orbit_at_level, int level, ring_theory::longinteger_object &len)
void write_treefile(std::string &fname_base, int lvl, graphics::layered_graph_draw_options *draw_options, int verbose_level)
void write_level_file_binary(int level, std::string &fname_base, int verbose_level)
void get_orbit_length_and_stabilizer_order(int node, int level, ring_theory::longinteger_object &stab_order, ring_theory::longinteger_object &len)
void create_fname_sv_level_file_binary(std::string &fname, std::string &fname_base, int level)
void write_sv_level_file_binary(int level, std::string &fname_base, int f_split, int split_mod, int split_case, int verbose_level)
void write_data_file(int depth_completed, std::string &fname_base, int verbose_level)
void prepare_fname_data_file(std::string &fname, std::string &fname_base, int depth_completed)
void read_data_file(int &depth_completed, std::string &fname, int verbose_level)
void read_sv_level_file_binary2(int level, std::ifstream &fp, int f_split, int split_mod, int split_case, int f_recreate_extensions, int f_dont_keep_sv, int verbose_level)
void read_level_file_binary2(int level, std::ifstream &fp, int &nb_group_elements, int verbose_level)
void write_level_file_binary2(int level, std::ofstream &fp, int &nb_group_elements, int verbose_level)
void write_lvl(std::ostream &f, int lvl, int t0, int f_with_stabilizer_generators, int f_long_version, int verbose_level)
void save_representatives_at_level_to_csv(std::string &fname, int lvl, int verbose_level)
void write_memory_object(int depth_completed, orbiter_kernel_system::memory_object *m, int &nb_group_elements, int verbose_level)
long int calc_size_on_file(int depth_completed, int verbose_level)
void read_memory_object(int &depth_completed, orbiter_kernel_system::memory_object *m, int &nb_group_elements, int verbose_level)
void write_sv_level_file_binary2(int level, std::ofstream &fp, int f_split, int split_mod, int split_case, int verbose_level)
void write_lvl_file(std::string &fname_base, int lvl, int t0, int f_with_stabilizer_generators, int f_long_version, int verbose_level)
to represent one poset orbit; related to the class poset_classification
void get_tl(std::vector< int > &tl, poset_classification *PC, int verbose_level)
void log_current_node(poset_classification *gen, int s, std::ostream &f, int f_with_stabilizer_poset_classifications, int verbose_level)
void get_strong_generators_handle(std::vector< int > &gen_hdl, int verbose_level)
void store_set_to(poset_classification *gen, int i, long int *to)
#define NEW_pchar(n)
Definition: foundations.h:635
#define FREE_pchar(p)
Definition: foundations.h:648
#define FREE_int(p)
Definition: foundations.h:640
char * pchar
Definition: foundations.h:203
#define ONE_MILLION
Definition: foundations.h:226
#define NEW_char(n)
Definition: foundations.h:632
#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
#define Lint_vec_print_to_str(A, B, C)
Definition: foundations.h:697
#define FREE_char(p)
Definition: foundations.h:646
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
the orbiter library for the classification of combinatorial objects
#define EXTENSION_TYPE_FUSION
#define EXTENSION_TYPE_EXTENSION