diff options
Diffstat (limited to 'src/solvers/twostep')
| -rw-r--r-- | src/solvers/twostep/twostep.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/solvers/twostep/twostep.h b/src/solvers/twostep/twostep.h new file mode 100644 index 0000000..e5b00f6 --- /dev/null +++ b/src/solvers/twostep/twostep.h | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | #ifndef SRC_SOLVERS_TWOSTEP_TWOSTEP_H | ||
| 2 | #define SRC_SOLVERS_TWOSTEP_TWOSTEP_H | ||
| 3 | |||
| 4 | #include "../coord/coord.h" | ||
| 5 | |||
| 6 | STATIC size_t twostep_size_1(void); | ||
| 7 | STATIC size_t twostep_size_2(void); | ||
| 8 | STATIC long long dataid_twostep(const char *, char [SIZE(NISSY_SIZE_DATAID)]); | ||
| 9 | STATIC long long gendata_twostep( | ||
| 10 | const char *, unsigned long long, unsigned char *); | ||
| 11 | STATIC long long checkdata_twostep( | ||
| 12 | const char *, unsigned long long, const unsigned char *); | ||
| 13 | STATIC long long solve_twostep(oriented_cube_t, const char *, unsigned, | ||
| 14 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, | ||
| 15 | const unsigned char *, unsigned, char *, | ||
| 16 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); | ||
| 17 | |||
| 18 | STATIC size_t | ||
| 19 | twostep_size_1(void) | ||
| 20 | { | ||
| 21 | size_t s; | ||
| 22 | |||
| 23 | s = gendata_coord(&coordinate_dr, NULL); | ||
| 24 | s = (size_t)8 * DIV_ROUND_UP(s, 8); /* Preserve 8-byte alignment */ | ||
| 25 | |||
| 26 | return s; | ||
| 27 | } | ||
| 28 | |||
| 29 | STATIC size_t | ||
| 30 | twostep_size_2(void) | ||
| 31 | { | ||
| 32 | return gendata_multicoord(&multicoordinate_drfin, NULL); | ||
| 33 | } | ||
| 34 | |||
| 35 | STATIC long long | ||
| 36 | dataid_twostep(const char *s, char dataid[SIZE(NISSY_SIZE_DATAID)]) | ||
| 37 | { | ||
| 38 | strcpy(dataid, "DR_DRFIN"); | ||
| 39 | return NISSY_OK; | ||
| 40 | } | ||
| 41 | |||
| 42 | STATIC long long | ||
| 43 | gendata_twostep( | ||
| 44 | const char *s, | ||
| 45 | unsigned long long bufsize, | ||
| 46 | unsigned char *buf | ||
| 47 | ) | ||
| 48 | { | ||
| 49 | size_t r, s1, s2; | ||
| 50 | |||
| 51 | s1 = twostep_size_1(); | ||
| 52 | s2 = twostep_size_2(); | ||
| 53 | |||
| 54 | if (buf == NULL) | ||
| 55 | goto gendata_twostep_return_size; | ||
| 56 | |||
| 57 | if (bufsize < s1 + s2) | ||
| 58 | return NISSY_ERROR_BUFFER_SIZE; | ||
| 59 | |||
| 60 | r = gendata_coord(&coordinate_dr, buf); | ||
| 61 | if (r == 0) | ||
| 62 | return NISSY_ERROR_UNKNOWN; | ||
| 63 | |||
| 64 | r = gendata_multicoord(&multicoordinate_drfin, buf + s1); | ||
| 65 | if (r == 0) | ||
| 66 | return NISSY_ERROR_UNKNOWN; | ||
| 67 | |||
| 68 | gendata_twostep_return_size: | ||
| 69 | return s1 + s2; | ||
| 70 | } | ||
| 71 | |||
| 72 | STATIC long long | ||
| 73 | checkdata_twostep( | ||
| 74 | const char *s, | ||
| 75 | unsigned long long bufsize, | ||
| 76 | const unsigned char *buf | ||
| 77 | ) | ||
| 78 | { | ||
| 79 | long long r; | ||
| 80 | |||
| 81 | LOG("[checkdata] Checking double table for two step solver\n"); | ||
| 82 | |||
| 83 | r = checkdata_coord(&coordinate_dr, bufsize, buf); | ||
| 84 | if (r != NISSY_OK) | ||
| 85 | return r; | ||
| 86 | |||
| 87 | r = checkdata_multicoord( | ||
| 88 | &multicoordinate_drfin, bufsize, buf + twostep_size_1()); | ||
| 89 | if (r != NISSY_OK) | ||
| 90 | return r; | ||
| 91 | |||
| 92 | return NISSY_OK; | ||
| 93 | } | ||
| 94 | |||
| 95 | STATIC long long | ||
| 96 | solve_twostep( | ||
| 97 | oriented_cube_t oc, | ||
| 98 | const char *coord_and_trans, | ||
| 99 | unsigned nissflag, | ||
| 100 | unsigned minmoves, | ||
| 101 | unsigned maxmoves, | ||
| 102 | unsigned maxsolutions, | ||
| 103 | unsigned optimal, | ||
| 104 | unsigned threads, | ||
| 105 | unsigned long long data_size, | ||
| 106 | const unsigned char *data, | ||
| 107 | unsigned solutions_size, | ||
| 108 | char *sols, | ||
| 109 | long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], | ||
| 110 | int (*poll_status)(void *), | ||
| 111 | void *poll_status_data | ||
| 112 | ) | ||
| 113 | { | ||
| 114 | //TODO | ||
| 115 | } | ||
| 116 | |||
| 117 | #endif /* SRC_SOLVERS_TWOSTEP_TWOSTEP_H */ | ||
