Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate IDFSearch when two consecutive depths reach the same number of moves #94

Open
lgarron opened this issue Jan 13, 2025 · 8 comments
Labels
enhancement New feature or request rust

Comments

@lgarron
Copy link
Member

lgarron commented Jan 13, 2025

This can help prevent infinite search in situations where a solution was provided but the state space is small enough to enumerate during normal search.

@lgarron lgarron added enhancement New feature or request rust labels Jan 13, 2025
@lgarron lgarron changed the title Terminate IDFSearch when two depths reach the same number of moves Terminate IDFSearch when two consecutive depths reach the same number of moves Jan 13, 2025
@ArhanChaudhary
Copy link

A little unrelated, but shouldn't this be called IDAStarSearch or something similar? Iterative deepening search with pruning tables is IDA*, right?

@lgarron
Copy link
Member Author

lgarron commented Jan 14, 2025

A little unrelated, but shouldn't this be called IDAStarSearch or something similar? Iterative deepening search with pruning tables is IDA*, right?

I don't know that we have enough heuristics in place to qualify as A*? @rokicki probably knows more.

@rokicki
Copy link
Collaborator

rokicki commented Jan 15, 2025 via email

@ArhanChaudhary
Copy link

A little unrelated, but shouldn't this be called IDAStarSearch or something similar? Iterative deepening search with pruning tables is IDA*, right?

I don't know that we have enough heuristics in place to qualify as A*? @rokicki probably knows more.

@rokicki and I talked about this some time earlier, and we concluded that the IDA* was indeed the correct terminology for what C++ twsearch uses (see https://cubing-org.slack.com/archives/CKD5E53A4/p1737658381579609). Is there any specific reason why Rust twsearch uses IDFS instead of IDA*? Your HashPruningTable implementation does give a lower bound, which makes IDA* applicable.

@lgarron
Copy link
Member Author

lgarron commented Feb 21, 2025

Is there any specific reason why Rust twsearch uses IDFS instead of IDA*?

Yes, the reason cited above. It was named before you and @rokicki talked. :P

Additionally, the IDFS struct can take a non-trivial prune table as a SearchAdaptation and does so for KPuzzle by default, but it doesn't have to. So it is in fact only in charge of the DFS with iterative deepeding.

@ArhanChaudhary
Copy link

Is there any specific reason why Rust twsearch uses IDFS instead of IDA*?

Yes, the reason cited above. It was named before you and @rokicki talked. :P

Additionally, the IDFS struct can take a non-trivial prune table as a SearchAdaptation and does so for KPuzzle by default, but it doesn't have to. So it is in fact only in charge of the DFS with iterative deepeding.

Sorry, let me be more specific in what I mean. Rust twsearch seems to do the recursive step of IDA*.

if prune_table_depth > remaining_depth {

This matches the IDA* wikipedia's pseudocode:

function search(path, g, bound)
    node := path.last
    f := g + h(node)
    if f > bound then return f

So that seems to be fine and dandy. However, Rust twsearch does not seem to relay the minimum heuristic information upstream:

for remaining_depth in *individual_search_data

Once again from wikipedia's pseudocode:

procedure ida_star(root)
    bound := h(root)
    path := [root]
    loop
        t := search(path, 0, bound)
        if t = FOUND then return (path, bound)
        if t = ∞ then return NOT_FOUND
        bound := t
    end loop
end procedure

I brought my above concern above specifically because of this observation. I interpreted the code as just a slightly faster version of IDFS rather then IDA*, hence why I proclaimed that in the above.

@lgarron
Copy link
Member Author

lgarron commented Feb 23, 2025

If the the code were implemented from an algorithm or spec, I suspect we would have more meaningful answers to your questions.

But there is a lot of design work in that code to be done, and therefore a lot of missing features.

If you want to tackle passing up the heuristic feel free, else I'm not sure when we'd have time to get to experimenting with it.

@rokicki
Copy link
Collaborator

rokicki commented Feb 23, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rust
Projects
None yet
Development

No branches or pull requests

3 participants