diff options
Diffstat (limited to 'src/solvers/h48/solve.h')
| -rw-r--r-- | src/solvers/h48/solve.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 0969c45..1ca294a 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -23,6 +23,8 @@ typedef struct { | |||
| 23 | bool use_lb_inverse; | 23 | bool use_lb_inverse; |
| 24 | _Atomic int64_t *nsols; | 24 | _Atomic int64_t *nsols; |
| 25 | int64_t maxsolutions; | 25 | int64_t maxsolutions; |
| 26 | int8_t *shortest_sol; | ||
| 27 | int8_t optimal; | ||
| 26 | uint8_t h; | 28 | uint8_t h; |
| 27 | uint8_t k; | 29 | uint8_t k; |
| 28 | uint8_t base; | 30 | uint8_t base; |
| @@ -38,7 +40,7 @@ typedef struct { | |||
| 38 | int64_t nodes_visited; | 40 | int64_t nodes_visited; |
| 39 | int64_t table_fallbacks; | 41 | int64_t table_fallbacks; |
| 40 | int64_t table_lookups; | 42 | int64_t table_lookups; |
| 41 | int threads; | 43 | int8_t threads; |
| 42 | int ntasks; | 44 | int ntasks; |
| 43 | solve_h48_task_t *tasks; | 45 | solve_h48_task_t *tasks; |
| 44 | int thread_id; | 46 | int thread_id; |
| @@ -51,6 +53,7 @@ typedef struct { | |||
| 51 | uint8_t moves[STARTING_MOVES]; | 53 | uint8_t moves[STARTING_MOVES]; |
| 52 | int8_t minmoves; | 54 | int8_t minmoves; |
| 53 | int8_t maxmoves; | 55 | int8_t maxmoves; |
| 56 | int8_t *shortest_sol; | ||
| 54 | } dfsarg_solve_h48_maketasks_t; | 57 | } dfsarg_solve_h48_maketasks_t; |
| 55 | 58 | ||
| 56 | STATIC int64_t solve_h48_appendsolution(dfsarg_solve_h48_t *); | 59 | STATIC int64_t solve_h48_appendsolution(dfsarg_solve_h48_t *); |
| @@ -63,8 +66,9 @@ STATIC int64_t solve_h48_maketasks( | |||
| 63 | solve_h48_task_t [static STARTING_CUBES], int *); | 66 | solve_h48_task_t [static STARTING_CUBES], int *); |
| 64 | STATIC void *solve_h48_runthread(void *); | 67 | STATIC void *solve_h48_runthread(void *); |
| 65 | STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t *); | 68 | STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t *); |
| 66 | STATIC int64_t solve_h48(cube_t, int8_t, int8_t, uint64_t, int, uint64_t, | 69 | STATIC int64_t solve_h48(cube_t, int8_t, int8_t, uint64_t, int8_t, int8_t, |
| 67 | const void *, uint64_t, char *, long long [static NISSY_SIZE_SOLVE_STATS]); | 70 | uint64_t, const void *, uint64_t, char *, |
| 71 | long long [static NISSY_SIZE_SOLVE_STATS]); | ||
| 68 | 72 | ||
| 69 | STATIC int64_t | 73 | STATIC int64_t |
| 70 | solve_h48_appendsolution(dfsarg_solve_h48_t *arg) | 74 | solve_h48_appendsolution(dfsarg_solve_h48_t *arg) |
| @@ -73,7 +77,8 @@ solve_h48_appendsolution(dfsarg_solve_h48_t *arg) | |||
| 73 | int64_t ret; | 77 | int64_t ret; |
| 74 | uint64_t solstart; | 78 | uint64_t solstart; |
| 75 | 79 | ||
| 76 | if (*arg->nsols >= arg->maxsolutions) | 80 | if (*arg->nsols >= arg->maxsolutions || |
| 81 | arg->nmoves + arg->npremoves > *arg->shortest_sol + arg->optimal) | ||
| 77 | return 0; | 82 | return 0; |
| 78 | 83 | ||
| 79 | solstart = *arg->solutions_used; | 84 | solstart = *arg->solutions_used; |
| @@ -98,6 +103,8 @@ solve_h48_appendsolution(dfsarg_solve_h48_t *arg) | |||
| 98 | if (!solve_h48_appendchar(arg, '\n')) | 103 | if (!solve_h48_appendchar(arg, '\n')) |
| 99 | goto solve_h48_appendsolution_error; | 104 | goto solve_h48_appendsolution_error; |
| 100 | (*arg->nsols)++; | 105 | (*arg->nsols)++; |
| 106 | *arg->shortest_sol = | ||
| 107 | MIN(*arg->shortest_sol, arg->nmoves + arg->npremoves); | ||
| 101 | ret++; | 108 | ret++; |
| 102 | } | 109 | } |
| 103 | 110 | ||
| @@ -408,7 +415,8 @@ solve_h48( | |||
| 408 | int8_t minmoves, | 415 | int8_t minmoves, |
| 409 | int8_t maxmoves, | 416 | int8_t maxmoves, |
| 410 | uint64_t maxsolutions, | 417 | uint64_t maxsolutions, |
| 411 | int threads, | 418 | int8_t optimal, |
| 419 | int8_t threads, | ||
| 412 | uint64_t data_size, | 420 | uint64_t data_size, |
| 413 | const void *data, | 421 | const void *data, |
| 414 | uint64_t solutions_size, | 422 | uint64_t solutions_size, |
| @@ -417,7 +425,7 @@ solve_h48( | |||
| 417 | ) | 425 | ) |
| 418 | { | 426 | { |
| 419 | int i, ntasks, eoesep_table_index; | 427 | int i, ntasks, eoesep_table_index; |
| 420 | int8_t d; | 428 | int8_t d, shortest_sol; |
| 421 | _Atomic int64_t nsols; | 429 | _Atomic int64_t nsols; |
| 422 | dfsarg_solve_h48_t arg[THREADS]; | 430 | dfsarg_solve_h48_t arg[THREADS]; |
| 423 | solve_h48_task_t tasks[STARTING_CUBES]; | 431 | solve_h48_task_t tasks[STARTING_CUBES]; |
| @@ -463,12 +471,15 @@ solve_h48( | |||
| 463 | fallback2 = h48data + offset; | 471 | fallback2 = h48data + offset; |
| 464 | 472 | ||
| 465 | symmask = symmetry_mask(cube); | 473 | symmask = symmetry_mask(cube); |
| 474 | shortest_sol = MAXLEN+1; | ||
| 466 | for (i = 0; i < threads; i++) { | 475 | for (i = 0; i < threads; i++) { |
| 467 | arg[i] = (dfsarg_solve_h48_t) { | 476 | arg[i] = (dfsarg_solve_h48_t) { |
| 468 | .start_cube = cube, | 477 | .start_cube = cube, |
| 469 | .cube = cube, | 478 | .cube = cube, |
| 470 | .symmask0 = symmask, | 479 | .symmask0 = symmask, |
| 471 | .nsols = &nsols, | 480 | .nsols = &nsols, |
| 481 | .shortest_sol = &shortest_sol, | ||
| 482 | .optimal = optimal, | ||
| 472 | .maxsolutions = maxsolutions, | 483 | .maxsolutions = maxsolutions, |
| 473 | .h = info.h48h, | 484 | .h = info.h48h, |
| 474 | .k = info.bits, | 485 | .k = info.bits, |
| @@ -517,7 +528,8 @@ solve_h48( | |||
| 517 | 528 | ||
| 518 | for ( | 529 | for ( |
| 519 | d = MAX(minmoves, STARTING_MOVES + 1); | 530 | d = MAX(minmoves, STARTING_MOVES + 1); |
| 520 | d <= maxmoves && nsols < (int64_t)maxsolutions; | 531 | d <= maxmoves && nsols < (int64_t)maxsolutions |
| 532 | && !(nsols != 0 && d > shortest_sol + optimal); | ||
| 521 | d++ | 533 | d++ |
| 522 | ) { | 534 | ) { |
| 523 | if (d >= 10) | 535 | if (d >= 10) |
