grovers-visualizer/README.md

90 lines
1.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Grovers Search Visualizer
A tiny Python package that steps through Grovers Search algorithm and shows you, after each iteration:
- A barchart of amplitudes (or probabilities)
- A sinecurve of successprobability vs. iteration
- A geometric "rotation" on the unit circle
Choose between a Matplotlib-based CLI or an optional DearPyGui GUI (WIP).
---
![Demo of Grovers Visualizer](media/demo.gif)
---
## Installation
### Via [pipx](https://pipx.pypa.io/stable/installation/)
Basic (CLI only):
```bash
pipx install grovers-visualizer
grovers-visualizer 1111
```
With the optional DearPyGui UI (WIP):
```bash
pipx "grovers-visualizer[ui]"
grovers-visualizer --ui
```
### Via [uvx](https://docs.astral.sh/uv/guides/tools/)
Basic (CLI only):
```bash
uvx grovers-visualizer 1111
```
With the optional UI extra:
```bash
uvx "grovers-visualizer[ui]" --ui
```
---
## Usage
### CLI Mode
Flags:
- `TARGET`
Target bitstring (e.g. `010`). Length determines number of qubits.
- `-s, --speed SPEED`
Delay between iterations (seconds). Default `0.5`.
- `-i, --iterations ITERATIONS`
Max iterations; `0` means use the optimal $\lfloor\frac\pi4\sqrt{2^n}\rfloor$.
- `-p, --phase PHASE`
The phase $\psi$ (in radians) used for both the oracle and diffusion steps. Defaults to $\pi$ (i.e. a sign-flip, $e^{i\pi}=-1$).
- `--ui`
Launch the optional DearPyGui GUI (requires the `[ui]` extra) (WIP).
### GUI Mode (WIP)
If you installed with `"[ui]"`, launch the DearPyGui window:
```
grovers-visualizer --ui
```
In the UI you can:
- Set number of qubits
- Enter the target bitstring
- Choose max iterations or leave at 0 for optimal
- Control the animation speed
Hit **Start** to watch the bar chart, sine plot, and rotationcircle update in real time.
---
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.