From 1215648b1ba3c592bd9d97b871349673d1702e44 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 13 Dec 2021 20:40:18 +0100 Subject: Faster optimal solver. This is a pretty big one, but unfortunately performance only improved by about 5%. I implemented one of the main ideas of nxopt, that is switching to the inverse scramble on the fly if it gives a lower branching factor. On the one hand it makes sense that it does not have such a huge impact, since it only rarely happens that we do have a lower branching factor on inverse, but on the other hand I am quite sad that the improvement is barely noticeable :-( Maybe the problem is that I have introduced a lot of new overhead and I can improve that in the future. Or maybe I am just overlooking something stupid. --- src/cubetypes.h | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src/cubetypes.h') diff --git a/src/cubetypes.h b/src/cubetypes.h index 9ec8620..3ad960b 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h @@ -81,9 +81,8 @@ typedef struct commandargs CommandArgs; typedef struct coordinate Coordinate; typedef struct cube Cube; typedef struct cubearray CubeArray; -typedef struct dfsdata DfsData; +typedef struct dfsarg DfsArg; typedef struct estimatedata EstimateData; -typedef struct localinfo LocalInfo; typedef struct piecefilter PieceFilter; typedef struct prunedata PruneData; typedef struct solveoptions SolveOptions; @@ -94,7 +93,7 @@ typedef struct threaddatagenpt ThreadDataGenpt; typedef Cube (*AntiIndexer) (uint64_t); typedef bool (*Checker) (Cube); -typedef int (*Estimator) (EstimateData *); +typedef int (*Estimator) (DfsArg *); typedef bool (*Validator) (Alg *); typedef void (*Exec) (CommandArgs *); typedef uint64_t (*Indexer) (Cube); @@ -198,35 +197,30 @@ cubearray }; struct -dfsdata +dfsarg { + Step * step; + SolveOptions * opts; + Cube cube; + Cube inverse; int d; - int m; - int lb; + uint64_t badmoves; + uint64_t badmovesinv; bool niss; Move last1; Move last2; + Move last1inv; + Move last2inv; EstimateData * ed; AlgList * sols; pthread_mutex_t * sols_mutex; Alg * current_alg; Move * sorted_moves; int * move_position; - uint8_t * visited; }; struct estimatedata -{ - Cube cube; - int target; - Move lastmove; - uint64_t movebitmask; - LocalInfo * li; -}; - -struct -localinfo { int corners; int normal_ud; @@ -235,7 +229,7 @@ localinfo int inverse_ud; int inverse_fb; int inverse_rl; - int prev_ret; + int oldret; }; struct @@ -284,6 +278,8 @@ step { char * shortname; char * name; + bool final; + Checker is_done; Estimator estimate; Checker ready; char * ready_msg; -- cgit v1.3