At1uri's picture
Upload folder using huggingface_hub
be4df46 verified
|
Raw History Blame Contribute Delete
5.57 kB
---
title: Quantum Portfolio Optimization Studio
emoji: ⚛️
colorFrom: purple
colorTo: blue
sdk: static
pinned: false
tags:
- quantum-computing
- qaoa
- vqe
- ising-hamiltonian
- qubo
- portfolio-optimization
- quantitative-finance
short_description: Quantum VQE and QAOA Ising Hamiltonian portfolio optimizer.
---
# Quantum Portfolio Optimization Studio
An interactive, client-side, research-grade quantum computational engine for solving NP-hard cardinality-constrained portfolio optimization and combinatorial arbitrage problems via **Variational Quantum Eigensolver (VQE)** and **Quantum Approximate Optimization Algorithm (QAOA)**.
## 1. Theoretical Formulation & Hamiltonian Mapping
Markowitz mean-variance optimization with cardinality constraints and transaction penalties is mapped to a Quadratic Unconstrained Binary Optimization (QUBO) problem:
$$\min_{\mathbf{x} \in \{0, 1\}^n} \mathcal{C}(\mathbf{x}) = q \, \mathbf{x}^T \boldsymbol{\Sigma} \mathbf{x} - \boldsymbol{\mu}^T \mathbf{x} + \lambda_{\text{budget}} \left(\sum_{i=1}^n x_i - K\right)^2$$
where:
- $\mathbf{x} \in \{0, 1\}^n$ is the binary asset selection vector,
- $\boldsymbol{\Sigma} \in \mathbb{R}^{n \times n}$ is the asset return covariance matrix,
- $\boldsymbol{\mu} \in \mathbb{R}^n$ is the expected asset return vector,
- $q \ge 0$ is the investor risk-aversion coefficient,
- $K \in \{1, \dots, n\}$ is the target cardinality (number of selected assets),
- $\lambda_{\text{budget}} > 0$ is the quadratic penalty enforcing the exact cardinality constraint.
### Mapping to the Ising Spin Glass Model
Using the Jordan-Wigner / spin-1/2 mapping $x_i = \frac{I - \sigma_i^z}{2}$ where $\sigma_i^z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}$ is the Pauli-$Z$ operator:
$$\mathcal{H}_C = \sum_{i=1}^n h_i \sigma_i^z + \sum_{1 \le i < j \le n} J_{ij} \sigma_i^z \sigma_j^z + C_{\text{offset}} \cdot I$$
The local longitudinal magnetic field $h_i$ and the exchange coupling $J_{ij}$ are derived analytically:
$$h_i = -\frac{1}{2} \mu_i + q \sum_{k \neq i} \Sigma_{ik} + \frac{q}{2} \Sigma_{ii} + \lambda_{\text{budget}} (1 - K)$$
$$J_{ij} = \frac{q}{4} \Sigma_{ij} + \frac{\lambda_{\text{budget}}}{2}$$
$$C_{\text{offset}} = \sum_{i} \left(\frac{q}{4}\Sigma_{ii} - \frac{1}{2}\mu_i\right) + \sum_{i < j} \left(\frac{q}{4}\Sigma_{ij} + \frac{\lambda_{\text{budget}}}{2}\right) + \lambda_{\text{budget}} K^2$$
---
## 2. Quantum Algorithms
### A. Quantum Approximate Optimization Algorithm (QAOA)
QAOA initializes $n$ qubits in an equal superposition state:
$$|+\rangle^{\otimes n} = \frac{1}{\sqrt{2^n}} \sum_{x \in \{0, 1\}^n} |x\rangle$$
Applying $p$ alternating unitary layers parameterized by angles $(\boldsymbol{\gamma}, \boldsymbol{\beta}) \in \mathbb{R}^{2p}$:
$$|\boldsymbol{\gamma}, \boldsymbol{\beta}\rangle = \prod_{l=1}^p U_B(\beta_l) \, U_C(\gamma_l) \, |+\rangle^{\otimes n}$$
where:
- **Cost Unitary**: $U_C(\gamma_l) = e^{-i \gamma_l \mathcal{H}_C} = \prod_i e^{-i \gamma_l h_i \sigma_i^z} \prod_{i < j} e^{-i \gamma_l J_{ij} \sigma_i^z \sigma_j^z}$
- **Mixer Unitary**: $U_B(\beta_l) = e^{-i \beta_l \mathcal{H}_M} = \prod_{i=1}^n e^{-i \beta_l \sigma_i^x} = \prod_{i=1}^n R_x(2\beta_l)_i$
The expectation value is minimized via a classical-quantum hybrid loop:
$$\min_{\boldsymbol{\gamma}, \boldsymbol{\beta}} \langle \mathcal{H}_C \rangle = \langle \boldsymbol{\gamma}, \boldsymbol{\beta} | \mathcal{H}_C | \boldsymbol{\gamma}, \boldsymbol{\beta} \rangle$$
### B. Variational Quantum Eigensolver (VQE)
VQE prepares a parameterized ansatz $|\psi(\boldsymbol{\theta})\rangle$ using a hardware-efficient circuit:
1. Layer of single-qubit rotations $R_y(\theta_{i, 0}) = \exp(-i \frac{\theta_{i,0}}{2} \sigma_i^y)$.
2. Entanglement layer using CNOT or Controlled-Z ($CZ$) gates across linear or full topologies.
3. Repetition for depth $d \ge 1$.
By the Rayleigh-Ritz variational principle:
$$\langle \mathcal{H}_C \rangle_{\boldsymbol{\theta}} = \frac{\langle \psi(\boldsymbol{\theta}) | \mathcal{H}_C | \psi(\boldsymbol{\theta}) \rangle}{\langle \psi(\boldsymbol{\theta}) | \psi(\boldsymbol{\theta}) \rangle} \ge E_0$$
where $E_0$ is the exact ground-state energy corresponding to the globally optimal portfolio bitstring $x^*$.
---
## 3. Quantum State Diagnostics
- **Bipartite Von Neumann Entanglement Entropy**:
$$S(\rho_A) = -\text{Tr}(\rho_A \log_2 \rho_A) = -\sum_{k} \lambda_k \log_2 \lambda_k$$
measures non-classical correlations synthesized by entangling gates.
- **Single-Qubit Bloch Vector Coordinates**:
$$\mathbf{r}_i = (\langle \sigma_i^x \rangle, \langle \sigma_i^y \rangle, \langle \sigma_i^z \rangle) = (\text{Tr}(\rho_i \sigma^x), \text{Tr}(\rho_i \sigma^y), \text{Tr}(\rho_i \sigma^z))$$
- **Approximation Ratio**:
$$\alpha = \frac{\langle \mathcal{H}_C \rangle - E_{\max}}{E_0 - E_{\max}} \in [0, 1]$$
---
## 4. Architecture & Capabilities
- **Zero-Latency In-Browser Simulator**: Full $2^n$-dimensional complex statevector $\in \mathbb{C}^{2^n}$ matrix-vector algebra implemented directly in client-side JavaScript.
- **Exact Classical Ground State Reference**: Brute-force evaluates all $2^n$ basis states to compute the global optimum and verify quantum convergence.
- **Interactive Multi-Qubit Visualizations**:
- Live energy landscape and variational optimization trajectory.
- Quantum measurement probability distribution $|\langle x | \psi \rangle|^2$.
- Bloch Sphere vector coordinates per qubit.
- Real-time bipartite entanglement entropy curve.
- Quantum circuit schematic visualizer.