Orbiter 2022
Combinatorial Objects
regular_ls_classify.cpp
Go to the documentation of this file.
1// regular_ls_classify.cpp
2//
3// Anton Betten
4// Jan 1, 2013
5
6#include "orbiter.h"
7
8using namespace std;
9
10namespace orbiter {
11namespace layer5_applications {
12namespace apps_combinatorics {
13
14
16{
17 Descr = NULL;
18
19 m2 = 0;
20 v1 = NULL; // [k]
21
22 Poset = NULL;
23 gen = NULL;
24 A = NULL;
25 A2 = NULL;
26 Aonk = NULL; // only a pointer, do not free
27
28 row_sum = NULL;
29 pairs = NULL;
30 open_rows = NULL;
31 open_row_idx = NULL;
32 open_pairs = NULL;
33 open_pair_idx = NULL;
34 //null();
35}
36
38{
39 freeself();
40}
41
43{
44}
45
46
48{
49 if (row_sum) {
51 }
52 if (pairs) {
54 }
55 if (open_rows) {
57 }
58 if (open_row_idx) {
60 }
61 if (open_pairs) {
63 }
64 if (open_pair_idx) {
66 }
67 null();
68}
69
70
71
74 int verbose_level)
75{
76 int f_v = (verbose_level >= 1);
77 //int f_vv = (verbose_level >= 2);
78
79 if (f_v) {
80 cout << "regular_ls_classify::init_and_run" << endl;
81 cout << "regular_ls_classify::init_and_run "
82 "m=" << Descr->m << " n=" << Descr->n << " k=" << Descr->k << " r=" << Descr->r << endl;
83 cout << "regular_ls_classify::init_basic starter_size=" << Descr->starter_size << endl;
84 }
85
87 if (!Descr->f_has_control) {
88 cout << "regular_ls_classify::init_and_run please use option -control" << endl;
89 exit(1);
90 }
91
92 m2 = (Descr->m * (Descr->m - 1)) >> 1;
93 v1 = NEW_int(Descr->m);
94
95
97 pairs = NEW_int(m2);
102
103 if (f_v) {
104 cout << "regular_ls_classify::init_and_run before init_group" << endl;
105 }
106 init_group(verbose_level);
107 if (f_v) {
108 cout << "regular_ls_classify::init_and_run after init_group" << endl;
109 }
110
111 if (f_v) {
112 cout << "regular_ls_classify::init_and_run before init_action_on_k_subsets" << endl;
113 }
114 init_action_on_k_subsets(Descr->k, verbose_level);
115 if (f_v) {
116 cout << "regular_ls_classify::init_and_run after init_action_on_k_subsets" << endl;
117 }
118
119 if (f_v) {
120 cout << "regular_ls_classify::init_and_run before init_generator" << endl;
121 }
123 Descr->Control,
124 A->Strong_gens,
125 verbose_level);
126 if (f_v) {
127 cout << "regular_ls_classify::init_and_run after init_generator" << endl;
128 }
129
130
132 int schreier_depth = Descr->target_size;
133 int f_use_invariant_subset_if_available = TRUE;
134 int f_debug = FALSE;
135 int t0 = Os.os_ticks();
136
137 if (f_v) {
138 cout << "regular_ls_classify::init_and_run "
139 "calling gen->main" << endl;
140 }
141 gen->main(t0,
142 schreier_depth,
143 f_use_invariant_subset_if_available,
144 f_debug,
145 verbose_level - 1);
146 if (f_v) {
147 cout << "regular_ls_classify::init_and_run "
148 "after gen->main" << endl;
149 }
150
151
152 if (f_v) {
153 cout << "regular_ls_classify::init_and_run done" << endl;
154 }
155}
156
157void regular_ls_classify::init_group(int verbose_level)
158{
159 int f_v = (verbose_level >= 1);
160
161 if (f_v) {
162 cout << "regular_ls_classify::init_group" << endl;
163 }
164
165 if (f_v) {
166 cout << "regular_ls_classify::init_group "
167 "creating symmetric group of degree " << Descr->m << endl;
168 }
170 int f_no_base = FALSE;
171
172 A->init_symmetric_group(Descr->m /* degree */, f_no_base, 0 /* verbose_level - 2*/);
173
174
175 if (f_v) {
176 cout << "regular_ls_generator::init_group done" << endl;
177 }
178}
179
181 int k, int verbose_level)
182{
183 int f_v = (verbose_level >= 1);
184
185 if (f_v) {
186 cout << "regular_ls_classify::init_action_on_k_subsets" << endl;
187 }
188
189 //regular_ls_generator::onk = onk;
190
191 if (f_v) {
192 cout << "regular_ls_classify::init_action_on_k_subsets "
193 "creating action on k-subsets for k=" << k << endl;
194 }
196 A2->induced_action_on_k_subsets(*A, k, verbose_level - 2);
197
199
200 if (f_v) {
201 cout << "regular_ls_classify::init_action_on_k_subsets "
202 "before A2->induced_action_override_sims" << endl;
203 }
204
205 if (f_v) {
206 cout << "regular_ls_classify::init_action_on_k_subsets "
207 "done" << endl;
208 }
209}
210
213 groups::strong_generators *Strong_gens,
214 int verbose_level)
215{
216 int f_v = (verbose_level >= 1);
217 //int i;
218
219 if (f_v) {
220 cout << "regular_ls_classify::init_generator" << endl;
221 }
222
223
224
225
228 Strong_gens,
229 verbose_level);
232 this /* void *data */,
233 verbose_level);
234
237 Poset->print_function_data = (void *) this;
238
239
241
243 Control, Poset,
244 Descr->target_size /* gen->depth ToDo */,
245 0/*verbose_level - 3*/);
246
247
248
249 if (f_v) {
250 cout << "regular_ls_classify::init_generator done" << endl;
251 }
252}
253
254
255void regular_ls_classify::early_test_func(long int *S, int len,
256 long int *candidates, int nb_candidates,
257 long int *good_candidates, int &nb_good_candidates,
258 int verbose_level)
259{
260 //verbose_level = 10;
261 int f_v = (verbose_level >= 1);
262 int f_vv = (verbose_level >= 2);
263 int i, j, a, b, p;
264 int f_OK;
266
267 if (f_v) {
268 cout << "regular_ls_classify::early_test_func checking set ";
269 Lint_vec_print(cout, S, len);
270 cout << endl;
271 cout << "candidate set of size " << nb_candidates << ":" << endl;
272 Lint_vec_print(cout, candidates, nb_candidates);
273 cout << endl;
274 }
277 //int_vec_copy(initial_pair_covering, pairs, m2);
278
279#if 0
280 if (f_vv) {
281 cout << "pairs initially:" << endl;
282 int_vec_print(cout, pairs, m2);
283 cout << endl;
284 }
285#endif
286
287 for (i = 0; i < len; i++) {
288
289 Combi.unrank_k_subset(S[i], v1, Descr->m, Descr->k);
290 for (a = 0; a < Descr->k; a++) {
291 row_sum[v1[a]]++;
292 for (b = a + 1; b < Descr->k; b++) {
293 p = Combi.ij2k(v1[a], v1[b], Descr->m);
294 pairs[p] = TRUE;
295 }
296 }
297
298 }
299 if (f_vv) {
300 cout << "pairs after adding in the chosen sets, pairs=" << endl;
301 Int_vec_print(cout, pairs, m2);
302 cout << endl;
303 }
304
305
306 nb_good_candidates = 0;
307
308 for (j = 0; j < nb_candidates; j++) {
309 f_OK = TRUE;
310
311 if (f_vv) {
312 cout << "Testing candidate " << j << " = "
313 << candidates[j] << endl;
314 }
315
316 // do candidate testing:
317
318 Combi.unrank_k_subset(candidates[j], v1, Descr->m, Descr->k);
319 if (f_vv) {
320 cout << "Testing candidate " << j << " = "
321 << candidates[j] << " = ";
322 Int_vec_print(cout, v1, Descr->k);
323 cout << endl;
324 }
325 for (a = 0; a < Descr->k; a++) {
326 if (row_sum[v1[a]] == Descr->r) {
327 f_OK = FALSE;
328 break;
329 }
330 for (b = a + 1; b < Descr->k; b++) {
331 p = Combi.ij2k(v1[a], v1[b], Descr->m);
332 if (pairs[p]) {
333 f_OK = FALSE;
334 break;
335 }
336 }
337 if (!f_OK) {
338 break;
339 }
340 }
341
342
343 if (f_OK) {
344 if (f_vv) {
345 cout << "Testing candidate " << j << " = "
346 << candidates[j] << " is good" << endl;
347 }
348 good_candidates[nb_good_candidates++] = candidates[j];
349 }
350 }
351}
352
353void regular_ls_classify::print(ostream &ost, long int *S, int len)
354{
355 int i;
356
357 for (i = 0; i < len; i++) {
358 ost << S[i] << " ";
359 }
360 ost << endl;
361}
362
364 exact_cover *E, int starter_case,
365 long int *candidates, int nb_candidates,
366 groups::strong_generators *Strong_gens,
367 solvers::diophant *&Dio, long int *&col_labels,
368 int &f_ruled_out,
369 int verbose_level)
370{
371 int f_v = (verbose_level >= 1);
372 int f_vv = (verbose_level >= 2);
373 int i, a, h1, h2, p, idx;
374 int nb_needed;
375 int nb_open_rows, nb_open_pairs;
377
378 if (f_v) {
379 cout << "regular_ls_classify::lifting_prepare_function_new "
380 "nb_candidates=" << nb_candidates << endl;
381 }
382
383 nb_needed = Descr->target_size - E->starter_size;
384 f_ruled_out = FALSE;
385
386
387 //int_vec_copy(initial_pair_covering, pairs, m2);
390
391#if 0
392 if (f_vv) {
393 cout << "pairs initially:" << endl;
394 int_vec_print(cout, pairs, m2);
395 cout << endl;
396 }
397#endif
398
399 for (i = 0; i < E->starter_size; i++) {
400
401 Combi.unrank_k_subset(E->starter[i], v1, Descr->m, Descr->k);
402 for (h1 = 0; h1 < Descr->k; h1++) {
403 row_sum[v1[h1]]++;
404 for (h2 = h1 + 1; h2 < Descr->k; h2++) {
405 p = Combi.ij2k(v1[h1], v1[h2], Descr->m);
406 pairs[p] = TRUE;
407 }
408 }
409 }
410
411 nb_open_rows = 0;
413 for (i = 0; i < Descr->m; i++) {
414 if (row_sum[i] < Descr->r) {
415 open_rows[nb_open_rows] = i;
416 open_row_idx[i] = nb_open_rows;
417 nb_open_rows++;
418 }
419 }
420
421 nb_open_pairs = 0;
423
424 for (i = 0; i < m2; i++) {
425 if (pairs[i] == FALSE) {
426 open_pairs[nb_open_pairs] = i;
427 open_pair_idx[i] = nb_open_pairs;
428 nb_open_pairs++;
429 }
430 }
431
432
433 col_labels = NEW_lint(nb_candidates);
434
435
436 Lint_vec_copy(candidates, col_labels, nb_candidates);
437
438 if (E->f_lex) {
439 E->lexorder_test(col_labels, nb_candidates, Strong_gens->gens,
440 verbose_level - 2);
441 }
442
443 if (f_vv) {
444 cout << "regular_ls_classify::lifting_prepare_function_new "
445 "after lexorder test" << endl;
446 cout << "regular_ls_classify::lifting_prepare_function_new "
447 "nb_candidates=" << nb_candidates << endl;
448 }
449
450 // compute the incidence matrix between
451 // open rows and open pairs versus candidate blocks:
452
453
454 int nb_rows;
455 int nb_cols;
456
457 nb_rows = nb_open_rows + nb_open_pairs;
458 nb_cols = nb_candidates;
459
461 Dio->open(nb_rows, nb_cols);
462 Dio->f_has_sum = TRUE;
463 Dio->sum = nb_needed;
464
465 for (i = 0; i < nb_open_rows; i++) {
466 Dio->type[i] = t_EQ;
467 Dio->RHS[i] = Descr->r - row_sum[open_rows[i]];
468 }
469
470 for (i = 0; i < nb_open_pairs; i++) {
471 Dio->type[nb_open_rows + i] = t_LE;
472 Dio->RHS[nb_open_rows + i] = 1;
473 }
474
476 Dio->set_x_min_constant(0);
477 Dio->set_x_max_constant(1);
478
479
480 for (i = 0; i < nb_candidates; i++) {
481 a = col_labels[i];
482
483
484 Combi.unrank_k_subset(a, v1, Descr->m, Descr->k);
485
486 for (h1 = 0; h1 < Descr->k; h1++) {
487
488 if (row_sum[v1[h1]] == Descr->r) {
489 cout << "regular_ls_classify::lifting_prepare_function_new "
490 "row_sum[v1[h1]] == Descr->r" << endl;
491 exit(1);
492 }
493 idx = open_row_idx[v1[h1]];
494 Dio->Aij(idx, i) = 1;
495
496 for (h2 = h1 + 1; h2 < Descr->k; h2++) {
497 p = Combi.ij2k(v1[h1], v1[h2], Descr->m);
498 if (pairs[p]) {
499 cout << "regular_ls_classify::lifting_prepare_function_new "
500 "pairs[p]" << endl;
501 exit(1);
502 }
503 idx = open_pair_idx[p];
504 Dio->Aij(nb_open_rows + idx, i) = 1;
505 }
506 }
507 }
508
509
510
511 if (f_v) {
512 cout << "regular_ls_classify::lifting_prepare_function_new "
513 "done" << endl;
514 }
515}
516
517
518
519
520
521// #############################################################################
522// global functions:
523// #############################################################################
524
525
526
527void regular_ls_classify_print_set(ostream &ost, int len, long int *S, void *data)
528{
530
531 //print_vector(ost, S, len);
532 Gen->print(ost, S, len);
533}
534
536 long int *candidates, int nb_candidates,
537 long int *good_candidates, int &nb_good_candidates,
538 void *data, int verbose_level)
539{
541 int f_v = (verbose_level >= 1);
542
543 if (f_v) {
544 cout << "regular_ls_classify_early_test_function for set ";
545 Lint_vec_print(cout, S, len);
546 cout << endl;
547 }
548 Gen->early_test_func(S, len,
549 candidates, nb_candidates,
550 good_candidates, nb_good_candidates,
551 verbose_level - 2);
552 if (f_v) {
553 cout << "regular_ls_classify_early_test_function done" << endl;
554 }
555}
556
558 exact_cover *EC, int starter_case,
559 long int *candidates, int nb_candidates,
560 groups::strong_generators *Strong_gens,
561 solvers::diophant *&Dio, long int *&col_labels,
562 int &f_ruled_out,
563 int verbose_level)
564{
565 int f_v = (verbose_level >= 1);
567
568 if (f_v) {
569 cout << "regular_ls_classify_lifting_prepare_function_new "
570 "nb_candidates=" << nb_candidates << endl;
571 }
572
573 Gen->lifting_prepare_function_new(EC, starter_case,
574 candidates, nb_candidates, Strong_gens,
575 Dio, col_labels, f_ruled_out,
576 verbose_level - 1);
577
578
579 if (f_v) {
580 cout << "regular_ls_classify_lifting_prepare_function_new "
581 "nb_rows=" << Dio->m << " nb_cols=" << Dio->n << endl;
582 }
583
584 if (f_v) {
585 cout << "regular_ls_classify_lifting_prepare_function_new "
586 "done" << endl;
587 }
588}
589
590}}}
591
592
diophantine systems of equations (i.e., linear systems over the integers)
Definition: solvers.h:209
a permutation group in a fixed action.
Definition: actions.h:99
void init_symmetric_group(int degree, int f_no_base, int verbose_level)
groups::strong_generators * Strong_gens
Definition: actions.h:130
void induced_action_on_k_subsets(action &old_action, int k, int verbose_level)
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
data_structures_groups::vector_ge * gens
Definition: groups.h:1708
exact cover problems arising with the lifting of combinatorial objects
Definition: solver.h:27
void lexorder_test(long int *live_blocks2, int &nb_live_blocks2, data_structures_groups::vector_ge *stab_gens, int verbose_level)
to control the behavior of the poset classification algorithm
void initialize_and_allocate_root_node(poset_classification_control *PC_control, poset_with_group_action *Poset, int 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 init_subset_lattice(actions::action *A, actions::action *A2, groups::strong_generators *Strong_gens, int verbose_level)
void add_testing_without_group(void(*func)(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level), void *data, int verbose_level)
void(* print_function)(std::ostream &ost, int len, long int *S, void *data)
a description of a class of regular linear spaces from the command line
void early_test_func(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, int verbose_level)
void init_generator(poset_classification::poset_classification_control *Control, groups::strong_generators *Strong_gens, int verbose_level)
void lifting_prepare_function_new(exact_cover *E, int starter_case, long int *candidates, int nb_candidates, groups::strong_generators *Strong_gens, solvers::diophant *&Dio, long int *&col_labels, int &f_ruled_out, int verbose_level)
void init_and_run(regular_linear_space_description *Descr, int verbose_level)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define NEW_lint(n)
Definition: foundations.h:628
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
void regular_ls_classify_early_test_function(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level)
void regular_ls_classify_print_set(ostream &ost, int len, long int *S, void *data)
void regular_ls_classify_lifting_prepare_function_new(exact_cover *EC, int starter_case, long int *candidates, int nb_candidates, groups::strong_generators *Strong_gens, solvers::diophant *&Dio, long int *&col_labels, int &f_ruled_out, int verbose_level)
the orbiter library for the classification of combinatorial objects
induced_actions::action_on_k_subsets * on_k_subsets