Fix the Dial queue: two ways it silently dropped states
First version scanned ahead for the next nonempty bucket but stopped one max
edge weight out, so a sparse frontier ended the search early and claimed
"nothing under the limit" while the queue still had work. Scanning further is
also wrong: the ring reuses a slot every ring.size steps, so a far bucket sits
where a near one would be. Plain Dial now: step one cost unit at a time.
The growth table in the README was measured with the broken version and was
wildly optimistic. Real numbers from the fixed build, full adder with
adjacent cells: cost 58 -> 80M states, 66 -> 220M, 70 -> 280M, about 27 bytes
per state and 650k states/s, so cost 75 / 450M states / 12GB is roughly the
ceiling on this machine.
Validated solve_cost on the small problems where the answer is known by hand:
copy comes out at cost 17 (sacrifice 0 into {2}, then sacrifice 2 into {0,1}),
which is the two block program, and it replays ok.
This commit is contained in:
1 parent
98593b568c
commit
230cf92159
3 files changed
+31
-22
No files matched your search
@@ -544,18 +544,13 @@ private:
|
||||
int d = 0;
|
||||
size_t pops_last = 0;
|
||||
const int limit = opt.max_cost;
|
||||
while (true) {
|
||||
while (d <= limit) {
|
||||
auto &bucket = ring[size_t(d) % ring.size()];
|
||||
if (bucket.empty()) {
|
||||
// Dijkstra pops in nondecreasing order, so when this bucket is dry the
|
||||
// next state lives in the next nonempty one -- which can be further
|
||||
// away than one edge weight.
|
||||
int next = d + 1;
|
||||
while (next <= limit && ring[size_t(next) % ring.size()].empty())
|
||||
next++;
|
||||
if (next > limit)
|
||||
break; // nothing left under the limit
|
||||
d = next;
|
||||
// plain Dial: step one unit at a time. Scanning ahead is not safe --
|
||||
// the ring reuses slots every ring.size() steps, so a far bucket can
|
||||
// sit where a near one would be.
|
||||
d++;
|
||||
continue;
|
||||
}
|
||||
const uint32_t id = bucket.back();
|
||||
|
||||
Reference in new issue
Block a user