Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamcrume/robust-binary-search
Robust Binary Search provides a binary search implementation which is robust against errors during the search.
https://github.com/adamcrume/robust-binary-search
Last synced: about 2 months ago
JSON representation
Robust Binary Search provides a binary search implementation which is robust against errors during the search.
- Host: GitHub
- URL: https://github.com/adamcrume/robust-binary-search
- Owner: adamcrume
- License: apache-2.0
- Created: 2020-10-24T03:33:05.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-17T03:53:45.000Z (over 1 year ago)
- Last Synced: 2024-07-17T22:53:54.728Z (2 months ago)
- Language: Rust
- Size: 73.2 KB
- Stars: 42
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Robust Binary Search
Robust Binary Search provides a binary search implementation which is robust against errors during
the search. In other words, if the comparison function sometimes returns an incorrect result, the
search in this project will still converge on the correct solution.This is adapted from the multiplicative weights algorithm in ["Noisy binary search and its
applications" by Karp and Kleinberg](https://www.cs.cornell.edu/~rdk/papers/karpr2.pdf), with
adjustments to make it deterministic and then extended to support directed acyclic graphs.## Usage
To use the git bisect replacement, install with `cargo install robust-git-bisect`, and then
`~/.cargo/bin/robust-git-bisect $start_commit $end_commit $command_to_test_commit`For library usage, see `AutoSearcher` for binary search over a linear range and
`AutoCompressedDAGSearcher` for binary search over a graph.## Performance
This code is optimized to minimize the number of tests executed (i.e. number of iterations) and not
necessarily the CPU time of the search algorithm itself, so this will be slower than a plain binary
search if the test is deterministic.The linear algorithm (`Searcher` and `AutoSearcher`) takes approximately `O(log N)` time per
iteration. The graph algorithm (`CompressedDAGSearcher` and `AutoCompressedDAGSearcher`) takes
approximately `O(segments)` time per iteration.robust-git-bisect shows improved performance compared with git bisect (higher accuracy with fewer
iterations):Method | Iterations | Accuracy
---------------------------------- | ---------- | --------
robust-git-bisect with 0.99 target | 29.6558 | 99.5392%
robust-git-bisect with 0.9 target | 26.1828 | 98.8950%
git bisect | 16.1907 | 31.7972%
git bisect with tests repeated | 35.0465 | 86.6359%
git bisect repeated | 72.3674 | 86.1751%This test is run over the `git` git repo from e83c516331 to 54e85e7af1, simulating 9c3592cf3c as the
bad commit, with a test that returns an incorrect result 5% of the time. See benchmark.rs for
details.