diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-07 16:38:40 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-07 16:38:40 +0100 |
| commit | 9ac266c76f39620d8343e46ca41cb09d1534384c (patch) | |
| tree | 823bd419d99fe0f00e6b5b713237a73b4ec7ffca /src/solvers/h48/gendata_h48.h | |
| parent | ea25a7ccad625c4e664dfd114147971b8a2677f3 (diff) | |
| download | nissy-core-9ac266c76f39620d8343e46ca41cb09d1534384c.tar.gz nissy-core-9ac266c76f39620d8343e46ca41cb09d1534384c.zip | |
Merge the "solver-experiments" branch that I have been working on for
a few weeks. This include mainly three things:
1. Various tweaks for a total performance gain of around 30%.
2. Take into account symmetries and avoid repeated work. This
required a re-work of the splitting into tasks before the solve.
3. Add a second fallback table (eoesep). This gives huge performance
gains for particular scrambles (e.g. superflip).
After merging this commit, remove and re-generate all pruning tables.
Squashed commit of the following:
commit 60f0705d2d69050e6a30581a2810f686d6f69b80
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sat Dec 7 16:06:48 2024 +0100
Fix indentation
commit cc5d489a251812b6188c0ba264ac6cb2236f1afe
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sat Dec 7 15:56:19 2024 +0100
Updated documentation
commit a3f605dd628546e52564f82b139feb473b0725f3
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sat Dec 7 14:01:11 2024 +0100
use eoesep table as second fallback
commit c75e43c9116c64f97e92b0fe038be8a032925a72
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Fri Dec 6 16:13:23 2024 +0100
First commit for gendata_eoesep
commit fea7688ab8bdc5ae0c3480622e2510a3bcd39248
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Dec 3 17:31:00 2024 +0100
Add scramble to tool
commit 66866cb71dea4ca8278ecb9e90ff4295771feb42
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Dec 3 17:22:59 2024 +0100
Added tool to check multiple solutions
commit ef65611c772c3996bddca8d181da3538e0af1674
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Dec 3 17:16:20 2024 +0100
Write all solutions for symmetric positions
commit e3ded26db7d7d4ae7c0e2488151ed14f581f7b8e
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Nov 26 09:14:54 2024 +0100
Added symmetry filter (TODO: print excluded solutions)
commit 864c437a9751c58d58562650ca9eba4a9e6ad3eb
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Mon Nov 25 14:51:13 2024 +0100
Improved task split
commit b88926d36d7ab0c64c5fe3bb954fd15d41267fba
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Fri Nov 22 19:06:41 2024 +0100
Reworked tasks for multi-threading in view of symmetry filter
commit 26fa653f97df8cd601aecb80eaf89f0a00e9ba9f
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Thu Oct 31 15:37:43 2024 +0100
Added transform move
commit 19f655ef94d658eaa2fefb5cea3c167a3ec58db6
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Thu Oct 31 09:29:15 2024 +0100
Clarified doc
commit 3b0fe1e5ef8b628854e30f0f0067300e2763c954
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Thu Oct 31 08:36:58 2024 +0100
Handle solved cube correctly
commit 57705cbc4982e3abe97a36ed64871738d4f721c0
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Thu Oct 31 08:24:30 2024 +0100
Close file
commit fc7d462b58bcf3d3a3fbf26c1f3bd04c640a4898
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Oct 29 15:05:48 2024 +0100
Removed stats tool
commit 359bf7cb49ef405ee76ed662207d47cb2abcc5a9
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Oct 29 15:01:51 2024 +0100
Updated theory doc
commit 39c315af562bc4ce896f41004388a4c34d475d37
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Oct 29 14:51:40 2024 +0100
Remove unused constants
commit 57a5d24538aa59a4df9221dad2f99e9f0286bd9d
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Tue Oct 29 10:20:38 2024 +0100
Add tool to solve scrambles from file
commit 07e2918c216636891b1fa6adecc9756086a901e9
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Mon Oct 28 17:00:00 2024 +0100
Add make table to tool
commit f5e5266c654eb027a5a35c57cc618555246f5e5e
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Mon Oct 28 09:35:49 2024 +0100
Remove old solver, other small things
commit a1ec78025b7959dbb845213f7f4e6851ecebc204
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sun Oct 27 02:00:29 2024 +0200
Improvements
commit 8eea23dbe888d923e662e24ae969130e2c67b999
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sat Oct 26 12:24:19 2024 +0200
Makefile fix
commit 3fc3927beacc78971cefeb42da8d71fe6c015fc1
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Fri Oct 25 18:25:09 2024 +0200
More performance gains
commit 7b4efa1f9af9722de1ab9ccfc27899825a0d12c4
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Fri Oct 25 15:53:20 2024 +0200
Alternative solver implementation, small performance gain
Diffstat (limited to 'src/solvers/h48/gendata_h48.h')
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 55c4f34..ae0b732 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -61,13 +61,13 @@ gendata_h48short(gendata_h48short_arg_t *arg) | |||
| 61 | return arg->map->n; | 61 | return arg->map->n; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | /* Generic function that dispatches to the data generators */ | ||
| 65 | STATIC int64_t | 64 | STATIC int64_t |
| 66 | gendata_h48(gendata_h48_arg_t *arg) | 65 | gendata_h48(gendata_h48_arg_t *arg) |
| 67 | { | 66 | { |
| 68 | uint64_t size, cocsepsize, h48size, fallbacksize; | 67 | uint64_t size, cocsepsize, h48size, fallbacksize, fallback2size, of; |
| 68 | long long r; | ||
| 69 | void *cocsepdata_offset; | 69 | void *cocsepdata_offset; |
| 70 | tableinfo_t cocsepinfo, h48info; | 70 | tableinfo_t cocsepinfo, h48info, fallbackinfo; |
| 71 | gendata_h48_arg_t arg_h0k4; | 71 | gendata_h48_arg_t arg_h0k4; |
| 72 | 72 | ||
| 73 | if (arg == NULL) { | 73 | if (arg == NULL) { |
| @@ -78,7 +78,8 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 78 | cocsepsize = COCSEP_FULLSIZE; | 78 | cocsepsize = COCSEP_FULLSIZE; |
| 79 | h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); | 79 | h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); |
| 80 | fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; | 80 | fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; |
| 81 | size = cocsepsize + h48size + fallbacksize; | 81 | fallback2size = EOESEP_FULLSIZE; |
| 82 | size = cocsepsize + h48size + fallbacksize + fallback2size; | ||
| 82 | 83 | ||
| 83 | if (arg->buf == NULL) | 84 | if (arg->buf == NULL) |
| 84 | return size; /* Dry-run */ | 85 | return size; /* Dry-run */ |
| @@ -110,18 +111,22 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 110 | return NISSY_ERROR_INVALID_SOLVER; | 111 | return NISSY_ERROR_INVALID_SOLVER; |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | if (readtableinfo(arg->buf_size, arg->buf, &cocsepinfo) != NISSY_OK) { | 114 | r = readtableinfo(arg->buf_size, arg->buf, &cocsepinfo); |
| 115 | if (r != NISSY_OK) { | ||
| 114 | LOG("gendata_h48: could not read info for cocsep table\n"); | 116 | LOG("gendata_h48: could not read info for cocsep table\n"); |
| 115 | return NISSY_ERROR_UNKNOWN; | 117 | return NISSY_ERROR_UNKNOWN; |
| 116 | } | 118 | } |
| 117 | 119 | ||
| 118 | cocsepinfo.next = cocsepsize; | 120 | cocsepinfo.next = cocsepsize; |
| 119 | if (writetableinfo(&cocsepinfo, arg->buf_size, arg->buf) != NISSY_OK) { | 121 | r = writetableinfo(&cocsepinfo, arg->buf_size, arg->buf); |
| 122 | if (r != NISSY_OK) { | ||
| 120 | LOG("gendata_h48: could not write info for cocsep table" | 123 | LOG("gendata_h48: could not write info for cocsep table" |
| 121 | " with updated 'next' value\n"); | 124 | " with updated 'next' value\n"); |
| 122 | return NISSY_ERROR_UNKNOWN; | 125 | return NISSY_ERROR_UNKNOWN; |
| 123 | } | 126 | } |
| 124 | 127 | ||
| 128 | /* Add h0k4 fallback table */ | ||
| 129 | |||
| 125 | if (arg->k == 2) { | 130 | if (arg->k == 2) { |
| 126 | arg_h0k4 = *arg; | 131 | arg_h0k4 = *arg; |
| 127 | arg_h0k4.h = 0; | 132 | arg_h0k4.h = 0; |
| @@ -134,16 +139,42 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 134 | 139 | ||
| 135 | gendata_h48h0k4(&arg_h0k4); | 140 | gendata_h48h0k4(&arg_h0k4); |
| 136 | 141 | ||
| 137 | if (readtableinfo_n(arg->buf_size, arg->buf, 2, &h48info) | 142 | } |
| 138 | != NISSY_OK) { | 143 | |
| 139 | LOG("gendata_h48: could not read info for h48 table\n"); | 144 | /* Add eoesep fallback table */ |
| 145 | |||
| 146 | gendata_eoesep((char *)arg->buf + (size - fallback2size), 20); | ||
| 147 | |||
| 148 | /* Update tableinfo with correct next values */ | ||
| 149 | |||
| 150 | r = readtableinfo_n(arg->buf_size, arg->buf, 2, &h48info); | ||
| 151 | if (r != NISSY_OK) { | ||
| 152 | LOG("gendata_h48: could not read info for h48 table\n"); | ||
| 153 | return NISSY_ERROR_UNKNOWN; | ||
| 154 | } | ||
| 155 | h48info.next = h48size; | ||
| 156 | r = writetableinfo(&h48info, | ||
| 157 | arg->buf_size - cocsepsize, (char *)arg->buf + cocsepsize); | ||
| 158 | if (r != NISSY_OK) { | ||
| 159 | LOG("gendata_h48: could not write info for h48 table\n"); | ||
| 160 | return NISSY_ERROR_UNKNOWN; | ||
| 161 | } | ||
| 162 | |||
| 163 | if (arg->k == 2) { | ||
| 164 | r = readtableinfo_n(arg->buf_size, arg->buf, 3, &fallbackinfo); | ||
| 165 | if (r != NISSY_OK) { | ||
| 166 | LOG("gendata_h48: could not read info for h48 " | ||
| 167 | "fallback table\n"); | ||
| 140 | return NISSY_ERROR_UNKNOWN; | 168 | return NISSY_ERROR_UNKNOWN; |
| 141 | } | 169 | } |
| 142 | 170 | ||
| 143 | h48info.next = h48size; | 171 | of = cocsepsize + h48size; |
| 144 | if (writetableinfo(&h48info, arg->buf_size - cocsepsize, | 172 | fallbackinfo.next = fallbacksize; |
| 145 | (char *)arg->buf + cocsepsize) != NISSY_OK) { | 173 | r = writetableinfo(&fallbackinfo, |
| 146 | LOG("gendata_h48: could not write info for h48 table\n"); | 174 | arg->buf_size - of, (char *)arg->buf + of); |
| 175 | if (r != NISSY_OK) { | ||
| 176 | LOG("gendata_h48: could not write info for h48 " | ||
| 177 | "fallback table\n"); | ||
| 147 | return NISSY_ERROR_UNKNOWN; | 178 | return NISSY_ERROR_UNKNOWN; |
| 148 | } | 179 | } |
| 149 | } | 180 | } |
| @@ -302,9 +333,8 @@ gendata_h48k2(gendata_h48_arg_t *arg) | |||
| 302 | * | 333 | * |
| 303 | * The following values for the base have been hand-picked. I first | 334 | * The following values for the base have been hand-picked. I first |
| 304 | * performed some statistics on the frequency of these values, but | 335 | * performed some statistics on the frequency of these values, but |
| 305 | * they turned out to be unreliable. I have not figured out why yet. | 336 | * they turned out to be unreliable. In the end I generated the same |
| 306 | * In the end I resorted to generating the same table with multiple | 337 | * table with multiple base value and see what was best. |
| 307 | * base value and see what was best. | ||
| 308 | * | 338 | * |
| 309 | * A curious case is h3, which has this distribution for base 8: | 339 | * A curious case is h3, which has this distribution for base 8: |
| 310 | * [0] = 6686828 | 340 | * [0] = 6686828 |
