Skip to content

Dharani-R-S/quantum_optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum-Inspired AI Optimizer

A Streamlit demo that compares a quantum-inspired search heuristic with classical gradient descent on a non-convex optimization landscape.

What It Does

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

Core Idea

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.

Project Structure

  • app.py: Streamlit app and experiment dashboard
  • optimizer/quantum_inspired.py: particle-based heuristic optimizer
  • optimizer/classical.py: gradient descent baseline
  • utils/landscapes.py: Rastrigin function and gradient
  • utils/visualization.py: Matplotlib plotting helpers
  • requirements.txt: project dependencies

How It Works

1. Objective Function

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.

2. Quantum-Inspired Optimizer

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

3. Classical Baseline

Gradient descent starts from one random point and repeatedly moves opposite the gradient using a configurable learning rate.

4. Visualization

The Streamlit interface shows:

  • final energy for both methods
  • the optimization landscape
  • convergence comparison
  • a mid-run particle snapshot

Running The App

Requirements

  • Python 3.10+
  • pip

Install dependencies:

pip install -r requirements.txt

Start the app:

streamlit run app.py

Controls

The UI allows you to tune:

  • optimization steps
  • number of particles
  • gradient descent learning rate
  • tunneling strength

What This Project Demonstrates

This project is useful as a compact demo of:

  • heuristic optimization
  • annealing-style search
  • local minima problems
  • optimizer comparison in a visual interface

Current Limitations

  • 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

Future Improvements

  • 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

Tech Stack

  • Python
  • Streamlit
  • NumPy
  • Matplotlib
  • SciPy

Summary

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.

About

Quantum-inspired optimization demo that compares tunneling-style search with gradient descent on a non-convex landscape.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages