A Streamlit demo that compares a quantum-inspired search heuristic with classical gradient descent on a non-convex optimization landscape.
This project optimizes the 1D Rastrigin function, a standard benchmark with many local minima. It compares:
- a quantum-inspired particle search with annealed tunneling noise
- classical gradient descent
The app visualizes:
- the energy landscape
- optimizer convergence over time
- a particle cloud snapshot from the quantum-inspired search
The quantum-inspired optimizer does not perform real quantum computation. Instead, it borrows the intuition of tunneling and annealing:
- keep many candidate positions at once
- perturb them with random jumps
- shrink jump size over time
- keep moves that improve the objective
This makes it a heuristic search demo for escaping poor local regions better than naive local methods in some cases.
app.py: Streamlit app and experiment dashboardoptimizer/quantum_inspired.py: particle-based heuristic optimizeroptimizer/classical.py: gradient descent baselineutils/landscapes.py: Rastrigin function and gradientutils/visualization.py: Matplotlib plotting helpersrequirements.txt: project dependencies
The project uses the 1D Rastrigin function:
f(x) = A + (x^2 - A * cos(2 * pi * x))
This function is useful because it has many local minima and is harder to optimize than a simple convex bowl.
The quantum-inspired optimizer:
- initializes many particles across the search space
- applies Gaussian tunneling noise to each particle
- scales tunneling by an annealing schedule
- keeps a candidate if it improves objective value
- tracks the best particle each step
Outputs include:
- best solution found
- best-energy history
- particle history over time
Gradient descent starts from one random point and repeatedly moves opposite the gradient using a configurable learning rate.
The Streamlit interface shows:
- final energy for both methods
- the optimization landscape
- convergence comparison
- a mid-run particle snapshot
- Python 3.10+
- pip
Install dependencies:
pip install -r requirements.txtStart the app:
streamlit run app.pyThe UI allows you to tune:
- optimization steps
- number of particles
- gradient descent learning rate
- tunneling strength
This project is useful as a compact demo of:
- heuristic optimization
- annealing-style search
- local minima problems
- optimizer comparison in a visual interface
- only a 1D objective is used
- the quantum-inspired method is a heuristic, not quantum computing
- there is no statistical benchmark over repeated runs
- the comparison is against a simple gradient descent baseline only
- add more benchmark functions
- support higher-dimensional optimization
- compare with simulated annealing and particle swarm optimization
- run repeated trials with summary statistics
- visualize full particle trajectories
- Python
- Streamlit
- NumPy
- Matplotlib
- SciPy
Quantum-Inspired AI Optimizer is a visual optimization playground that shows how a tunneling-style search heuristic behaves against classical gradient descent on a rugged objective landscape.