Orbiter 2022
Combinatorial Objects
substructure_classifier.cpp
Go to the documentation of this file.
1/*
2 * substructure_classifier.cpp
3 *
4 * Created on: Jun 9, 2021
5 * Author: betten
6 */
7
8
9
10
12#include "discreta/discreta.h"
15
16using namespace std;
17
18namespace orbiter {
19namespace layer4_classification {
20
21
23{
24 //std::string &fname_base_out;
26 PC = NULL;
27 Control = NULL;
28 A = NULL;
29 A2 = NULL;
30 Poset = NULL;
31 nb_orbits = 0;
32}
33
34
36{
37
38}
39
40
42 std::string &fname_base_out,
46 int substructure_size,
47 int verbose_level)
48{
49 int f_v = (verbose_level >= 1);
50
51
52 if (f_v) {
53 cout << "substructure_classifier::classify_substructures, substructure_size=" << substructure_size << endl;
54 cout << "substructure_classifier::classify_substructures, fname_base_out=" << fname_base_out << endl;
55 cout << "substructure_classifier::classify_substructures, action A=";
56 A->print_info();
57 cout << endl;
58 cout << "substructure_classifier::classify_substructures, action A2=";
59 A2->print_info();
60 cout << endl;
61 cout << "substructure_classifier::classify_substructures generators:" << endl;
62 gens->print_generators_tex(cout);
63 }
64
69
71
72
74
77
78
79 if (f_v) {
80 cout << "substructure_classifier::classify_substructures control=" << endl;
81 Control->print();
82 }
83
84
86 gens,
87 verbose_level);
88
89 if (f_v) {
90 cout << "substructure_classifier::classify_substructures "
91 "before Poset->orbits_on_k_sets_compute" << endl;
92 }
94 Control,
96 verbose_level);
97 if (f_v) {
98 cout << "substructure_classifier::classify_substructures "
99 "after Poset->orbits_on_k_sets_compute" << endl;
100 }
101
103
104 cout << "We found " << nb_orbits << " orbits at level " << substructure_size << ":" << endl;
105
106 int j;
107
108 for (j = 0; j < nb_orbits; j++) {
109
110
111 groups::strong_generators *Strong_gens;
112
114 Strong_gens,
115 substructure_size, j, 0 /* verbose_level*/);
116
118
119 Strong_gens->group_order(go);
120
121 FREE_OBJECT(Strong_gens);
122
123 cout << j << " : " << go << endl;
124
125
126 }
127
128 if (f_v) {
129 cout << "substructure_classifier::classify_substructures done" << endl;
130 }
131
132
133
134}
135
136
137
140 groups::strong_generators *Strong_gens,
141 int intermediate_subset_size,
142 std::string &fname_mask, int nb, std::string &column_label,
143 std::string &fname_out,
144 int verbose_level)
145{
146 int f_v = (verbose_level >= 1);
147
148
149 if (f_v) {
150 cout << "substructure_classifier::set_stabilizer_in_any_space" << endl;
151 }
152
153 //substructure_classifier *SubC;
154
155 //SubC = NEW_OBJECT(substructure_classifier);
156
157 if (f_v) {
158 cout << "substructure_classifier::set_stabilizer_in_any_space "
159 "before SubC->classify_substructures" << endl;
160 }
161
164 A, A,
165 Strong_gens,
166 intermediate_subset_size, verbose_level - 5);
167
168 if (f_v) {
169 cout << "substructure_classifier::set_stabilizer_in_any_space "
170 "after SubC->classify_substructures" << endl;
171 cout << "substructure_classifier::set_stabilizer_in_any_space "
172 "We found " << nb_orbits << " orbits at level " << intermediate_subset_size << ":" << endl;
173 }
174
175
176
177
178
179 int nb_objects_to_test;
180 int cnt;
181 int row;
182
183 nb_objects_to_test = 0;
184
185
186 for (cnt = 0; cnt < nb; cnt++) {
187
188 char str[1000];
189 string fname;
190
191 sprintf(str, fname_mask.c_str(), cnt);
192 fname.assign(str);
193
195
196 S.read_spreadsheet(fname, 0 /*verbose_level*/);
197
198 nb_objects_to_test += S.nb_rows - 1;
199 if (f_v) {
200 cout << "substructure_classifier::set_stabilizer_in_any_space "
201 "file " << cnt << " / " << nb << " has "
202 << S.nb_rows - 1 << " objects" << endl;
203 }
204
205 }
206
207 if (f_v) {
208 cout << "substructure_classifier::set_stabilizer_in_any_space "
209 "nb_objects_to_test = " << nb_objects_to_test << endl;
210 }
211
212
213 int counter;
214
215 counter = 0;
216
217 for (cnt = 0; cnt < nb; cnt++) {
218
219 char str[1000];
220 string fname;
221
222 sprintf(str, fname_mask.c_str(), cnt);
223 fname.assign(str);
224
226
227 S.read_spreadsheet(fname, verbose_level);
228
229 if (f_v) {
230 cout << "substructure_classifier::set_stabilizer_in_any_space S.nb_rows = " << S.nb_rows << endl;
231 cout << "substructure_classifier::set_stabilizer_in_any_space S.nb_cols = " << S.nb_cols << endl;
232 }
233
234 int col_idx;
235
236 col_idx = S.find_column(column_label);
237
238
239 for (row = 0; row < S.nb_rows - 1; row++, counter++) {
240
241 int j, t;
242 string pts_txt;
243 long int *pts;
244 int nb_pts;
245 long int *canonical_pts;
246
247 if (f_v) {
248 cout << "#############################################################################" << endl;
249 cout << "cnt = " << cnt << " / " << nb << " row = " << row << " / " << S.nb_rows - 1 << endl;
250 }
251
252 j = col_idx;
253 t = S.Table[(row + 1) * S.nb_cols + j];
254 if (S.tokens[t] == NULL) {
255 cout << "substructure_classifier::set_stabilizer_in_any_space token[t] == NULL" << endl;
256 }
257 pts_txt.assign(S.tokens[t]);
258
260
261 ST.remove_specific_character(pts_txt, '\"');
262
263
264 Lint_vec_scan(pts_txt, pts, nb_pts);
265
266 canonical_pts = NEW_lint(nb_pts);
267
268 if (f_v) {
269 cout << "row = " << row;
270 cout << " pts=";
271 Lint_vec_print(cout, pts, nb_pts);
272 cout << endl;
273 }
274
275
276
277 std::string fname;
278 char str[1000];
279
280 sprintf(str, "_cnt%d", counter);
281 fname.assign(fname_out);
282 fname.append(str);
283
284
285 if (f_v) {
286 cout << "substructure_classifier::set_stabilizer_in_any_space "
287 "before set_stabilizer_of_set" << endl;
288 }
290 fname,
291 cnt, nb, row,
292 pts,
293 nb_pts,
294 canonical_pts,
295 verbose_level - 3);
296 if (f_v) {
297 cout << "substructure_classifier::set_stabilizer_in_any_space "
298 "after set_stabilizer_of_set" << endl;
299 }
300
301 FREE_lint(pts);
302 FREE_lint(canonical_pts);
303
304 } // row
305
306 }
307
308 //FREE_OBJECT(SubC);
309 if (f_v) {
310 cout << "substructure_classifier::set_stabilizer_in_any_space done" << endl;
311 }
312
313}
314
315
317 std::string &fname_out,
318 int cnt, int nb, int row,
319 long int *pts,
320 int nb_pts,
321 long int *canonical_pts,
322 int verbose_level)
323{
324 int f_v = (verbose_level >= 1);
325
326
327 if (f_v) {
328 cout << "substructure_classifier::set_stabilizer_of_set" << endl;
329 }
330
332
334
335 if (f_v) {
336 cout << "substructure_classifier::set_stabilizer_of_set before SubSt->init" << endl;
337 }
338 SubSt->init(
339 fname_out,
340 this,
341 pts,
342 nb_pts,
343 verbose_level - 2);
344 if (f_v) {
345 cout << "substructure_classifier::set_stabilizer_of_set after SubSt->init" << endl;
346 }
347 if (f_v) {
348 cout << "substructure_classifier::set_stabilizer_of_set" << endl;
349 cout << "stabilizer generators are:" << endl;
350 SubSt->gens->print_generators_tex(cout);
351 }
352
353
354
355
356 int *transporter_to_canonical_form;
357 groups::strong_generators *Gens_stabilizer_original_set;
358
359 if (f_v) {
360 cout << "substructure_classifier::set_stabilizer before handle_orbit" << endl;
361 }
362
363 transporter_to_canonical_form = NEW_int(A->elt_size_in_int);
364
366 SubSt,
367 canonical_pts,
368 transporter_to_canonical_form,
369 Gens_stabilizer_original_set,
370 verbose_level - 2);
371
372 if (f_v) {
373 cout << "substructure_classifier::set_stabilizer after handle_orbit" << endl;
374 cout << "canonical point set: ";
375 Lint_vec_print(cout, canonical_pts, nb_pts);
377
378 Gens_stabilizer_original_set->group_order(go);
379 cout << "_{" << go << "}" << endl;
380 cout << endl;
381 cout << "transporter to canonical form:" << endl;
382 A->element_print(transporter_to_canonical_form, cout);
383 cout << "Stabilizer of the original set:" << endl;
384 Gens_stabilizer_original_set->print_generators_tex();
385 }
386
387 groups::strong_generators *Gens_stabilizer_canonical_form;
388
389 Gens_stabilizer_canonical_form = NEW_OBJECT(groups::strong_generators);
390
391 if (f_v) {
392 cout << "substructure_classifier::set_stabilizer before init_generators_for_the_conjugate_group_avGa" << endl;
393 }
394 Gens_stabilizer_canonical_form->init_generators_for_the_conjugate_group_avGa(
395 Gens_stabilizer_original_set, transporter_to_canonical_form,
396 verbose_level - 2);
397 if (f_v) {
398 cout << "substructure_classifier::set_stabilizer after init_generators_for_the_conjugate_group_avGa" << endl;
399 }
400
401 if (f_v) {
402 cout << "substructure_classifier::set_stabilizer after handle_orbit" << endl;
403 cout << "canonical point set: ";
404 Lint_vec_print(cout, canonical_pts, nb_pts);
406
407 Gens_stabilizer_canonical_form->group_order(go);
408 cout << "_{" << go << "}" << endl;
409 cout << endl;
410 cout << "transporter to canonical form:" << endl;
411 A->element_print(transporter_to_canonical_form, cout);
412 cout << "Stabilizer of the canonical form:" << endl;
413 Gens_stabilizer_canonical_form->print_generators_tex();
414 }
415
416
417 FREE_OBJECT(SubSt);
418
419 FREE_int(transporter_to_canonical_form);
420 FREE_OBJECT(Gens_stabilizer_original_set);
421 FREE_OBJECT(Gens_stabilizer_canonical_form);
422
423 if (f_v) {
424 cout << "substructure_classifier::set_stabilizer_of_set done" << endl;
425 }
426
427}
428
431 long int *canonical_pts,
432 int *transporter_to_canonical_form,
433 groups::strong_generators *&Gens_stabilizer_original_set,
434 int verbose_level)
435{
436 int f_v = (verbose_level >= 1);
437
438
439 //overall_backtrack_nodes = 0;
440 if (f_v) {
441 cout << "substructure_classifier::handle_orbit calling compute_stabilizer_function" << endl;
442 }
443
445
447
448 if (f_v) {
449 cout << "substructure_classifier::handle_orbit before CS->init" << endl;
450 }
451 CS->init(SubSt,
452 //SubSt->Pts, SubSt->nb_pts,
453 canonical_pts,
454 //SubSt->SubC->PC, SubSt->SubC->A, SubSt->SubC->A2,
455 //SubSt->SubC->substructure_size, SubSt->selected_orbit,
456 //SubSt->nb_interesting_subsets, SubSt->interesting_subsets,
457 verbose_level);
458 if (f_v) {
459 cout << "substructure_classifier::handle_orbit after CS->init" << endl;
460 }
461
462
463 SubSt->SubC->A->element_move(CS->T1, transporter_to_canonical_form, 0);
464
465 Gens_stabilizer_original_set = NEW_OBJECT(groups::strong_generators);
466
467 Gens_stabilizer_original_set->init_from_sims(CS->Stab, verbose_level);
468
469 if (f_v) {
470 cout << "substructure_classifier::handle_orbit done with compute_stabilizer" << endl;
471 cout << "substructure_classifier::handle_orbit backtrack_nodes_first_time = " << CS->backtrack_nodes_first_time << endl;
472 cout << "substructure_classifier::handle_orbit backtrack_nodes_total_in_loop = " << CS->backtrack_nodes_total_in_loop << endl;
473 }
474
475
476 FREE_OBJECT(CS);
477
478 //overall_backtrack_nodes += CS->nodes;
479
480
481 if (f_v) {
482 cout << "substructure_classifier::handle_orbit done" << endl;
483 }
484}
485
486
487
488
489}}
490
void read_spreadsheet(std::string &fname, int verbose_level)
functions related to strings and character arrays
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
a permutation group in a fixed action.
Definition: actions.h:99
void element_print(void *elt, std::ostream &ost)
Definition: action_cb.cpp:347
void element_move(void *a, void *b, int verbose_level)
Definition: action_cb.cpp:335
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
void init_from_sims(groups::sims *S, int verbose_level)
void init_generators_for_the_conjugate_group_avGa(strong_generators *SG, int *Elt_a, int verbose_level)
void group_order(ring_theory::longinteger_object &go)
void init(substructure_stats_and_selection *SubSt, long int *canonical_pts, int verbose_level)
to control the behavior of the poset classification algorithm
void get_stabilizer_generators(groups::strong_generators *&gens, int level, int orbit_at_level, int verbose_level)
void init_subset_lattice(actions::action *A, actions::action *A2, groups::strong_generators *Strong_gens, int verbose_level)
poset_classification * orbits_on_k_sets_compute(poset_classification_control *Control, int k, int verbose_level)
void set_stabilizer_in_any_space(actions::action *A, actions::action *A2, groups::strong_generators *Strong_gens, int intermediate_subset_size, std::string &fname_mask, int nb, std::string &column_label, std::string &fname_out, int verbose_level)
void set_stabilizer_of_set(std::string &fname_out, int cnt, int nb, int row, long int *pts, int nb_pts, long int *canonical_pts, int verbose_level)
void classify_substructures(std::string &fname_base_out, actions::action *A, actions::action *A2, groups::strong_generators *gens, int substructure_size, int verbose_level)
poset_classification::poset_classification * PC
poset_classification::poset_classification_control * Control
poset_classification::poset_with_group_action * Poset
void handle_orbit(substructure_stats_and_selection *SubSt, long int *canonical_pts, int *transporter_to_canonical_form, groups::strong_generators *&Gens_stabilizer_original_set, int verbose_level)
void init(std::string &fname_case_out, substructure_classifier *SubC, long int *Pts, int nb_pts, int verbose_level)
#define FREE_int(p)
Definition: foundations.h:640
#define Lint_vec_scan(A, B, C)
Definition: foundations.h:717
#define NEW_OBJECT(type)
Definition: foundations.h:638
#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 TRUE
Definition: foundations.h:231
#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