Orbiter 2022
Combinatorial Objects
design_activity.cpp
Go to the documentation of this file.
1/*
2 * design_activity.cpp
3 *
4 * Created on: May 26, 2021
5 * Author: betten
6 */
7
8
9#include "orbiter.h"
10
11using namespace std;
12
13namespace orbiter {
14namespace layer5_applications {
15namespace apps_combinatorics {
16
17
19{
20 Descr = NULL;
21
22}
23
25{
26
27}
28
30 design_create *DC, int verbose_level)
31{
32 int f_v = (verbose_level >= 1);
33
34 if (f_v) {
35 cout << "design_activity::perform_activity" << endl;
36 }
37
39
40#if 0
41 if (Descr->f_create_table) {
42
43
45 DC,
46 Descr->create_table_label,
47 Descr->create_table_group,
48 //Descr->create_table_group_order,
49 //Descr->create_table_gens,
50 verbose_level);
51
52
53 }
54#endif
55 if (Descr->f_load_table) {
57 DC,
64 verbose_level);
65 }
66 else if (Descr->f_canonical_form) {
68 verbose_level);
69 }
71
72 if (f_v) {
73 cout << "design_activity::perform_activity f_extract_solutions_by_index_csv" << endl;
74 }
75
77 DC,
83 TRUE /* f_csv */,
84 verbose_level);
85
86 if (f_v) {
87 cout << "design_activity::perform_activity f_extract_solutions_by_index_csv done" << endl;
88 }
89 }
91
92 if (f_v) {
93 cout << "design_activity::perform_activity f_extract_solutions_by_index_txt" << endl;
94 }
95
97 DC,
103 FALSE /* f_csv */,
104 verbose_level);
105
106 if (f_v) {
107 cout << "design_activity::perform_activity f_extract_solutions_by_index_txt done" << endl;
108 }
109 }
110 else if (Descr->f_export_inc) {
111 if (f_v) {
112 cout << "design_activity::perform_activity export_inc" << endl;
113 }
115 DC,
116 verbose_level);
117 }
118 else if (Descr->f_export_blocks) {
119 if (f_v) {
120 cout << "design_activity::perform_activity export_blocks" << endl;
121 }
123 DC,
124 verbose_level);
125 }
126 else if (Descr->f_row_sums) {
127 if (f_v) {
128 cout << "design_activity::perform_activity row_sums" << endl;
129 }
131 DC,
132 verbose_level);
133 }
135 if (f_v) {
136 cout << "design_activity::perform_activity f_tactical_decomposition" << endl;
137 }
139 DC,
140 verbose_level);
141 }
142
143
144 if (f_v) {
145 cout << "design_activity::perform_activity done" << endl;
146 }
147
148}
149
150
152 design_create *DC,
153 std::string &label,
154 std::string &group_label,
155 std::string &fname_in,
156 std::string &fname_out,
157 std::string &prefix_text,
158 int f_csv_format,
159 int verbose_level)
160{
161 int f_v = (verbose_level >= 1);
162
163 if (f_v) {
164 cout << "design_activity::do_extract_solutions_by_index" << endl;
165 }
166
168 design_tables *T;
169
170 int idx;
172
174
176
178
179 if (t != t_any_group) {
180 cout << "object must be of type group, but is ";
182 cout << endl;
183 exit(1);
184 }
186
187
188 Combi.load_design_table(DC,
189 label,
190 T,
191 AG->Subgroup_gens,
192 verbose_level);
193
194 if (f_v) {
195 cout << "design_activity::do_extract_solutions_by_index after Combi.load_design_table" << endl;
196 }
197
198 int *prefix;
199 int prefix_sz;
200
201 Int_vec_scan(prefix_text, prefix, prefix_sz);
202
204 int *Sol_idx;
205 int nb_sol;
206 int sol_width;
207
208 if (f_csv_format) {
209 int *Sol_idx_1;
210 int i, j;
211 Fio.int_matrix_read_csv(fname_in, Sol_idx_1, nb_sol, sol_width, verbose_level);
212
213 Sol_idx = NEW_int(nb_sol * (prefix_sz + sol_width));
214 for (i = 0; i < nb_sol; i++) {
215 for (j = 0; j < prefix_sz; j++) {
216 Sol_idx[i * (prefix_sz + sol_width) + j] = prefix[j];
217 }
218 for (j = 0; j < sol_width; j++) {
219 Sol_idx[i * (prefix_sz + sol_width) + prefix_sz + j] = Sol_idx_1[i * sol_width + j];
220 }
221 }
222 FREE_int(Sol_idx_1);
223 sol_width += prefix_sz;
224 }
225 else {
227 int underlying_set_size = 0;
228 int i, j;
229
231 SoS->init_from_orbiter_file(underlying_set_size,
232 fname_in, verbose_level);
233 nb_sol = SoS->nb_sets;
234 if (nb_sol) {
235 if (!SoS->has_constant_size_property()) {
236 cout << "design_activity::do_extract_solutions_by_index the sets have different sizes" << endl;
237 exit(1);
238 }
239 sol_width = SoS->Set_size[0];
240
241 Sol_idx = NEW_int(nb_sol * (prefix_sz + sol_width));
242 for (i = 0; i < nb_sol; i++) {
243 for (j = 0; j < prefix_sz; j++) {
244 Sol_idx[i * (prefix_sz + sol_width) + j] = prefix[j];
245 }
246 for (j = 0; j < sol_width; j++) {
247 Sol_idx[i * (prefix_sz + sol_width) + prefix_sz + j] = SoS->Sets[i][j];
248 }
249 }
250 sol_width += prefix_sz;
251 }
252 else {
253 Sol_idx = NEW_int(1);
254 }
255 FREE_OBJECT(SoS);
256 }
257
258
259 if (f_v) {
260 cout << "design_activity::do_extract_solutions_by_index before T->extract_solutions_by_index" << endl;
261 }
262
264 nb_sol, sol_width, Sol_idx,
265 fname_out,
266 verbose_level);
267
268 if (f_v) {
269 cout << "design_activity::do_extract_solutions_by_index after T->extract_solutions_by_index" << endl;
270 }
271
272
273
274 if (f_v) {
275 cout << "design_activity::do_extract_solutions_by_index done" << endl;
276 }
277}
278
279
280
282 design_create *DC,
283 std::string &label,
284 std::string &group_label,
285 int verbose_level)
286{
287 int f_v = (verbose_level >= 1);
288
289 if (f_v) {
290 cout << "design_activity::do_create_table" << endl;
291 }
292
294 design_tables *T;
295
296
297 int idx;
299
301
303
305
306 if (t != t_any_group) {
307 cout << "object must be of type group, but is ";
309 cout << endl;
310 exit(1);
311 }
313
314 if (f_v) {
315 cout << "design_activity::do_create_table before Combi.create_design_table" << endl;
316 }
317
318 Combi.create_design_table(DC,
319 label,
320 T,
321 AG->Subgroup_gens,
322 verbose_level);
323
324 if (f_v) {
325 cout << "design_activity::do_create_table after Combi.create_design_table" << endl;
326 }
327
328 if (f_v) {
329 cout << "design_activity::do_create_table done" << endl;
330 }
331}
332
333
335 design_create *DC,
336 std::string &label,
337 std::string &group_label,
338 std::string &H_label,
339 std::string &H_go_text,
340 std::string &H_generators_data,
341 int selected_orbit_length,
342 int verbose_level)
343{
344 int f_v = (verbose_level >= 1);
345
346 if (f_v) {
347 cout << "design_activity::do_load_table" << endl;
348 }
349
350
351
352 int idx;
354
356
358
360
361 if (t != t_any_group) {
362 cout << "object must be of type group, but is ";
364 cout << endl;
365 exit(1);
366 }
368
369 if (f_v) {
370 cout << "design_activity::do_create_table before Combi.load_design_table" << endl;
371 }
372
374 design_tables *T;
375
376 Combi.load_design_table(DC,
377 label,
378 T,
379 AG->Subgroup_gens,
380 verbose_level);
381
382 if (f_v) {
383 cout << "design_activity::do_create_table after Combi.load_design_table" << endl;
384 }
385
386
388
390
391 if (f_v) {
392 cout << "design_activity::do_create_table before LS->init" << endl;
393 }
394 LS->init(DC,
395 T,
396 verbose_level);
397 if (f_v) {
398 cout << "design_activity::do_create_table after LS->init" << endl;
399 }
400
401
402
405
406 if (f_v) {
407 cout << "design_activity::do_load_table before H_gens->init_from_data_with_go" << endl;
408 }
410 DC->A, H_generators_data,
411 H_go_text,
412 verbose_level);
413 if (f_v) {
414 cout << "design_activity::do_load_table after H_gens->init_from_data_with_go" << endl;
415 }
416
417
418#if 0
419 large_set_was *LSW;
420
422
423
424 if (f_v) {
425 cout << "design_activity::do_load_table before LSW->init" << endl;
426 }
427 LSW->init(LS,
428 H_gens, H_label,
429 selected_orbit_length,
430 verbose_level);
431 if (f_v) {
432 cout << "design_activity::do_load_table after LSW->init" << endl;
433 }
434
435#endif
436
437 if (f_v) {
438 cout << "design_activity::do_load_table done" << endl;
439 }
440}
441
443 int verbose_level)
444{
445 int f_v = (verbose_level >= 1);
446
447 if (f_v) {
448 cout << "design_activity::do_canonical_form" << endl;
449 }
450
451
453
454#if 0
455
456 if (f_v) {
457 cout << "design_activity::do_canonical_form" << endl;
458 }
459
460 OC = NEW_OBJECT(classification_of_objects);
461
462 if (f_v) {
463 cout << "design_activity::do_canonical_form before OC->do_the_work" << endl;
464 }
465 OC->do_the_work(
466 Canonical_form_Descr,
467 FALSE,
468 NULL,
469 verbose_level);
470 if (f_v) {
471 cout << "design_activity::do_canonical_form after OC->do_the_work" << endl;
472 }
473
474 FREE_OBJECT(OC);
475
476
477#endif
478
479 if (f_v) {
480 cout << "design_activity::do_canonical_form done" << endl;
481 }
482
483}
484
486 design_create *DC,
487 int verbose_level)
488{
489 int f_v = (verbose_level >= 1);
490
491 if (f_v) {
492 cout << "design_activity::do_export_inc" << endl;
493 }
494
495 string fname;
496
497 fname.assign(DC->label_txt);
498 fname.append("_inc.txt");
499
501
502 int v = DC->degree;
503 int k = DC->k;
504 int b = DC->sz;
505
506 int N = k * b;
507 int *M;
508 int h;
509
510 Combi.compute_incidence_matrix(v, b, k, DC->set,
511 M, verbose_level);
512
513
514 {
515 ofstream ost(fname);
516
517 ost << v << " " << b << " " << N << endl;
518 for (h = 0; h < v * b; h++) {
519 if (M[h]) {
520 ost << h << " ";
521 }
522 }
523 ost << endl;
524 ost << "-1" << endl;
525 }
527
528 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
529
530 FREE_int(M);
531
532 //8 8 24
533 //0 1 2 8 11 12 16 21 22 25 27 29 33 36 39 42 44 46 50 53 55 59 62 63
534 //-1 1
535 //48
536
537
538
539 if (f_v) {
540 cout << "design_activity::do_export_inc done" << endl;
541 }
542}
543
545 design_create *DC,
546 int verbose_level)
547{
548 int f_v = (verbose_level >= 1);
549
550 if (f_v) {
551 cout << "design_activity::do_export_blocks" << endl;
552 }
553
554 string fname;
555
556 fname.assign(DC->label_txt);
557 fname.append("_blocks_coded.csv");
558
560
561 int v = DC->degree;
562 int k = DC->k;
563 int b = DC->sz;
564
565
567 Fio.lint_matrix_write_csv(fname, DC->set, 1, b);
568
569 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
570
571
572
573 fname.assign(DC->label_txt);
574 fname.append("_blocks.csv");
575
576 int *Blocks;
577
578
579 Combi.compute_blocks(v, b, k, DC->set, Blocks, verbose_level);
580
581 Fio.int_matrix_write_csv(fname, Blocks, b, k);
582
583 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
584
585
586 FREE_int(Blocks);
587
588
589 if (f_v) {
590 cout << "design_activity::do_export_blocks done" << endl;
591 }
592}
593
595 design_create *DC,
596 int verbose_level)
597{
598 int f_v = (verbose_level >= 1);
599
600 if (f_v) {
601 cout << "design_activity::do_row_sums" << endl;
602 }
603
604 string fname;
605
606 fname.assign(DC->label_txt);
607 fname.append("_inc.txt");
608
610
611 int v = DC->degree;
612 int k = DC->k;
613 int b = DC->sz;
614
615 //int N = k * b;
616 int *M;
617 int i, j;
618 int *R;
619
620 R = NEW_int(v);
621
622 Combi.compute_incidence_matrix(v, b, k, DC->set,
623 M, verbose_level);
624
625 for (i = 0; i < v; i++) {
626 R[i] = 0;
627 for (j = 0; j < b; j++) {
628 if (M[i * b + j]) {
629 R[i]++;
630 }
631 }
632 }
633
635
636 T.init(R, v, FALSE, 0);
637 cout << "distribution of row sums: ";
638 T.print(TRUE /* f_backwards */);
639 cout << endl;
640
641 FREE_int(M);
642 FREE_int(R);
643
644
645
646 if (f_v) {
647 cout << "design_activity::do_row_sums done" << endl;
648 }
649}
650
652 design_create *DC,
653 int verbose_level)
654{
655 int f_v = (verbose_level >= 1);
656
657 if (f_v) {
658 cout << "design_activity::do_tactical_decomposition" << endl;
659 }
660
661 string fname;
662
663 fname.assign(DC->label_txt);
664 fname.append("_inc.txt");
665
667
668 int v = DC->degree;
669 int k = DC->k;
670 int b = DC->sz;
671
672 //int N = k * b;
673 int *M;
674 //int i, j;
675 int *R;
676
677 R = NEW_int(v);
678
679 Combi.compute_incidence_matrix(v, b, k, DC->set,
680 M, verbose_level);
681
682 {
685
686
688
689 Inc->init_by_matrix(v, b, M, 0 /* verbose_level */);
690
692
693 Stack->allocate_with_two_classes(v + b, v, b, 0 /* verbose_level */);
694
695
696
697 while (TRUE) {
698
699 int ht0, ht1;
700
701 ht0 = Stack->ht;
702
703 if (f_v) {
704 cout << "process_single_case before refine_column_partition_safe" << endl;
705 }
706 Inc->refine_column_partition_safe(*Stack, verbose_level - 2);
707 if (f_v) {
708 cout << "process_single_case after refine_column_partition_safe" << endl;
709 }
710 if (f_v) {
711 cout << "process_single_case before refine_row_partition_safe" << endl;
712 }
713 Inc->refine_row_partition_safe(*Stack, verbose_level - 2);
714 if (f_v) {
715 cout << "process_single_case after refine_row_partition_safe" << endl;
716 }
717 ht1 = Stack->ht;
718 if (ht1 == ht0) {
719 break;
720 }
721 }
722
723 int f_labeled = TRUE;
724
725 Inc->print_partitioned(cout, *Stack, f_labeled);
727 Stack->print_classes(cout);
728
729
730 int f_print_subscripts = FALSE;
731 cout << "Decomposition:\\\\" << endl;
732 cout << "Row scheme:\\\\" << endl;
734 cout, TRUE /* f_enter_math */,
735 f_print_subscripts, *Stack);
736 cout << "Column scheme:\\\\" << endl;
738 cout, TRUE /* f_enter_math */,
739 f_print_subscripts, *Stack);
740
741 data_structures::set_of_sets *Row_classes;
742 data_structures::set_of_sets *Col_classes;
743
744 Stack->get_row_classes(Row_classes, verbose_level);
745 cout << "Row classes:\\\\" << endl;
746 Row_classes->print_table_tex(cout);
747
748
749 Stack->get_column_classes(Col_classes, verbose_level);
750 cout << "Col classes:\\\\" << endl;
751 Col_classes->print_table_tex(cout);
752
753 if (Row_classes->nb_sets > 1) {
754 cout << "The row partition splits" << endl;
755 }
756
757 if (Col_classes->nb_sets > 1) {
758 cout << "The col partition splits" << endl;
759 }
760
761
762 FREE_OBJECT(Inc);
763 FREE_OBJECT(Stack);
764 FREE_OBJECT(Row_classes);
765 FREE_OBJECT(Col_classes);
766 }
767
768 if (f_v) {
769 cout << "design_activity::do_tactical_decomposition" << endl;
770 }
771
772}
773
774}}}
775
776
777
778
description of a classification of objects using class classification_of_objects
classification of combinatorial objects using a graph-theoretic approach
void compute_blocks(int v, int b, int k, long int *Blocks_coded, int *&Blocks, int verbose_level)
void compute_incidence_matrix(int v, int b, int k, long int *Blocks_coded, int *&M, int verbose_level)
data structure for set partitions following Jeffrey Leon
void get_column_classes(set_of_sets *&Sos, int verbose_level)
void allocate_with_two_classes(int n, int v, int b, int verbose_level)
void get_row_classes(set_of_sets *&Sos, int verbose_level)
void init_from_orbiter_file(int underlying_set_size, std::string &fname, int verbose_level)
a statistical analysis of data consisting of single integers
void init(int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:72
interface for various incidence geometries
Definition: geometry.h:1099
void get_and_print_row_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math, int f_print_subscripts, data_structures::partitionstack &PStack)
int refine_row_partition_safe(data_structures::partitionstack &PStack, int verbose_level)
void get_and_print_decomposition_schemes(data_structures::partitionstack &PStack)
int refine_column_partition_safe(data_structures::partitionstack &PStack, int verbose_level)
void get_and_print_column_tactical_decomposition_scheme_tex(std::ostream &ost, int f_enter_math, int f_print_subscripts, data_structures::partitionstack &PStack)
void print_partitioned(std::ostream &ost, data_structures::partitionstack &P, int f_labeled)
void init_by_matrix(int m, int n, int *M, int verbose_level)
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
Definition: file_io.cpp:1300
void lint_matrix_write_csv(std::string &fname, long int *M, int m, int n)
Definition: file_io.cpp:1323
void int_matrix_read_csv(std::string &fname, int *&M, int &m, int &n, int verbose_level)
Definition: file_io.cpp:1477
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
void init_from_data_with_go(actions::action *A, std::string &generators_data, std::string &go_text, int verbose_level)
a wrapper for linear_group and permutation_group_create
void create_design_table(design_create *DC, std::string &problem_label, design_tables *&T, groups::strong_generators *Gens, int verbose_level)
void load_design_table(design_create *DC, std::string &problem_label, design_tables *&T, groups::strong_generators *Gens, int verbose_level)
combinatorics::classification_of_objects_description * Canonical_form_Descr
void do_export_blocks(design_create *DC, int verbose_level)
void do_tactical_decomposition(design_create *DC, int verbose_level)
void do_extract_solutions_by_index(design_create *DC, std::string &label, std::string &group_label, std::string &fname_in, std::string &fname_out, std::string &prefix_text, int f_csv_format, int verbose_level)
void do_canonical_form(combinatorics::classification_of_objects_description *Canonical_form_Descr, int verbose_level)
void do_create_table(design_create *DC, std::string &label, std::string &group_label, int verbose_level)
void do_load_table(design_create *DC, std::string &label, std::string &group_label, std::string &H_label, std::string &H_go_text, std::string &H_generators_data, int selected_orbit_length, int verbose_level)
void perform_activity(design_activity_description *Descr, design_create *DC, int verbose_level)
to create a known design using a description from class design_create_description
void extract_solutions_by_index(int nb_sol, int Index_width, int *Index, std::string &ouput_fname_csv, int verbose_level)
void init(design_create *DC, design_tables *T, int verbose_level)
classification of large sets of designs with assumed symmetry
void init(large_set_was_description *Descr, large_set_classify *LS, int verbose_level)
#define Int_vec_scan(A, B, C)
Definition: foundations.h:716
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects