diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-02-08 23:20:11 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-02-08 23:20:11 +0100 |
| commit | 374c33d1412f8f3a35dd3eb874dcaef82d60fff4 (patch) | |
| tree | ba90fa0e453e06564af5816b621ca24f359afd5c | |
| parent | 455c7d9c8185acdd8c8fe74ad4a59a3e0756d75d (diff) | |
| download | nissy-374c33d1412f8f3a35dd3eb874dcaef82d60fff4.tar.gz nissy-374c33d1412f8f3a35dd3eb874dcaef82d60fff4.zip | |
Added notes for solver theory
| -rw-r--r-- | TODO/2.1.md | 63 | ||||
| -rw-r--r-- | TODO/testing.md | 8 |
2 files changed, 49 insertions, 22 deletions
diff --git a/TODO/2.1.md b/TODO/2.1.md index 6cdd946..92e4555 100644 --- a/TODO/2.1.md +++ b/TODO/2.1.md | |||
| @@ -2,26 +2,57 @@ | |||
| 2 | 2 | ||
| 3 | ## Rework solver | 3 | ## Rework solver |
| 4 | 4 | ||
| 5 | ### Architecture | 5 | * The architecture is the following: solve.h contains a solve() public |
| 6 | function that takes as parameters a set of solver methods (see below) | ||
| 7 | and a thread manager (basically, multithreaded or single threaded). | ||
| 8 | It also has a dfs() public function with the same parameters. | ||
| 9 | * The solve() function, looping over the allowed depths, calls | ||
| 10 | the dispatcher provided by the thread manager, which takes care of | ||
| 11 | instantiating the threads. Each thread calls back to dfs(). The | ||
| 12 | thread manager then takes case of re-assembling the solutions, and | ||
| 13 | finally returns a list of solutions for the given depth. | ||
| 14 | * The specifics of how dfs() works are implemented in a specific solver | ||
| 15 | module. | ||
| 6 | 16 | ||
| 7 | * Nail down the theory first | 17 | ### solve.h |
| 8 | * One generic solve module that does not depend on anything else, | 18 | |
| 9 | not even on cube if possible | 19 | * Interface: define solve(), dfs() and the types dfsdata, solvermethods and |
| 10 | * The generic file includes the logic for branching and calls functions | 20 | threadmanager. solve.h is included by specific thread managers and solvers. |
| 11 | provided as parameters to move the cube and check the status etc... | 21 | * DfsData: remove Cube *, Movable, Step and extra. Add Void * (containing |
| 12 | * This includes the logic for single/multithreading (simplify if compiled | 22 | either cube, indexes or whatnot) and a moveset (extracted from step, |
| 13 | with N_THREADS = 1 or whatever this option is going to be) | 23 | necessary). Maybe cleanup solveoptions too (e.g. threads not necessary). |
| 14 | * The data representing the cube is a void pointer | 24 | * solve.h depends only on moves (dependency on step and trans is removed). |
| 25 | * preparation step should be reworked, maybe removed or delegated to the | ||
| 26 | specific implementations. | ||
| 27 | * allowed_moves and cancel_niss are moved to move.h. | ||
| 28 | * All dfs stuff in the same function. Maybe remove also solvestop. | ||
| 15 | * Move two-step solve to a different module | 29 | * Move two-step solve to a different module |
| 16 | * Each other solver (solve coord, solve fst, solve multistep) | ||
| 17 | should go in a separate module | ||
| 18 | 30 | ||
| 19 | ### Other practicalities | 31 | ### Specific thread managers |
| 32 | |||
| 33 | * Single thread. Useful in low-resources environments or when solving multiple | ||
| 34 | scrambles at the same time, or simply when asked to solve with one thread. | ||
| 35 | * Lazy multithread: threads are as independent as possible and only | ||
| 36 | merged at the end. Ideal when all solutions of a certain length are requested. | ||
| 37 | * Eager multithread: current implementation, branches communicate the number | ||
| 38 | and list of solutions to stop as soon as possible. Good when only one solution | ||
| 39 | of a certain depth is required. | ||
| 40 | |||
| 41 | ### Solver methods | ||
| 20 | 42 | ||
| 21 | * remove cube from dfsarg? (i still need to save the scramble somewhere, | 43 | * bool move_check_stop(DfsArg *, Move): applies the given move (possibly |
| 22 | but I really only use it in dfs_niss) | 44 | recovered from DfsData, but we avoid checking for niss by passing it |
| 23 | * Re-work prepare_step process for solve_generic (nxopt table is special). | 45 | directly) and at the same time checks if the branch should be pruned. Not |
| 24 | * is_valid should also unnis and / or cleanup the alg. | 46 | elegant, but it is much more efficient to do the two things at the same time |
| 47 | (e.g. when moving a fst_cube we can move one "orientation" at the time, check | ||
| 48 | the pruning table and stop if possible). | ||
| 49 | * void add_solution(DfsArg *, ThreadManager): add the solution to the list. | ||
| 50 | Also checks if the solution is valid / acceptable (e.g. EO does not finish | ||
| 51 | with F' instead of F and such) and cleans it up (rotation, cleanup, unniss). | ||
| 52 | * void copy(void * src, void * dst): copy the cube-part of dfs_data. To be | ||
| 53 | called by copy_dfsdata, which remains in solve.h (but merged into dfs). | ||
| 54 | * void * invert_cube(void *): in preparation for niss. | ||
| 55 | * bool niss_makes_sense(DfsArg *): maybe can be done generically in solve.h? | ||
| 25 | 56 | ||
| 26 | ## New optimal solver (use fst) | 57 | ## New optimal solver (use fst) |
| 27 | 58 | ||
diff --git a/TODO/testing.md b/TODO/testing.md index 8c62f87..1deb93a 100644 --- a/TODO/testing.md +++ b/TODO/testing.md | |||
| @@ -2,9 +2,5 @@ | |||
| 2 | 2 | ||
| 3 | ## Write tests | 3 | ## Write tests |
| 4 | 4 | ||
| 5 | * Pretty much all are missing, except fst. | 5 | * Write tests for each module. Some of might require refactoring (this is |
| 6 | * Start from bottom (utils.c) | 6 | a good thing!) |
| 7 | |||
| 8 | ## Other | ||
| 9 | |||
| 10 | * Move test_coord from coord.c to test folder. | ||
