Orbiter 2022
Combinatorial Objects
poset_classification_init.cpp
Go to the documentation of this file.
1// poset_classification_init.cpp
2//
3// Anton Betten
4// December 29, 2003
5//
6// moved here from poset_classification.cpp: July 29, 2014
7
8
10#include "discreta/discreta.h"
13
14using namespace std;
15
16namespace orbiter {
17namespace layer4_classification {
18namespace poset_classification {
19
20
22{
23 t0 = 0;
24
25 Control = NULL;
26
27 //problem_label[0] = 0;
28 //problem_label_with_path[0] = 0;
29
30 Elt_memory = NULL;
31
32 Poset = NULL;
33
34 f_base_case = FALSE;
35 Base_case = NULL;
36
37 depth = 0;
38
39 Schreier_vector_handler = NULL;
40 set_S = NULL;
41 sz = 0; // = depth
42 max_set_size = 0;
43
44 Elt_memory = NULL;
45 Elt1 = NULL;
46 Elt2 = NULL;
47 Elt3 = NULL;
48 Elt4 = NULL;
49 Elt5 = NULL;
50 Elt6 = NULL;
51
52
53 tmp_set_apply_fusion = NULL;
54 tmp_find_node_for_subspace_by_rank1 = NULL;
55 tmp_find_node_for_subspace_by_rank2 = NULL;
56
57
58
59 //nb_times_trace = 0;
60 //nb_times_trace_was_saved = 0;
61
62 transporter = NULL;
63 set = NULL;
64
65 Poo = NULL;
66
67
68 f_has_invariant_subset_for_root_node = FALSE;
69 invariant_subset_for_root_node = NULL;
70 invariant_subset_for_root_node_size = 0;
71
72
73
74
75
76 f_do_group_extension_in_upstep = TRUE;
77
78 f_allowed_to_show_group_elements = FALSE;
79 downstep_orbits_print_max_orbits = 25;
80 downstep_orbits_print_max_points_per_orbit = 50;
81
82 nb_times_image_of_called0 = 0;
83 nb_times_mult_called0 = 0;
84 nb_times_invert_called0 = 0;
85 nb_times_retrieve_called0 = 0;
86 nb_times_store_called0 = 0;
87
88 progress_last_time = 0.;
89 progress_epsilon = 0.;
90
91
92
94
95 t0 = Os.os_ticks();
96}
97
98poset_classification::~poset_classification()
99{
100 freeself();
101}
102
103void poset_classification::null()
104{
105}
106
107void poset_classification::freeself()
108{
109 int i;
110 int verbose_level = 1;
111 int f_v = (verbose_level >= 1);
112
113 if (f_v) {
114 cout << "poset_classification::freeself" << endl;
115 }
116 if (Elt_memory) {
117 FREE_int(Elt_memory);
118 }
119
120 // do not free Strong_gens
121
122
123 if (set_S) {
124 if (f_v) {
125 cout << "poset_classification::freeself deleting S" << endl;
126 }
127 FREE_lint(set_S);
128 }
129 if (Schreier_vector_handler) {
130 FREE_OBJECT(Schreier_vector_handler);
131 }
132 if (tmp_set_apply_fusion) {
133 FREE_lint(tmp_set_apply_fusion);
134 }
135 if (tmp_find_node_for_subspace_by_rank1) {
136 FREE_int(tmp_find_node_for_subspace_by_rank1);
137 }
138 if (tmp_find_node_for_subspace_by_rank2) {
139 FREE_int(tmp_find_node_for_subspace_by_rank2);
140 }
141
142 if (f_v) {
143 cout << "poset_classification::freeself "
144 "deleting transporter and set[]" << endl;
145 }
146 if (transporter) {
147 FREE_OBJECT(transporter);
148 for (i = 0; i <= sz; i++) {
149 FREE_lint(set[i]);
150 }
151 FREE_plint(set);
152 }
153
154 if (Poo) {
155 FREE_OBJECT(Poo);
156 }
157
158
159 if (f_v) {
160 cout << "poset_classification::freeself done" << endl;
161 }
162 null();
163}
164
165
166void poset_classification::init_internal(
169 int sz,
170 int verbose_level)
171{
172 int f_v = (verbose_level >= 1);
173 int f_vv = (verbose_level >= 2);
174 //int f_v6 = (verbose_level >= 6);
175 int i;
176
177 if (f_v) {
178 cout << "poset_classification::init_internal sz=" << sz << endl;
179 cout << "poset_classification::init_internal Control=" << endl;
180 Control->print();
181 }
182
183 Control = PC_control;
184 poset_classification::Poset = Poset;
185 poset_classification::sz = sz;
186
187 problem_label.assign(Control->problem_label);
188 problem_label_with_path.assign(Control->path);
189 problem_label_with_path.append(Control->problem_label);
190 //Control->init_labels(problem_label, problem_label_with_path);
191
192 if (f_v) {
193 cout << "poset_classification::init_internal, problem_label=" << problem_label << endl;
194 cout << "poset_classification::init_internal, problem_label_with_path=" << problem_label_with_path << endl;
195 }
196
197 if (Poset == NULL) {
198 cout << "poset_classification::init_internal "
199 "Poset == NULL" << endl;
200 exit(1);
201 }
202 if (Poset->A == NULL) {
203 cout << "poset_classification::init_internal "
204 "Poset->A == NULL" << endl;
205 exit(1);
206 }
207 if (Poset->A2 == NULL) {
208 cout << "poset_classification::init_internal "
209 "Poset->A2 == NULL" << endl;
210 exit(1);
211 }
212
213 max_set_size = Poset->A2->degree;
214 if (f_v) {
215 cout << "poset_classification::init_internal max_set_size=" << max_set_size << endl;
216 }
217
218 if (f_v) {
219 cout << "poset_classification::init_internal "
220 "sz = " << sz << endl;
221 cout << "poset_classification::init_internal "
222 "A->degree=" << Poset->A->degree << endl;
223 cout << "poset_classification::init_internal "
224 "A2->degree=" << Poset->A2->degree << endl;
225 }
226
227 if (Poset->Orbit_based_testing) {
228 Poset->Orbit_based_testing->PC = this;
229 }
230
232
233 t0 = Os.os_ticks();
234
235 progress_epsilon = 0.005;
236
237
238 if (f_vv) {
239 cout << "poset_classification::init_internal action A:" << endl;
240 Poset->A->print_info();
241 cout << "poset_classification::init_internal action A2:" << endl;
242 Poset->A2->print_info();
243 }
244
245
246 if (f_v) {
247 cout << "poset_classification::init_internal group order is ";
248 cout << Poset->go << endl;
249 }
250
252 Schreier_vector_handler->init(Poset->A, Poset->A2,
253 TRUE /* f_allow_failure */,
254 verbose_level);
255
256 if (f_v) {
257 cout << "poset_classification::init_internal sz = " << sz << endl;
258 }
259
260 if (f_vv) {
261 cout << "poset_classification::init_internal "
262 "allocating S of size " << sz << endl;
263 }
264 set_S = NEW_lint(sz);
265 for (i = 0; i < sz; i++) {
266 set_S[i] = i;
267 }
268
269 tmp_set_apply_fusion = NEW_lint(sz + 1);
270
271 if (f_vv) {
272 cout << "poset_classification::init_internal "
273 "allocating Elt_memory" << endl;
274 }
275
276
277 Elt_memory = NEW_int(6 * Poset->A->elt_size_in_int);
278 Elt1 = Elt_memory + 0 * Poset->A->elt_size_in_int;
279 Elt2 = Elt_memory + 1 * Poset->A->elt_size_in_int;
280 Elt3 = Elt_memory + 2 * Poset->A->elt_size_in_int;
281 Elt4 = Elt_memory + 3 * Poset->A->elt_size_in_int;
282 Elt5 = Elt_memory + 4 * Poset->A->elt_size_in_int;
283 Elt6 = Elt_memory + 5 * Poset->A->elt_size_in_int;
284
285
286 if (sz == 0) {
287 cout << "poset_classification::init_internal sz == 0" << endl;
288 exit(1);
289 }
291 transporter->init(Poset->A, verbose_level - 2);
292 transporter->allocate(sz + 1, verbose_level - 2);
293 Poset->A->element_one(transporter->ith(0), FALSE);
294
295 set = NEW_plint(sz + 1);
296 for (i = 0; i <= sz; i++) {
297 set[i] = NEW_lint(max_set_size);
298 }
299
300 int nb_poset_orbit_nodes = 1000;
301
303 if (f_vv) {
304 cout << "poset_classification::init_internal "
305 "before Poo->init" << endl;
306 }
307 Poo->init(this, nb_poset_orbit_nodes, sz, max_set_size, t0, verbose_level);
308 if (f_vv) {
309 cout << "poset_classification::init_internal "
310 "after Poo->init" << endl;
311 }
312
313 if (f_v) {
314 cout << "poset_classification::init_internal before Control->prepare" << endl;
315 }
316 Control->prepare(this, verbose_level);
317 if (f_v) {
318 cout << "poset_classification::init_internal after Control->prepare" << endl;
319 }
320
321 nb_times_image_of_called0 = Poset->A->ptr->nb_times_image_of_called;
322 nb_times_mult_called0 = Poset->A->ptr->nb_times_mult_called;
323 nb_times_invert_called0 = Poset->A->ptr->nb_times_invert_called;
324 nb_times_retrieve_called0 = Poset->A->ptr->nb_times_retrieve_called;
325 nb_times_store_called0 = Poset->A->ptr->nb_times_store_called;
326
327
328 if (Poset->f_subspace_lattice) {
329 tmp_find_node_for_subspace_by_rank1 = NEW_int(Poset->VS->dimension);
330 tmp_find_node_for_subspace_by_rank2 = NEW_int(sz * Poset->VS->dimension);
331 //tmp_find_node_for_subspace_by_rank3 =
332 // NEW_int(Poset->VS->dimension);
333 }
334
335 if (f_v) {
336 cout << "poset_classification::init_internal done" << endl;
337 }
338}
339
340void poset_classification::initialize_and_allocate_root_node(
343 int depth,
344 int verbose_level)
345{
346 int f_v = (verbose_level >= 1);
347 int f_vv = (verbose_level >= 2);
348
349 if (f_v) {
350 cout << "poset_classification::initialize_and_allocate_root_node" << endl;
351 cout << "poset_classification::initialize_and_allocate_root_node "
352 "depth = " << depth << endl;
353 }
354
355
356 poset_classification::depth = depth;
357 poset_classification::Control = PC_control;
358 downstep_orbits_print_max_orbits = 50;
359 downstep_orbits_print_max_points_per_orbit = INT_MAX;
360
361
362 // !!!
363 //f_allowed_to_show_group_elements = TRUE;
364
365 if (f_vv) {
366 cout << "poset_classification::initialize_and_allocate_root_node "
367 "before init_internal" << endl;
368 }
369 init_internal(PC_control,
370 Poset,
371 depth,
372 verbose_level - 2);
373 if (f_vv) {
374 cout << "poset_classification::initialize_and_allocate_root_node "
375 "after init_internal" << endl;
376 }
377
378 Poo->init_root_node(verbose_level - 1);
379
380
381 if (f_v) {
382 cout << "poset_classification::initialize_and_allocate_root_node done" << endl;
383 }
384}
385
386
387void poset_classification::initialize_with_base_case(
390 int depth,
391 classification_base_case *Base_case,
392 int verbose_level)
393{
394 int f_v = (verbose_level >= 1);
395 int f_vv = (verbose_level >= 2);
396
397 if (f_v) {
398 cout << "poset_classification::initialize_with_base_case" << endl;
399 }
400
401 Control = PC_control;
402
403 poset_classification::depth = depth;
404 downstep_orbits_print_max_orbits = 50;
405 downstep_orbits_print_max_points_per_orbit = INT_MAX;
406
407
408 // !!!
409 //f_allowed_to_show_group_elements = TRUE;
410
411 if (f_vv) {
412 cout << "poset_classification::initialize_with_base_case "
413 "before init_internal" << endl;
414 }
415 init_internal(PC_control, Poset,
416 depth, verbose_level - 2);
417 if (f_vv) {
418 cout << "poset_classification::initialize_with_base_case "
419 "after init_internal" << endl;
420 }
421
422
423 if (f_vv) {
424 cout << "poset_classification::initialize_with_base_case "
425 "calling init_starter" << endl;
426 }
427 init_base_case(Base_case, verbose_level);
428
429 Poo->init_root_node(verbose_level);
430
431 if (f_v) {
432 cout << "poset_classification::initialize_with_base_case done" << endl;
433 }
434}
435
436void poset_classification::init_root_node_invariant_subset(
437 int *invariant_subset, int invariant_subset_size,
438 int verbose_level)
439{
440 int f_v = (verbose_level >= 1);
441
442 if (f_v) {
443 cout << "poset_classification::init_root_node_"
444 "invariant_subset" << endl;
445 }
446 f_has_invariant_subset_for_root_node = TRUE;
447 invariant_subset_for_root_node = invariant_subset;
448 invariant_subset_for_root_node_size = invariant_subset_size;
449 if (f_v) {
450 cout << "poset_classification::init_root_node_"
451 "invariant_subset "
452 "installed invariant subset of size "
453 << invariant_subset_size << endl;
454 }
455}
456
457
458void poset_classification::init_base_case(classification_base_case *Base_case,
459 int verbose_level)
460// Does not initialize the first starter nodes.
461// This is done in init_root_node
462{
463 int f_v = (verbose_level >= 1);
464
465 if (f_v) {
466 cout << "poset_classification::init_base_case" << endl;
467 }
468 f_base_case = TRUE;
469 poset_classification::Base_case = Base_case;
470}
471
472
473}}}
474
475
void element_one(void *elt, int verbose_level)
Definition: action_cb.cpp:224
void init(actions::action *A, actions::action *A2, int f_allow_failure, int verbose_level)
void init(actions::action *A, int verbose_level)
Definition: vector_ge.cpp:55
represents a known classification with constructive recognition, to be used as base case for poset_cl...
to control the behavior of the poset classification algorithm
void init_internal(poset_classification_control *PC_control, poset_with_group_action *Poset, int sz, int verbose_level)
void init_base_case(classification_base_case *Base_case, int verbose_level)
the data structure for the poset of orbits in the poset classification algorithm
void init(poset_classification *PC, int nb_poset_orbit_nodes, int sz, int max_set_size, long int t0, int verbose_level)
#define NEW_plint(n)
Definition: foundations.h:629
#define FREE_int(p)
Definition: foundations.h:640
#define FREE_plint(p)
Definition: foundations.h:643
#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 FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
the orbiter library for the classification of combinatorial objects