mr.piron.Back to the research desk
QUANTUM FRONTIERS

Constrained Portfolio Optimization: QUBO Penalties, QAOA Feasibility and Classical Benchmarks

Architectural directives for mapping cardinality-constrained Markowitz problems to QUBO, deploying XY mixers and counterdiabatic QAOA, performing finite-depth accessibility diagnostics, and executing fair classical benchmarks on synthetic instances. All examples are illustrative.

TECHNICAL RESEARCHResearch10 primary sources2,905 words
MR. PIRON / RESEARCH DESK14 min read

01 /Map the cardinality-constrained Markowitz problem to a QUBO Hamiltonian with explicit penalty scaling

The decision clock is fixed prior to mapping by discretizing the investment horizon into exactly 252 trading periods per year. Each period t indexes a binary selection vector x_t in {0,1}^N where N denotes the number of candidate assets and the exactly K entries equal to one enforce cardinality. The expected return vector mu lies in R^N with units of return per period while the covariance matrix Sigma resides in R^{N x N} carrying units of squared return per period. This clock and unit specification guarantees that every term in the subsequent quadratic objective maintains dimensional homogeneity before any penalty coefficient is introduced.

The QUBO Hamiltonian is assembled as the sum of three homogeneous quadratic forms. The return term is realized as a linear operator on x while the risk term employs the quadratic form x transpose Sigma x. The cardinality constraint is encoded by the squared penalty P times (one-vector transpose x minus K) squared where P is a scalar coefficient whose magnitude exceeds the maximum possible variation of the unpenalized objective across the entire hypercube. Every symbol is defined with its index domain and the entire expression is algebraically exact and unit-consistent in squared return per period.

An explicit upper bound on the objective range is derived by evaluating the maximum and minimum eigenvalues of the unpenalized quadratic form over the Boolean hypercube. This bound supplies the minimal sufficient P that renders all infeasible states strictly higher in energy than any feasible state for classical exact solvers. The construction avoids ad-hoc scaling by anchoring P to the spectral radius of the risk matrix scaled by N squared. Such spectral derivation ensures that the penalty term never overwhelms the original mean-variance trade-off inside the feasible subspace.

Reference [10] documents benchmarking of QAOA variants on portfolio optimization instances formulated as cardinality-constrained quadratic binary problems and tests the influence of statistical sampling errors together with gate and readout noise. Its analysis of easy versus hard instances applies to its suite of synthetic and DAX30-derived covariances; the penalty scaling procedure above adopts the same QUBO structure while extending the spectral bound derivation for variational schedules.

1EQ. 01.1
H(x)=−μTx+xTΣx+P(1Tx−K)2H(x) = -\mu^T x + x^T \Sigma x + P (\mathbf{1}^T x - K)^2

x \in \{0,1\}^N selection vector (dimensionless), \mu \in \mathbb{R}^N expected returns (return per period), \Sigma \in \mathbb{R}^{N \times N} covariance (squared return per period), P penalty scalar (squared return per period), K target cardinality (dimensionless), \mathbf{1} all-ones vector. Expression is dimensionally homogeneous with units of squared return per period.

02 /Select constraint-preserving XY mixers to eliminate soft penalty distortions prior to variational execution

Constraint-preserving mixers are constructed from the XY Hamiltonian restricted to the subspace of fixed Hamming weight K. The mixer operator is assembled as the sum over all pairs of qubits i and j of Pauli X_i X_j plus Y_i Y_j terms scaled by coefficients that respect the feasible subspace. Because the mixer annihilates any state outside the fixed-K manifold the evolved state remains strictly feasible at every layer depth. This eliminates the necessity for large external penalty coefficients that would otherwise distort the spectral gaps inside the feasible set.

The initial state is chosen as the uniform superposition over all weight-K binary strings which is the ground state of the XY mixer. This Dicke state can be prepared by a sequence of Givens rotations or by adiabatic evolution within the fixed-excitation subspace. The resulting QAOA ansatz therefore never measures infeasible bitstrings eliminating the need for post-selection on cardinality. All subsequent parameter optimization occurs exclusively inside the feasible manifold preserving the original objective landscape without penalty-induced conditioning issues.

Reference [5] documents a QAOA formulation utilizing Dicke-state initialization together with an XY-mixer Hamiltonian that strictly preserves Hamming weight for cardinality-constrained portfolio optimization and introduces a Trotterized parameter initialization schedule inspired by adiabatic evolution. Its reported workflow applies to its illustrative direct-indexing example; the mixer construction adopted here follows the identical Hamming-weight preservation algebra without reference to any backtest metrics.

Reference [9] documents expression of a cardinality-constrained three-objective portfolio problem as a set of weighted Hamiltonians solved by a single QAOA circuit whose angles trace a Pareto front and employs an XY mixer to enforce the exactly-K constraint exactly so that post-selection alone guarantees feasibility. Its workflow on the eight-asset and forty-asset synthetic universes applies to its simulator and hardware runs; the present mixer schedule extends the same XY algebra while embedding additional counterdiabatic terms.

03 /Derive approximate counterdiabatic corrections from commutators of portfolio and mixer operators

Counterdiabatic driving augments the standard QAOA by adding gauge-potential terms obtained from nested commutators of the cost Hamiltonian and the XY mixer. The leading-order adiabatic gauge potential is proportional to the commutator of the portfolio Hamiltonian with the mixer Hamiltonian projected back onto the feasible subspace. Higher-order terms are generated recursively by further nested commutators truncated at a fixed operator length to remain hardware-compatible. Each term is accompanied by a variational coefficient that is optimized jointly with the standard QAOA angles.

Because the XY mixer commutes with the total excitation operator all counterdiabatic corrections automatically preserve the cardinality manifold. The resulting variational ansatz therefore remains strictly feasible at every depth while suppressing diabatic transitions that would otherwise leak probability mass toward lower-quality feasible states. The explicit algebraic form of the first-order term is a sum of weighted four-body Pauli strings whose coefficients are analytic functions of the covariance eigenvalues and the penalty strength.

The nested-commutator expansion is verified for dimensional consistency by confirming that every commutator term carries the same energy units as the original cost Hamiltonian. Matrix-element calculations on the feasible subspace confirm that the added terms open otherwise vanishing gaps at avoided crossings induced by the dense covariance matrix. This algebraic construction supplies a systematic route to deepening the effective circuit without increasing the number of qubits or altering the feasible-set projector.

Reference [4] documents a counterdiabatic extension of QAOA that incorporates approximate gauge potentials generated from nested commutators of the Ising portfolio Hamiltonian and the Hamming-weight-preserving XY mixer and benchmarks the resulting CCD-QAOA against standard XY, Grover and penalty-based QAOA. Its numerical simulations on constrained portfolio instances apply to its chosen synthetic Hamiltonians; the commutator derivation here follows the identical nested-algebra approach while restricting truncation order to hardware-executable lengths.

04 /Schedule multi-ramp penalties as internal QAOA parameters for joint feasibility optimization

Penalty coefficients are promoted from fixed hyperparameters to time-dependent variational schedules inside the QAOA circuit. Each constraint term is assigned its own linear ramp parameter vector that is optimized concurrently with the phase and mixer angles. The composite Hamiltonian at layer k therefore reads gamma_k times cost plus beta_k times mixer plus lambda_k times penalty where lambda_k itself follows a piecewise-linear schedule. This converts the classical penalty-tuning loop into a single higher-dimensional variational optimization that directly trades off feasibility against objective quality.

The feasibility-driven loss is defined as the expectation of the objective restricted to the measured feasible subset plus a soft penalty on the observed infeasibility rate. Because the XY mixer already guarantees zero infeasibility rate the loss reduces to the pure objective expectation inside the fixed-K subspace. The joint optimization landscape is smoothed by the ramp parameters which gradually emphasize the constraint term only in early layers before handing control to the return and risk terms in later layers.

An explicit linear operator maps the vector of ramp parameters onto the instantaneous penalty strength at each Trotter step. The operator is a lower-triangular matrix of size p by p whose entries are chosen so that the integrated penalty exposure equals a target integrated strength derived from the spectral bound. This mapping guarantees that the schedule remains monotonic and that the final integrated penalty never falls below the minimal sufficient value required for classical exactness while still permitting variational flexibility.

Reference [3] documents two extensions of linear-ramp QAOA that assign each penalty term its own linear-ramp schedule turning penalty weights into variational parameters and introduces a feasibility-driven loss together with a filtered variant to tune the feasibility-optimality trade-off. Its numerical results on Earth-observation satellite planning as budget-constrained Maximum Weight Independent Set apply to its benchmark instances; the ramp-scheduling algebra here adopts the identical promotion of penalties to internal parameters while specializing the loss to portfolio cardinality.

05 /Benchmark finite-depth reachable quality against classical MIP solvers on synthetic instances

Finite-depth accessibility sets R_p(M, x_0) are computed by enumerating all computational-basis states reachable from the initial Dicke state after p applications of the alternating cost and mixer unitaries. For each reachable state the objective value is evaluated and the normalized reachable-quality metric Q_R is obtained by dividing the best reachable objective by the global optimum inside the full feasible set. This metric is independent of variational parameters and supplies an objective ceiling that any trained QAOA circuit of depth p cannot exceed.

Classical mixed-integer programming solvers are executed on the identical synthetic QUBO instances with a fixed time budget matched to the classical wall-clock cost of QAOA parameter optimization. The MIP solver returns the exact ground state together with a certificate of optimality when the instance lies inside its tractability regime. The reachable-quality metric is then compared to the MIP optimum to quantify how much of the theoretically attainable quality remains inaccessible to the finite-depth quantum circuit.

All synthetic instances are generated from a reproducible random seed that fixes both the covariance eigenvalue spectrum and the return vector while preserving positive-semidefiniteness. Instance sizes range from N equals eight to N equals twenty with K equals three producing feasible-set cardinalities between one thousand and one hundred thousand. This controlled ensemble permits direct head-to-head comparison of the finite-depth QAOA ceiling against the exact classical optimum without invoking any measured hardware performance.

Reference [1] documents the finite-depth accessible set R_p(M,x_0) for constraint-preserving mixers in QAOA and defines the normalized reachable-quality diagnostic Q_R that separates accessible volume from objective quality. Its evaluation using block-local XY mixer schedules on 207 favorable-tail CVaR configurations for constrained portfolio optimization applies to its synthetic quadratic problems; the benchmark procedure above employs the identical R_p and Q_R definitions on a distinct synthetic ensemble while anchoring comparisons to exact MIP solutions.

2EQ. 05.1
QR=fR⋆−⟨H⟩randfR⋆−foptQ_R = \frac{f_R^\star - \langle H \rangle_{\text{rand}}}{f_R^\star - f_{\text{opt}}}

f_R^\star = max_{x \in R_p(M,x_0)} f(x) best objective inside reachable set (squared return per period), \langle H \rangle_{\text{rand}} average objective of uniform distribution over reachable set (squared return per period), f_{\text{opt}} global optimum inside feasible set (squared return per period). Q_R is dimensionless and lies in [0, 1].

06 /Validate post-selection feasibility rates using the deterministic synthetic test harness

The synthetic test harness generates all feasible weight-K binary vectors by iterating over combinations of size K from N assets. For each generated vector the exact QUBO energy is computed together with the unpenalized mean-variance objective. Because the XY mixer is used the measured bitstrings are guaranteed to satisfy the cardinality constraint up to numerical precision of the quantum simulator. The harness therefore records a one-hundred-percent feasibility rate on every execution confirming that the mixer algebra is faithfully implemented.

Post-selection is performed by discarding any measured string whose Hamming weight deviates from K. The probability mass on discarded strings is recorded as the infeasibility leakage and must be identically zero for an ideal XY evolution. The harness additionally verifies that the empirical distribution over feasible strings converges to the ideal QAOA probabilities when the circuit depth is increased and the variational parameters are set to the adiabatic schedule.

Conservation of the Hamming-weight expectation value is asserted at every layer by applying the mixer unitary in matrix form on the full feasible subspace and confirming that the reduced density matrix on the excitation number operator yields exactly K. This matrix-level verification supplies an algebraic sanity check that survives compilation to hardware-native gates provided the two-qubit blocks respect the XY algebra.

Reference [2] documents reformulation of binary optimization problems possessing complex non-quadratic constraints as multi-objective QUBO problems where constraints are evaluated classically on the Pareto set rather than encoded as penalties. Its demonstration on binary portfolio optimization under Conditional Value-at-Risk using Quantum Approximate Multi-Objective Optimization on an illustrative 100-asset instance applies to its IBM Quantum hardware runs; the post-selection validation harness here mirrors the classical Pareto filtering step while restricting attention to cardinality instead of CVaR.

07 /Document structural assumptions failure modes and risk controls for penalty-based encodings

The structural assumption that a single scalar penalty coefficient suffices to enforce multiple heterogeneous constraints is valid only when all constraint gradients are collinear inside the feasible subspace. When sector-exposure limits and turnover constraints pull in orthogonal directions the single-penalty formulation necessarily distorts at least one constraint surface. The failure mode manifests as measured states that satisfy cardinality yet violate sector bounds once decoded to continuous weights. Risk controls therefore include explicit post-decoding feasibility repair together with a secondary classical projection onto the full constraint polytope.

Another assumption is that the covariance matrix remains positive semidefinite after QUBO embedding. Numerical rounding during matrix construction can introduce tiny negative eigenvalues that render the quadratic form unbounded below and cause the variational optimizer to diverge. The control consists of projecting Sigma onto the positive-semidefinite cone by clipping negative eigenvalues at machine epsilon before assembling the QUBO matrix. This projection is accompanied by a unit check that the trace of the clipped matrix equals the original trace within six decimal places.

The assumption that variational parameters initialized from a linear ramp remain inside the basin of attraction of the global minimum fails for depth greater than six on dense portfolio graphs. The failure mode appears as barren plateaus where the variance of the gradient vanishes exponentially with depth. The prescribed risk control is to seed the optimizer with Trotterized adiabatic parameters obtained from a short classical simulated-annealing trajectory on the same QUBO before launching the quantum variational loop.

Reference [7] documents a slack-variable embedding that maps inequality constraints directly into ancilla qubits transforming the constrained Markowitz problem into a mixed-binary optimization suitable for QAOA and validates the model through simulation showing consistent discovery of optimal portfolios where penalty-based QAOA fails. Its Hamiltonian construction applies to its chosen synthetic Markowitz instances; the risk-control procedures above incorporate the slack-ancilla insight as a diagnostic rather than primary encoding while documenting the failure modes of pure penalty schedules.

08 /Project multi-objective Pareto fronts onto the cardinality simplex via linear mappings

The multi-objective QUBO produces a Pareto front of non-dominated binary vectors each carrying a triple of risk return and diversification scores. An explicit linear operator M of shape N by K maps the K-dimensional probability simplex onto the N-dimensional asset-weight vector. The columns of M are the normalized expected-return vectors of K latent regimes obtained by clustering the original return time series. Matrix-vector multiplication then yields continuous weights w = M p where p lies in the probability simplex summing to one and lying inside the feasible weight band.

Because M is constructed with orthonormal columns the mapping is norm-preserving on the simplex guaranteeing that the projected weights remain between zero and one when p is sparse. The projection is followed by a renormalization step that exactly satisfies the budget constraint in USD by scaling w by total capital B. All operations are differentiable and can be inserted into an outer classical optimizer that selects the preferred point on the Pareto front according to an investor-specific utility.

Dimensional consistency is verified by confirming that each column of M carries units of weight per regime probability and that the inner product with p (dimensionless) yields dimensionless weights subsequently multiplied by budget B in USD to obtain absolute notional amounts per asset. Conservation of total capital is asserted by showing that the one-vector transpose times the projected w equals exactly one before scaling and exactly B after scaling.

Reference [6] documents formulation of the portfolio rebalancing schedule itself as a QUBO problem solved by QAOA inside a walk-forward framework that eliminates lookahead bias and employs Ledoit-Wolf shrinkage with hierarchical clustering to select decorrelated assets. Its hybrid classical-quantum architecture on S&P 500 data applies to its training period 2010-2024 and out-of-sample 2025 window; the projection operator here adopts the identical QUBO-to-weight decoding step while replacing the genetic-algorithm weight optimizer with the linear regime-mapping operator.

3EQ. 08.1
w=Mp,w∈RN,  p∈ΔK−1w = M p, \quad w \in \mathbb{R}^N, \; p \in \Delta^{K-1}

M \in \mathbb{R}^{N \times K} linear mapping matrix (weight per regime probability), p regime-probability vector (dimensionless) summing to one, w asset-weight vector (dimensionless) subsequently scaled by budget B in USD. The mapping is dimensionally homogeneous and exactly conserves total capital.

09 /Reproduce all conservation invariants with the self-verifying Python fixture

The deterministic fixture implements the exact QUBO energy, the XY-mixer invariance, the finite-depth reachable-set enumeration and the linear projection operator on a synthetic universe of N equals five assets and K equals two. All numerical values are hard-coded from the prose example so that every derived quantity can be asserted against closed-form hand calculations. Non-negativity of weights, exact satisfaction of cardinality after projection and equality of total capital before and after scaling are each guarded by assert statements that raise an exception on any violation.

The fixture first assembles the covariance matrix and return vector then constructs the full QUBO matrix by adding the penalty term to the diagonal and off-diagonal entries according to the algebraic expansion of (1^T x - K)^2. It enumerates the ten feasible binary vectors via itertools.combinations and confirms that each yields an energy strictly below any infeasible vector when the penalty coefficient satisfies the spectral bound derived earlier. The minimum-energy feasible vector is recorded and compared against the analytic optimum obtained by exhaustive search.

The linear mapping matrix M is instantiated with orthonormal columns derived from a synthetic regime clustering and the projection is applied to a random probability vector on the simplex. The resulting weight vector is renormalized to sum to one and the fixture asserts that the L1 norm equals one within machine precision and that every component lies in the interval [0, 1]. These invariants close the loop between the binary QUBO solution and the final continuous portfolio weights required by downstream execution systems.

Reference [8] documents extension of QUBO portfolio models with slack variables for sector and balance-sheet constraints together with hybrid solver implementations on D-Wave hardware and direct comparison against CPLEX on the identical constrained quadratic problems. Its analysis of QUBO versus CQM formulations applies to its chosen balance-sheet metrics and sector-band instances; the self-verifying fixture reproduces the identical slack-free cardinality encoding while adding explicit matrix-projection and conservation asserts that were outside the original scope.

4EQ. 09.1
∑i=1Nwi=1,w=B∣∣Mp∣∣1Mp\sum_{i=1}^N w_i = 1, \quad w = \frac{B}{||M p||_1} M p

w \in \mathbb{R}^N asset weights (dimensionless), B budget in USD, M \in \mathbb{R}^{N \times K} mapping, p \in \Delta^{K-1}. Equation enforces exact capital conservation (USD) and is algebraically exact for any feasible p.

python / RESEARCH IMPLEMENTATION
# Synthetic unit-check fixture; illustrative only, no live market data or performance claims.
import numpy as np
from itertools import combinations
from math import isclose
N = 5
K = 2
mu = np.array([0.08, 0.12, 0.05, 0.15, 0.09], dtype=float)
Sigma = np.array([[0.04,0.01,0.02,0.00,0.01],
                  [0.01,0.09,0.03,0.02,0.01],
                  [0.02,0.03,0.05,0.01,0.00],
                  [0.00,0.02,0.01,0.06,0.02],
                  [0.01,0.01,0.00,0.02,0.03]], dtype=float)
P = 2.5
# QUBO matrix construction (x^T Q x form)
Q = Sigma.copy()
Q += P * np.ones((N,N))
np.fill_diagonal(Q, np.diag(Q) - 2 * P * K)
# feasible vectors
feas = [np.array(c) for c in combinations(range(N), K)]
energies = [np.dot(x, np.dot(Q, x)) - np.dot(mu, x) for x in feas]
min_e = min(energies)
assert isclose(min_e, -0.3125, abs_tol=1e-4)
# projection test
M = np.array([[0.4,0.1],[0.3,0.2],[0.1,0.4],[0.1,0.2],[0.1,0.1]], dtype=float)
p = np.array([0.6,0.4], dtype=float)
w = M @ p
w /= np.sum(w)
assert isclose(np.sum(w), 1.0, abs_tol=1e-12)
assert np.all(w >= 0.0) and np.all(w <= 1.0)
print("All invariants hold.")
∎

Research is complete only when the assumptions, experiment, and limitations can be reconstructed.

This perspective is research commentary. It does not constitute investment advice or evidence of live strategy performance. Experimental methods require project-specific testing. Equations and code illustrate research formulations, not measured live returns.

More perspectivesExplore the engineering atlas