aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/h48')
-rw-r--r--src/solvers/h48/solve.h30
-rw-r--r--src/solvers/h48/solve_multithread.h1
2 files changed, 19 insertions, 12 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index 36b6875..2a5e341 100644
--- a/src/solvers/h48/solve.h
+++ b/src/solvers/h48/solve.h
@@ -8,6 +8,7 @@ typedef struct {
8 int64_t maxsolutions; 8 int64_t maxsolutions;
9 uint8_t h; 9 uint8_t h;
10 uint8_t k; 10 uint8_t k;
11 uint8_t base;
11 const uint32_t *cocsepdata; 12 const uint32_t *cocsepdata;
12 const uint8_t *h48data; 13 const uint8_t *h48data;
13 uint64_t solutions_size; 14 uint64_t solutions_size;
@@ -98,27 +99,32 @@ STATIC_INLINE bool
98solve_h48_stop(dfsarg_solveh48_t *arg) 99solve_h48_stop(dfsarg_solveh48_t *arg)
99{ 100{
100 uint32_t data, data_inv; 101 uint32_t data, data_inv;
101 int8_t bound; 102 int8_t cbound, cbound_inv, h48bound, h48bound_inv;
102 103
103 arg->nissbranch = MM_NORMAL; 104 arg->nissbranch = MM_NORMAL;
104 bound = get_h48_cdata(arg->cube, arg->cocsepdata, &data); 105 cbound = get_h48_cdata(arg->cube, arg->cocsepdata, &data);
105 if (bound + arg->nmoves + arg->npremoves > arg->depth) 106 if (cbound + arg->nmoves + arg->npremoves > arg->depth)
106 return true; 107 return true;
107 108
108 bound = get_h48_cdata(arg->inverse, arg->cocsepdata, &data_inv); 109 cbound_inv = get_h48_cdata(arg->inverse, arg->cocsepdata, &data_inv);
109 if (bound + arg->nmoves + arg->npremoves > arg->depth) 110 if (cbound_inv + arg->nmoves + arg->npremoves > arg->depth)
110 return true; 111 return true;
111 112
112 bound = get_h48_bound(arg->cube, data, arg->h, arg->k, arg->h48data); 113 h48bound = get_h48_bound(arg->cube, data, arg->h, arg->k, arg->h48data);
113 if (bound + arg->nmoves + arg->npremoves > arg->depth) 114
115 /* If the h48 bound is > 0, we add the base value. */
116 /* Otherwise, we use the cbound value instead (fallback). */
117 h48bound += h48bound == 0 ? cbound : arg->base;
118 if (h48bound + arg->nmoves + arg->npremoves > arg->depth)
114 return true; 119 return true;
115 if (bound + arg->nmoves + arg->npremoves == arg->depth) 120 if (h48bound + arg->nmoves + arg->npremoves == arg->depth)
116 arg->nissbranch = MM_INVERSEBRANCH; 121 arg->nissbranch = MM_INVERSEBRANCH;
117 122
118 bound = get_h48_bound(arg->inverse, data_inv, arg->h, arg->k, arg->h48data); 123 h48bound_inv = get_h48_bound(arg->inverse, data_inv, arg->h, arg->k, arg->h48data);
119 if (bound + arg->nmoves + arg->npremoves > arg->depth) 124 h48bound_inv += h48bound_inv == 0 ? cbound_inv : arg->base;
125 if (h48bound_inv + arg->nmoves + arg->npremoves > arg->depth)
120 return true; 126 return true;
121 if (bound + arg->nmoves + arg->npremoves == arg->depth) 127 if (h48bound_inv + arg->nmoves + arg->npremoves == arg->depth)
122 arg->nissbranch = MM_NORMALBRANCH; 128 arg->nissbranch = MM_NORMALBRANCH;
123 129
124 return false; 130 return false;
@@ -144,7 +150,6 @@ solve_h48_dfs(dfsarg_solveh48_t *arg)
144 return 1; 150 return 1;
145 } 151 }
146 152
147 /* TODO: avoid copy, change arg and undo changes after recursion */
148 nextarg = *arg; 153 nextarg = *arg;
149 ret = 0; 154 ret = 0;
150 uint32_t allowed; 155 uint32_t allowed;
@@ -203,6 +208,7 @@ solve_h48(
203 .maxsolutions = maxsolutions, 208 .maxsolutions = maxsolutions,
204 .h = info.h48h, 209 .h = info.h48h,
205 .k = info.bits, 210 .k = info.bits,
211 .base = info.base,
206 .cocsepdata = get_cocsepdata_constptr(data), 212 .cocsepdata = get_cocsepdata_constptr(data),
207 .h48data = get_h48data_constptr(data), 213 .h48data = get_h48data_constptr(data),
208 .solutions_size = solutions_size, 214 .solutions_size = solutions_size,
diff --git a/src/solvers/h48/solve_multithread.h b/src/solvers/h48/solve_multithread.h
index d8c81af..2e3a1e9 100644
--- a/src/solvers/h48/solve_multithread.h
+++ b/src/solvers/h48/solve_multithread.h
@@ -277,6 +277,7 @@ solve_h48_multithread(
277 .maxsolutions = maxsolutions, 277 .maxsolutions = maxsolutions,
278 .h = info.h48h, 278 .h = info.h48h,
279 .k = info.bits, 279 .k = info.bits,
280 .base = info.base,
280 .cocsepdata = get_cocsepdata_constptr(data), 281 .cocsepdata = get_cocsepdata_constptr(data),
281 .h48data = get_h48data_constptr(data), 282 .h48data = get_h48data_constptr(data),
282 .solutions_size = solutions_size, 283 .solutions_size = solutions_size,

Generated with cgit - Back to sebastiano.tronto.net