diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-18 09:53:07 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-18 09:53:07 +0200 |
| commit | e71e2776674a748372e95702be49af2753ff3d48 (patch) | |
| tree | 81a936d347e9317a06491d48d7ad879fb9c8cc70 /doc | |
| parent | 5a8ca71aa8255fb76335bf41c8168cfe45eb9574 (diff) | |
| download | nissy-core-e71e2776674a748372e95702be49af2753ff3d48.tar.gz nissy-core-e71e2776674a748372e95702be49af2753ff3d48.zip | |
Update H48 doc
Diffstat (limited to '')
| -rw-r--r-- | doc/h48.md | 50 |
1 files changed, 35 insertions, 15 deletions
| @@ -309,22 +309,42 @@ we can reuse it and avoid an expensive table lookup. | |||
| 309 | 309 | ||
| 310 | ### Other optimizations | 310 | ### Other optimizations |
| 311 | 311 | ||
| 312 | Other possible (low-level) optimizations include: | 312 | The H48 solver uses various other optimizations. |
| 313 | 313 | ||
| 314 | * **Avoid inverse computation**: computing the inverse of a cube position | 314 | #### Avoiding inverse cube computation |
| 315 | is expensive. We can avoid doing that (for the inverse pruning value | 315 | |
| 316 | estimate) if we bring along both the normal and the inverse cube during | 316 | Computing the inverse of a cube position is expensive. We avoid doing |
| 317 | the search, and we use *premoves* to apply moves to the inverse scramble. | 317 | that (for the inverse pruning value estimate) if we bring along both |
| 318 | * **Multi-threading (multiple scrambles)**: It is easy to parallelize this | 318 | the normal and the inverse cube during the search, and we use *premoves* |
| 319 | algorithm when solving multiple cubes at once, by firing up multiple | 319 | to apply moves to the inverse scramble. |
| 320 | instances of the solver. It is important to make sure that the same | 320 | |
| 321 | (read-only) pruning table is used for all instances, to avoid expensive | 321 | #### Multi-threading |
| 322 | memory duplication. | 322 | |
| 323 | * **Multi-threading (single scramble)**: It is also possible to parallelize | 323 | The solution search is parallelized *per-scramble*. Although when solving |
| 324 | the search for a single scramble. For example, we can generate 18 different | 324 | multiple positions it would be more efficient to solve them in parallel |
| 325 | cubes, one for each possible starting move, and solve each of them in a | 325 | by dedicating a single thread to each of them, the current H48 solver |
| 326 | separate thread. Some coordination between threads is necessary to stop | 326 | optimizes for solving a single cube at the time. |
| 327 | the search when the desired number of solutions has been found. | 327 | |
| 328 | To do this, we first compute all cube positions that are 4 moves away | ||
| 329 | from the scramble. This way we prepare up to 43254 *tasks* (depending | ||
| 330 | on the symmetries of the starting position, which we take advantage of) | ||
| 331 | which are equally split between the available threads. Any solution | ||
| 332 | encountered in this step is of course added to the list of solutions. | ||
| 333 | |||
| 334 | #### Heuristically sorting tasks | ||
| 335 | |||
| 336 | The tasks described in the previous paragraph (multi-threading) are | ||
| 337 | initially searched in an arbitrary order. However, after searching at a | ||
| 338 | sufficient depth, we have gathered some data that allows us to make some | ||
| 339 | heuristical improvements: the tasks that leads to visiting more positions | ||
| 340 | (or in other words, where we go over the estimated lower bounds less | ||
| 341 | often), are more likely to yield the optimal solution. Thus we sort the | ||
| 342 | tasks based on this. | ||
| 343 | |||
| 344 | Preliminary benchmark show a performance improvement of around 40% | ||
| 345 | when searching a single solution. When searching for multiple optimal | ||
| 346 | solutions the effects of this optimization will be less pronounced, and | ||
| 347 | they are obviously inexistent when looking for *all* optimal solutions. | ||
| 328 | 348 | ||
| 329 | ## Pruning table computation | 349 | ## Pruning table computation |
| 330 | 350 | ||
