Orbiter 2022
Combinatorial Objects
spread_lifting.cpp
Go to the documentation of this file.
1// spread_lifting.cpp
2//
3// Anton Betten
4// April 1, 2018
5//
6//
7//
8
9#include "orbiter.h"
10
11using namespace std;
12
13namespace orbiter {
14namespace layer5_applications {
15namespace spreads {
16
17
19{
20 null();
21}
22
24{
25 freeself();
26}
27
29{
30 S = NULL;
31 E = NULL;
32 starter = NULL;
34 free_point_list = NULL;
35 point_idx = NULL;
36 col_labels = NULL;
37
38}
39
41{
44 }
45 if (free_point_list) {
47 }
48 if (point_idx) {
50 }
51 if (col_labels) {
53 }
54 null();
55}
56
59 long int *starter, int starter_size,
60 int starter_case_number, int starter_number_of_cases,
61 long int *candidates, int nb_candidates,
62 groups::strong_generators *Strong_gens,
63 int f_lex,
64 int verbose_level)
65{
66 int f_v = (verbose_level >= 1);
67 //int f_vv = (verbose_level >= 2);
69
70
71 if (f_v) {
72 cout << "spread_lifting::init" << endl;
73 }
84
85 if (f_v) {
86 cout << "spread_lifting::init "
87 "before compute_points_covered_by_starter" << endl;
88 }
89 compute_points_covered_by_starter(verbose_level - 2);
90 if (f_v) {
91 cout << "spread_lifting::init "
92 "after compute_points_covered_by_starter" << endl;
93 }
94
95 if (f_v) {
96 cout << "spread_lifting::init "
97 "before prepare_free_points" << endl;
98 }
99 prepare_free_points(verbose_level - 2);
100 if (f_v) {
101 cout << "spread_lifting::init "
102 "after prepare_free_points" << endl;
103 }
104
106 if (f_v) {
107 cout << "spread_lifting::init "
108 "nb_needed=" << nb_needed << endl;
109 cout << "spread_lifting::init "
110 "nb_candidates=" << nb_candidates << endl;
111 }
112
113
117
118
119 if (f_lex) {
120 int nb_cols_before;
121
122 nb_cols_before = nb_cols;
124 verbose_level - 2);
125 if (f_v) {
126 cout << "spread_lifting::init after lexorder test "
127 "nb_candidates before: " << nb_cols_before
128 << " reduced to " << nb_cols << " (deleted "
129 << nb_cols_before - nb_cols << ")" << endl;
130 }
131 }
132
133 if (f_v) {
134 cout << "spread_lifting::init after lexorder test" << endl;
135 cout << "spread_lifting::init nb_cols=" << nb_cols << endl;
136 }
137
138 if (f_v) {
139 cout << "spread_lifting::init done" << endl;
140 }
141}
142
144 int verbose_level)
145{
146 int f_v = (verbose_level >= 1);
147 int f_vv = (verbose_level >= 2);
148 int f_v3 = (verbose_level >= 3);
149 int i, a;
151
152 if (f_v) {
153 cout << "spread_lifting::compute_points_"
154 "covered_by_starter" << endl;
155 }
158
159 for (i = 0; i < starter_size; i++) {
160 long int *point_list;
161 int nb_points;
162
163 a = starter[i];
164 S->Grass->unrank_lint(a, 0/*verbose_level - 4*/);
166 S->Grass->M, S->k, S->n, point_list,
167 nb_points, 0 /*verbose_level - 2*/);
168
169 if (nb_points != S->block_size) {
170 cout << "spread_lifting::compute_points_"
171 "covered_by_starter nb_points != S->block_size" << endl;
172 exit(1);
173 }
174
175 Lint_vec_copy(point_list,
177 S->block_size);
178
179 if (f_v3) {
180 cout << "starter element " << i << " / "
181 << starter_size << " is " << a << ":" << endl;
182 Int_matrix_print(S->Grass->M, S->k, S->n);
183 //cout << endl;
184 cout << "points_covered_by_starter: " << endl;
185 Lint_vec_print(cout,
187 i * S->block_size, S->block_size);
188 cout << endl;
189 }
190
191 FREE_lint(point_list);
192 }
195 if (f_vv) {
196 cout << "spread_lifting::compute_points_"
197 "covered_by_starter covered points computed:" << endl;
198 cout << "spread_lifting::compute_points_"
199 "covered_by_starter nb_points_covered_by_starter="
203 cout << endl;
204 }
205
206 if (f_v) {
207 cout << "spread_lifting::compute_points_"
208 "covered_by_starter done" << endl;
209 }
210}
211
213 int verbose_level)
214{
215 int f_v = (verbose_level >= 1);
216 int f_vv = (verbose_level >= 2);
217 int f_v3 = (verbose_level >= 3);
218 int i, j, idx;
220
221 if (f_v) {
222 cout << "spread_lifting::prepare_free_points" << endl;
223 }
224
226 if (f_vv) {
227 cout << "spread_lifting::prepare_free_points "
228 "nb_free_points=" << nb_free_points << endl;
229 }
232 j = 0;
233 for (i = 0; i < S->nb_points_total; i++) {
235 nb_points_covered_by_starter, i, idx, 0)) {
236 point_idx[i] = -1;
237 }
238 else {
239 free_point_list[j] = i;
240 point_idx[i] = j;
241 j++;
242 }
243 }
244 if (j != nb_free_points) {
245 cout << "spread_lifting::prepare_free_points "
246 "j != nb_free_points" << endl;
247 exit(1);
248 }
249 if (f_vv) {
250 cout << "spread_lifting::prepare_free_points "
251 "computed free points" << endl;
252 }
253
254 if (f_v3) {
255 cout << "spread_lifting::prepare_free_points "
256 "The " << nb_free_points << " free points:" << endl;
257 Lint_vec_print(cout,
259 cout << endl;
261 }
262 if (f_v) {
263 cout << "spread_lifting::prepare_free_points done" << endl;
264 }
265}
266
268{
269 int f_v = (verbose_level >= 1);
270 int f_vv = (verbose_level >= 2);
271 int f_v5 = (verbose_level >= 5);
273 int nb_rows = nb_free_points;
274 int i, j, a, b, h;
275
276 if (f_v) {
277 cout << "spread_lifting::create_system" << endl;
278 }
279
281 Dio->open(nb_rows, nb_cols);
282 Dio->f_has_sum = TRUE;
283 Dio->sum = nb_needed;
284
285 for (i = 0; i < nb_rows; i++) {
286 Dio->type[i] = t_EQ;
287 Dio->RHS[i] = 1;
288 }
289
291 if (f_vv) {
292 cout << "spread_lifting::create_system "
293 "nb_rows = " << nb_rows << endl;
294 cout << "spread_lifting::create_system "
295 "nb_cols = " << nb_cols << endl;
296 }
297 for (j = 0; j < nb_cols; j++) {
298
299 long int *point_list;
300 int nb_points;
301
302 a = col_labels[j];
303 S->Grass->unrank_lint(a, 0/*verbose_level - 4*/);
304 if (f_vv) {
305 cout << "candidate " << j << " / "
306 << nb_cols << " is " << a << endl;
307 }
308
309 if (f_v5) {
310 cout << "Which is " << endl;
311 Int_matrix_print(S->Grass->M, S->k, S->n);
312 }
314 S->Grass->M, S->k, S->n, point_list, nb_points,
315 0 /*verbose_level*/);
316 if (nb_points != S->block_size) {
317 cout << "spread_lifting::create_system "
318 "nb_points != S->block_size" << endl;
319 exit(1);
320 }
321 if (FALSE /*f_vv*/) {
322 cout << "List of points: ";
323 Lint_vec_print(cout, point_list, nb_points);
324 cout << endl;
325 }
326
327
328
329
330 for (h = 0; h < S->block_size; h++) {
331 b = point_list[h];
332 i = point_idx[b];
333 if (i == -1) {
334 cout << "spread_lifting::create_system "
335 "candidate block contains point that "
336 "is already covered" << endl;
337 exit(1);
338 }
339 if (i < 0 || i >= nb_free_points) {
340 cout << "spread_lifting::create_system "
341 "i < 0 || i >= nb_free_points" << endl;
342 exit(1);
343 }
344 Dio->Aij(i, j) = 1;
345 }
346 FREE_lint(point_list);
347 }
348
349 if (FALSE) {
350 cout << "spread_lifting::create_system "
351 "coefficient matrix" << endl;
352 for (i = 0; i < nb_rows; i++) {
353 for (j = 0; j < nb_cols; j++) {
354 cout << Dio->Aij(i, j);
355 }
356 cout << endl;
357 }
358 }
359 if (f_v) {
360 cout << "spread_lifting::create_system done" << endl;
361 }
362 return Dio;
363}
364
366 int *&col_color, int &nb_colors,
367 int verbose_level)
368{
369 int f_v = (verbose_level >= 1);
370 int *colors;
371 int i, j, a, c;
372 int *v;
373
374 if (f_v) {
375 cout << "spread_lifting::find_coloring" << endl;
376 }
377 v = NEW_int(S->n);
378 colors = NEW_int(nb_free_points);
379 nb_colors = 0;
380 for (i = 0; i < nb_free_points; i++) {
381 a = free_point_list[i];
382 S->unrank_point(v, a);
384 v, 1, S->n);
385 if (v[0] != 1) {
386 continue;
387 }
388 for (j = 1; j < S->k; j++) {
389 if (v[j] != 0) {
390 break;
391 }
392 }
393 if (j < S->k) {
394 continue;
395 }
396 if (f_v) {
397 cout << "found color " << nb_colors
398 << " : " << i << " = " << a << " = ";
399 Int_vec_print(cout, v, S->n);
400 cout << endl;
401 }
402 colors[nb_colors++] = i;
403 }
404 if (f_v) {
405 cout << "spread_lifting::find_coloring "
406 "we found " << nb_colors << " colors" << endl;
407 }
408 if (nb_colors != nb_needed) {
409 cout << "spread_lifting::find_coloring "
410 "nb_colors != nb_needed" << endl;
411 exit(1);
412 }
413
414 col_color = NEW_int(nb_cols);
415 for (j = 0; j < nb_cols; j++) {
416 for (c = 0; c < nb_colors; c++) {
417 i = colors[c];
418 if (Dio->Aij(i, j)) {
419 col_color[j] = c;
420 break;
421 }
422 }
423 if (c == nb_colors) {
424 cout << "spread_lifting::find_coloring "
425 "c == nb_colors" << endl;
426 exit(1);
427 }
428 }
429 FREE_int(colors);
430 FREE_int(v);
431 if (f_v) {
432 cout << "spread_lifting::find_coloring done" << endl;
433 }
434}
435
436}}}
437
a collection of functions related to sorted vectors
int lint_vec_search(long int *v, int len, long int a, int &idx, int verbose_level)
Definition: sorting.cpp:1157
void all_PG_elements_in_subspace(int *genma, int k, int n, long int *&point_list, int &nb_points, int verbose_level)
void unrank_lint(long int rk, int verbose_level)
Definition: grassmann.cpp:343
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
diophantine systems of equations (i.e., linear systems over the integers)
Definition: solvers.h:209
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 classify spreads of PG(k-1,q) in PG(n-1,q) where k divides n
Definition: spreads.h:106
solvers::diophant * create_system(int verbose_level)
void find_coloring(solvers::diophant *Dio, int *&col_color, int &nb_colors, int verbose_level)
void init(spread_classify *S, exact_cover *E, long int *starter, int starter_size, int starter_case_number, int starter_number_of_cases, long int *candidates, int nb_candidates, groups::strong_generators *Strong_gens, int f_lex, int verbose_level)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define FREE_int(p)
Definition: foundations.h:640
#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 Int_matrix_print(A, B, C)
Definition: foundations.h:707
#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
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects