Repository navigation
ida_star: stop looping forever when the goal is unreachable - #93
Open
ducduong97hn wants to merge 1 commit into
Open
ducduong97hn wants to merge 1 commit into
ducduong97hn wants to merge 1 commit into
Conversation
find_path()'s loop only exited early on "isinstance(t, bool) and not t", but search() never returns a bool: it only ever returns a float or a Node. That branch is dead code, so the only way out of the loop was finding the goal. With the default time_limit and max_runs (both infinite), a genuinely unreachable goal made find_path() grow cutoff and re-search forever. search() already returns +inf at the top when every reachable node has been tried down to a true dead end (no remaining neighbors) without any of them exceeding the cutoff: that case means the whole reachable area has been searched and the goal was not in it, so no cutoff increase will ever find it. Check for that instead and return an empty path. Added a regression test for this case. Not fully verified end-to-end against the exact repro in brean#92 (an open map) with a running interpreter; I confirmed the dead code and the infinite-loop mechanism by reading search()/find_path() and traced the +inf exhaustion case by hand, but could not execute pytest in this environment to check the open-map case runs quickly too, or run the existing test suite to confirm nothing else regresses. Fixes brean#92
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_path()'s loop only exited early onisinstance(t, bool) and not t, butsearch()never returns abool— it only ever returns afloator aNode. That branch is dead code, so the only way out of the loop was finding the goal. With the defaulttime_limitandmax_runs(both infinite), a genuinely unreachable goal madefind_path()growcutoffand re-search forever.search()already returns+infat the top level when every reachable node has been tried down to a true dead end (no remaining neighbors) without any of them exceeding the cutoff — that case means the whole reachable area has been searched and the goal was not in it, so no cutoff increase will ever find it. This checks for that instead of the deadisinstance(t, bool)branch, and returns an empty path.Added a regression test for an isolated goal (
[[1, 0, 1]], no diagonal movement), with its owntime_limit=10as a safety net in case the fix is ever lost again.What I verified, and what I didn't: I traced the dead-code path and the
+infexhaustion case by readingsearch()/find_path()by hand, and I'm confident in the mechanism. I could not runpytestin the environment I wrote this in, so I have not executed the new test or the existing suite (test_path.pyin particular, since it already runsIDAStarFinderthroughpath_test_scenarios.jsonwithtime_limit=10) to confirm nothing regresses. I'd appreciate a CI run or a local check before merging.I also wasn't able to reproduce the exact repro in #92 (a fully open map, which should be reachable) to confirm this is the complete explanation for that report rather than a related-but-separate issue — happy to dig further if the fix alone doesn't resolve it there.
Fixes #92