aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-08 17:38:42 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-08 17:38:42 +0100
commita0b89016dc7ea42fe8af0aeb956fd383cd1b66f1 (patch)
tree27dc3f3ff760f4b1339e9ebd5e5612caf3cd1c08
parent131428b913a3d42f26714b8e5e873d8112db10c0 (diff)
downloadnissy-a0b89016dc7ea42fe8af0aeb956fd383cd1b66f1.tar.gz
nissy-a0b89016dc7ea42fe8af0aeb956fd383cd1b66f1.zip
Faster and nice pruning table generation. Can still be improved with multithreading.
Diffstat (limited to '')
-rwxr-xr-xnissybin165128 -> 169136 bytes
-rw-r--r--src/coord.c13
-rw-r--r--src/cubetypes.h4
-rw-r--r--src/pruning.c16
-rw-r--r--src/symcoord.c115
5 files changed, 110 insertions, 38 deletions
diff --git a/nissy b/nissy
index f559b2e..4970885 100755
--- a/nissy
+++ b/nissy
Binary files differ
diff --git a/src/coord.c b/src/coord.c
index 3d5e785..c9a28c4 100644
--- a/src/coord.c
+++ b/src/coord.c
@@ -49,7 +49,6 @@ coord_eofb = {
49 .index = index_eofb, 49 .index = index_eofb,
50 .cube = antindex_eofb, 50 .cube = antindex_eofb,
51 .max = POW2TO11, 51 .max = POW2TO11,
52 .ntrans = 1,
53}; 52};
54 53
55Coordinate 54Coordinate
@@ -57,7 +56,6 @@ coord_eofbepos = {
57 .index = index_eofbepos, 56 .index = index_eofbepos,
58 .cube = antindex_eofbepos, 57 .cube = antindex_eofbepos,
59 .max = POW2TO11 * BINOM12ON4, 58 .max = POW2TO11 * BINOM12ON4,
60 .ntrans = 1,
61}; 59};
62 60
63Coordinate 61Coordinate
@@ -65,7 +63,6 @@ coord_coud = {
65 .index = index_coud, 63 .index = index_coud,
66 .cube = antindex_coud, 64 .cube = antindex_coud,
67 .max = POW3TO7, 65 .max = POW3TO7,
68 .ntrans = 1,
69}; 66};
70 67
71Coordinate 68Coordinate
@@ -73,7 +70,6 @@ coord_corners = {
73 .index = index_corners, 70 .index = index_corners,
74 .cube = antindex_corners, 71 .cube = antindex_corners,
75 .max = POW3TO7 * FACTORIAL8, 72 .max = POW3TO7 * FACTORIAL8,
76 .ntrans = 1,
77}; 73};
78 74
79Coordinate 75Coordinate
@@ -81,7 +77,6 @@ coord_cp = {
81 .index = index_cp, 77 .index = index_cp,
82 .cube = antindex_cp, 78 .cube = antindex_cp,
83 .max = FACTORIAL8, 79 .max = FACTORIAL8,
84 .ntrans = 1,
85}; 80};
86 81
87Coordinate 82Coordinate
@@ -89,7 +84,6 @@ coord_cphtr = {
89 .index = index_cphtr, 84 .index = index_cphtr,
90 .cube = antindex_cphtr, 85 .cube = antindex_cphtr,
91 .max = BINOM8ON4 * 6, 86 .max = BINOM8ON4 * 6,
92 .ntrans = 1,
93}; 87};
94 88
95Coordinate 89Coordinate
@@ -97,7 +91,6 @@ coord_cornershtr = {
97 .index = index_cornershtr, 91 .index = index_cornershtr,
98 .cube = antindex_cornershtr, 92 .cube = antindex_cornershtr,
99 .max = POW3TO7 * BINOM8ON4 * 6, 93 .max = POW3TO7 * BINOM8ON4 * 6,
100 .ntrans = 1,
101}; 94};
102 95
103Coordinate 96Coordinate
@@ -105,7 +98,6 @@ coord_cornershtrfin = {
105 .index = index_cornershtrfin, 98 .index = index_cornershtrfin,
106 .cube = antindex_cornershtrfin, 99 .cube = antindex_cornershtrfin,
107 .max = 24*24/6, 100 .max = 24*24/6,
108 .ntrans = 1,
109}; 101};
110 102
111Coordinate 103Coordinate
@@ -113,7 +105,6 @@ coord_epud = {
113 .index = index_epud, 105 .index = index_epud,
114 .cube = antindex_epud, 106 .cube = antindex_epud,
115 .max = FACTORIAL8, 107 .max = FACTORIAL8,
116 .ntrans = 1,
117}; 108};
118 109
119Coordinate 110Coordinate
@@ -121,7 +112,6 @@ coord_drud = {
121 .index = index_drud, 112 .index = index_drud,
122 .cube = antindex_drud, 113 .cube = antindex_drud,
123 .max = POW2TO11 * POW3TO7 * BINOM12ON4, 114 .max = POW2TO11 * POW3TO7 * BINOM12ON4,
124 .ntrans = 1,
125}; 115};
126 116
127Coordinate 117Coordinate
@@ -129,7 +119,6 @@ coord_htr_drud = {
129 .index = index_htr_drud, 119 .index = index_htr_drud,
130 .cube = antindex_htr_drud, 120 .cube = antindex_htr_drud,
131 .max = BINOM8ON4 * 6 * BINOM8ON4, 121 .max = BINOM8ON4 * 6 * BINOM8ON4,
132 .ntrans = 1,
133}; 122};
134 123
135Coordinate 124Coordinate
@@ -137,7 +126,6 @@ coord_htrfin = {
137 .index = index_htrfin, 126 .index = index_htrfin,
138 .cube = antindex_htrfin, 127 .cube = antindex_htrfin,
139 .max = 24 * 24 * 24 *24 * 24 / 6, /* should be /12 but it's ok */ 128 .max = 24 * 24 * 24 *24 * 24 / 6, /* should be /12 but it's ok */
140 .ntrans = 1,
141}; 129};
142 130
143Coordinate 131Coordinate
@@ -145,7 +133,6 @@ coord_drud_eofb = {
145 .index = index_drud_eofb, 133 .index = index_drud_eofb,
146 .cube = antindex_drud_eofb, 134 .cube = antindex_drud_eofb,
147 .max = POW3TO7 * BINOM12ON4, 135 .max = POW3TO7 * BINOM12ON4,
148 .ntrans = 1,
149}; 136};
150 137
151/* Antindexers ***************************************************************/ 138/* Antindexers ***************************************************************/
diff --git a/src/cubetypes.h b/src/cubetypes.h
index 3f350af..27666be 100644
--- a/src/cubetypes.h
+++ b/src/cubetypes.h
@@ -100,6 +100,7 @@ typedef uint64_t (*Indexer) (Cube);
100typedef bool (*Moveset) (Move); 100typedef bool (*Moveset) (Move);
101typedef CommandArgs * (*ArgParser) (int, char **); 101typedef CommandArgs * (*ArgParser) (int, char **);
102typedef Trans (*TransDetector) (Cube); 102typedef Trans (*TransDetector) (Cube);
103typedef int (*TransFinder) (uint64_t ind, Trans *);
103 104
104 105
105/* Structs *******************************************************************/ 106/* Structs *******************************************************************/
@@ -162,8 +163,7 @@ coordinate
162 Indexer index; 163 Indexer index;
163 AntiIndexer cube; 164 AntiIndexer cube;
164 uint64_t max; 165 uint64_t max;
165 int ntrans; 166 TransFinder trans;
166 Trans * trans;
167}; 167};
168 168
169struct 169struct
diff --git a/src/pruning.c b/src/pruning.c
index 716379e..6ea77e3 100644
--- a/src/pruning.c
+++ b/src/pruning.c
@@ -144,20 +144,20 @@ genptable(PruneData *pd)
144static void 144static void
145genptable_bfs(PruneData *pd, int d, Move *ms) 145genptable_bfs(PruneData *pd, int d, Move *ms)
146{ 146{
147 int j; 147 int j, n;
148 uint64_t i; 148 uint64_t i;
149 Cube c, cc; 149 Cube c, cc;
150 Trans t[NTRANS];
150 151
151 for (i = 0; i < pd->coord->max; i++) { 152 for (i = 0; i < pd->coord->max; i++) {
152 /*
153 * TODO: only do this if the position is "nasty",
154 * i.e. self-symmetrical with respect to the base
155 * coordinate but not overall.
156 */
157 if (ptableval_index(pd, i) == d) { 153 if (ptableval_index(pd, i) == d) {
154 n = pd->coord->trans(i, t);
155 if (n == 1)
156 continue;
157
158 c = pd->coord->cube(i); 158 c = pd->coord->cube(i);
159 for (j = 0; j < pd->coord->ntrans; j++) { 159 for (j = 0; j < n; j++) {
160 cc = apply_trans(pd->coord->trans[j], c); 160 cc = apply_trans(t[j], c);
161 if (ptableval(pd, cc) > d) 161 if (ptableval(pd, cc) > d)
162 ptable_update(pd, cc, d); 162 ptable_update(pd, cc, d);
163 } 163 }
diff --git a/src/symcoord.c b/src/symcoord.c
index 798a946..038449a 100644
--- a/src/symcoord.c
+++ b/src/symcoord.c
@@ -1,5 +1,9 @@
1#include "symcoord.h" 1#include "symcoord.h"
2 2
3/* These constants have been computed generating the respective SymData */
4#define CLASSES_CP_16 2768
5#define CLASSES_EOFBEPOS_16 64430
6
3static Cube antindex_coud_sym16(uint64_t ind); 7static Cube antindex_coud_sym16(uint64_t ind);
4static Cube antindex_cp_sym16(uint64_t ind); 8static Cube antindex_cp_sym16(uint64_t ind);
5static Cube antindex_eofbepos_sym16(uint64_t ind); 9static Cube antindex_eofbepos_sym16(uint64_t ind);
@@ -14,8 +18,13 @@ static uint64_t index_drud_sym16(Cube cube);
14static uint64_t index_drudfin_noE_sym16(Cube cube); 18static uint64_t index_drudfin_noE_sym16(Cube cube);
15static uint64_t index_khuge(Cube cube); 19static uint64_t index_khuge(Cube cube);
16 20
21static int transfinder_drud_sym16(uint64_t ind, Trans *ret);
22static int transfinder_drudfin_noE_sym16(uint64_t ind, Trans *ret);
23static int transfinder_khuge(uint64_t ind, Trans *ret);
24
17static void gensym(SymData *sd); 25static void gensym(SymData *sd);
18static bool read_symdata_file(SymData *sd); 26static bool read_symdata_file(SymData *sd);
27static int selfsims(SymData *sd, uint64_t ind, Trans *ret);
19static bool write_symdata_file(SymData *sd); 28static bool write_symdata_file(SymData *sd);
20 29
21/* Transformation groups and symmetry data ***********************************/ 30/* Transformation groups and symmetry data ***********************************/
@@ -69,51 +78,42 @@ Coordinate
69coord_eofbepos_sym16 = { 78coord_eofbepos_sym16 = {
70 .index = index_eofbepos_sym16, 79 .index = index_eofbepos_sym16,
71 .cube = antindex_eofbepos_sym16, 80 .cube = antindex_eofbepos_sym16,
72 .ntrans = 16,
73 .trans = trans_group_udfix,
74}; 81};
75 82
76Coordinate 83Coordinate
77coord_coud_sym16 = { 84coord_coud_sym16 = {
78 .index = index_coud_sym16, 85 .index = index_coud_sym16,
79 .cube = antindex_coud_sym16, 86 .cube = antindex_coud_sym16,
80 .ntrans = 16,
81 .trans = trans_group_udfix,
82}; 87};
83 88
84Coordinate 89Coordinate
85coord_cp_sym16 = { 90coord_cp_sym16 = {
86 .index = index_cp_sym16, 91 .index = index_cp_sym16,
87 .cube = antindex_cp_sym16, 92 .cube = antindex_cp_sym16,
88 .ntrans = 16,
89 .trans = trans_group_udfix,
90}; 93};
91 94
92Coordinate 95Coordinate
93coord_drud_sym16 = { 96coord_drud_sym16 = {
94 .index = index_drud_sym16, 97 .index = index_drud_sym16,
95 .cube = antindex_drud_sym16, 98 .cube = antindex_drud_sym16,
96 .max = POW3TO7 * 64430, 99 .max = POW3TO7 * CLASSES_EOFBEPOS_16,
97 .ntrans = 16, 100 .trans = transfinder_drud_sym16,
98 .trans = trans_group_udfix,
99}; 101};
100 102
101Coordinate 103Coordinate
102coord_drudfin_noE_sym16 = { 104coord_drudfin_noE_sym16 = {
103 .index = index_drudfin_noE_sym16, 105 .index = index_drudfin_noE_sym16,
104 .cube = antindex_drudfin_noE_sym16, 106 .cube = antindex_drudfin_noE_sym16,
105 .max = FACTORIAL8 * 2768, 107 .max = FACTORIAL8 * CLASSES_CP_16,
106 .ntrans = 16, 108 .trans = transfinder_drudfin_noE_sym16,
107 .trans = trans_group_udfix,
108}; 109};
109 110
110Coordinate 111Coordinate
111coord_khuge = { 112coord_khuge = {
112 .index = index_khuge, 113 .index = index_khuge,
113 .cube = antindex_khuge, 114 .cube = antindex_khuge,
114 .max = POW3TO7 * FACTORIAL4 * 64430, 115 .max = POW3TO7 * FACTORIAL4 * CLASSES_EOFBEPOS_16,
115 .ntrans = 16, 116 .trans = transfinder_khuge,
116 .trans = trans_group_udfix,
117}; 117};
118 118
119/* Functions *****************************************************************/ 119/* Functions *****************************************************************/
@@ -229,6 +229,72 @@ index_khuge(Cube cube)
229 return a * POW3TO7 + c.coud; 229 return a * POW3TO7 + c.coud;
230} 230}
231 231
232static int
233transfinder_drud_sym16(uint64_t ind, Trans *ret)
234{
235 uint64_t i, trueind;
236 int j;
237 static bool initialized = false;
238 static int naux[CLASSES_EOFBEPOS_16];
239 static Trans retaux[CLASSES_EOFBEPOS_16][NTRANS];
240
241 if (!initialized) {
242 for (i = 0; i < CLASSES_EOFBEPOS_16; i++)
243 naux[i] = selfsims(&sd_eofbepos_16, i, retaux[i]);
244
245 initialized = true;
246 }
247
248 trueind = ind/POW3TO7;
249 for (j = 0; j < naux[trueind]; j++)
250 ret[j] = retaux[trueind][j];
251 return naux[trueind];
252}
253
254static int
255transfinder_drudfin_noE_sym16(uint64_t ind, Trans *ret)
256{
257 uint64_t i, trueind;
258 int j;
259 static bool initialized = false;
260 static int naux[CLASSES_CP_16];
261 static Trans retaux[CLASSES_CP_16][NTRANS];
262
263 if (!initialized) {
264 for (i = 0; i < CLASSES_CP_16; i++)
265 naux[i] = selfsims(&sd_cp_16, i, retaux[i]);
266
267 initialized = true;
268 }
269
270 trueind = ind/FACTORIAL8;
271 for (j = 0; j < naux[trueind]; j++)
272 ret[j] = retaux[trueind][j];
273 return naux[trueind];
274}
275
276static int
277transfinder_khuge(uint64_t ind, Trans *ret)
278{
279 uint64_t i, trueind;
280 int j;
281 static bool initialized = false;
282 static int naux[CLASSES_EOFBEPOS_16];
283 static Trans retaux[CLASSES_EOFBEPOS_16][NTRANS];
284
285 if (!initialized) {
286 for (i = 0; i < CLASSES_EOFBEPOS_16; i++)
287 naux[i] = selfsims(&sd_eofbepos_16, i, retaux[i]);
288
289 initialized = true;
290 }
291
292 trueind = ind/(FACTORIAL4*POW3TO7);
293 for (j = 0; j < naux[trueind]; j++)
294 ret[j] = retaux[trueind][j];
295 return naux[trueind];
296}
297
232/* Other functions ***********************************************************/ 298/* Other functions ***********************************************************/
233 299
234static void 300static void
@@ -320,6 +386,25 @@ read_symdata_file(SymData *sd)
320 return r; 386 return r;
321} 387}
322 388
389static int
390selfsims(SymData *sd, uint64_t ind, Trans *ret)
391{
392 Cube cube, tcube;
393 int i, n;
394 uint64_t indnosym;
395
396 cube = sd->sym_coord->cube(ind);
397 indnosym = sd->coord->index(cube);
398 n = 0;
399 for (i = 0; i < sd->ntrans; i++) {
400 tcube = apply_trans(sd->trans[i], cube);
401 if (sd->coord->index(tcube) == indnosym)
402 ret[n++] = sd->trans[i];
403 }
404
405 return n;
406}
407
323static bool 408static bool
324write_symdata_file(SymData *sd) 409write_symdata_file(SymData *sd)
325{ 410{

Generated with cgit - Back to sebastiano.tronto.net