This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Enhancing Knapsack-based Financial Portfolio Optimization Using Quantum Approximate Optimization Algorithm

Chansreynich Huot1, Kimleang Kea1,
Tae-Kyung Kim2, and Youngsun Han1*
Abstract

Portfolio optimization is a primary component of the decision-making process in finance, aiming to tactfully allocate assets to achieve optimal returns while considering various constraints. Herein, we proposed a method that uses the knapsack-based portfolio optimization problem and incorporates the quantum computing capabilities of the quantum walk mixer with the quantum approximate optimization algorithm (QAOA) to address the challenges presented by the NP-hard problem. Additionally, we present the sequential procedure of our suggested approach and demonstrate empirical proof to illustrate the effectiveness of the proposed method in finding the optimal asset allocations across various constraints and asset choices. Moreover, we discuss the effectiveness of the QAOA components in relation to our proposed method. Consequently, our study successfully achieves the approximate ratio of the portfolio optimization technique using a circuit layer of p3p\geqslant 3, compared to the classical best-known solution of the knapsack problem. Our proposed methods potentially contribute to the growing field of quantum finance by offering insights into the potential benefits of employing quantum algorithms for complex optimization tasks in financial portfolio management.

1Department of AI Convergence, Pukyong National University, Nam-gu, Busan 48513, South Korea

2Department of Management Information Systems, Chungbuk National University, 1, Chungdae-ro, Seowon-gu, Cheongju-si, Chungcheongbuk-do, South Korea

*Corresponding author: Youngsun Han (youngsun@pknu.ac.kr)

Keywords

best-known solution (BKS), portfolio optimization, knapsack problem, quantum approximate optimization algorithm (QAOA)

1 Introduction

The financial industry plays a remarkable role in the economic health and growth of every country. In the constantly evolving world of financial markets, technological advancements are shaping traditional portfolio optimization methods, presenting new opportunities and challenges; this process involves enlarging assets to reduce risk by offsetting individual risk profiles crucial to the investment process [1]. Although there are many portfolio optimization models, they possibly have limitations. For example, the mean-variance model, which provides solutions as percentages of the total budget, can result in fractional allocations of non-feasible assets [2]. In the constant pursuit of optimization, some studies have explored extensions to portfolio optimization [3]. Among these, a technique that reformulates the financial portfolio optimization problem as a knapsack-based problem has been proposed [4, 5].

Knapsack problem [2] was adapted for portfolio optimization by treating all assets included in the portfolio as items. The value of each asset is represented by its expected return, usually estimated using historical data or forecasting techniques. The weight of each item corresponds to a risky asset, typically measured by its standard deviation or the variance-covariance matrix of the assets. The knapsack capacity corresponds to the budget or available capital that can be invested in the portfolio. By reformulating the knapsack problem, the primary objective is to maximize the total value of the portfolio while satisfying the capacity constraint and potentially other constraints, such as a target return or a minimum number of assets. However, similar to [6], the knapsack problem is considered NP-hard even with polynomial-bounded weights and values. Therefore, exploring new paradigms for optimization owing to the computational complexity of solving this problem is crucial [7, 8].

Similarly, the paradigm of quantum computing, leveraging the properties of quantum mechanics, has been developed to solve complex problems intractable for classical computers [9, 10]. The financial domain is a primary aspect of quantum computing, with applications spanning price derivation, risk modeling, portfolio optimization, and fraud detection [11]. As technology redefines problem-solving in finance, the quantum approximate optimization algorithm (QAOA), rooted in quantum computing, offers the promise of efficiently finding approximate solutions for computationally demanding problems within the polynomial-bounded NP optimization complexity class [12]. In [13, 14], the application of QAOA to the knapsack problem is explored for optimization purposes.

In this paper, we reformulate the classical portfolio optimization problem as a knapsack problem that allows for an efficient mapping onto quantum algorithms, particularly advantageous for NP-hard financial optimization. By treating each asset’s expected return as value and its risk as weight, the knapsack model aligns portfolio constraints with total risk, permitting optimization under capacity constraints. Our approach introduces a novel Quantum Walk Mixer (QWM) combined with the Quantum Approximate Optimization Algorithm (QAOA), integrating the Quantum Fourier Transform (QFT) within the oracle. This QWM-QAOA framework ensures feasible states are targeted while reducing computational complexity. Empirical results demonstrate that QWM-QAOA enhances solution space exploration, providing robust portfolio configurations with high approximation ratios even under various noise conditions, thus showcasing a significant advancement in leveraging quantum algorithms for practical finance applications. The contributions of our study can be summarized as follows:

  • We propose a portfolio selection approach that formulates the portfolio problem as a knapsack concern by incorporating expected returns from the Markowitz model [15] and setting the capacity according to the knapsack framework.

  • We present a Quantum Walk Mixer to Quantum Approximate Optimization Algorithm (QWM-QAOA) for the knapsack problem, integrating a shallow circuit layer to decrease computational complexity and improve solution quality.

  • We demonstrate that our model consistently enhances the identification of optimal solutions for the knapsack problem, achieving an impressive approximation ratio ranging from 100% to 95% in scenarios involving the selection of 2 to 8 stocks.

The paper is organized as follows: Section 2 provides the background knowledge. Section 3 explores the related work. Section 4 details our proposed method. Section 5 demonstrates the experimental setup and performance evaluation. Section 6 dissects the findings of the proposed method, underscoring its achievements and limitations. Finally, we conclude our study in Section 7.

2 Background

In this section, we briefly describe the background knowledge of portfolio optimization, the knapsack problem, and the quantum approximate optimization algorithm (QAOA).

2.1 Portfolio Optimization

Portfolio optimization is a mathematical framework that maximizes returns while minimizing risks through strategically selecting assets within an investment portfolio [16]. This is typically achieved by strategically allocating the proportion of each asset in the portfolio to optimize the risk-return tradeoff by considering the specified risk tolerance. The process involves four steps: i) identifying suitable assets, ii) projecting anticipated yields based on historical data for future forecasts, iii) quantifying the risk by assessing the uncertainty of each asset, and iv) selecting the optimal portfolio that maximizes the expected yield for a given risk level [17]. One of the various models used in this study was the Markowitz model developed by Harry Markowitz in 1952 [15]. This analysis is in conjunction with the variance of the rate of return, providing a significant assessment of portfolio risk under a rational framework of assumptions. The Markowitz model represented the maximum expected yield by allocating funds into stocks as follows [18]:

Ri=t=1dirit,tR_{i}=\sum_{t=1}^{\infty}d_{i}{}_{t}r_{i}{}_{t}, (1)

where rit{r_{i}}_{t} indicates the anticipated return at time tt per stock invested in, and dit{d_{i}}_{t} is the rate at which return in the ithi_{th} security where time tt is discounted back to the presents. The standard deviation—the variance of return—is a statistical measure used as an indicator of the uncertainty or risk linked to return. These statistical indicators effectively measure the extent to which returns deviate unpredictably from the average value over a specific period. The variance represents the degree of variation exhibited by the return RiR_{i} concerning the expected return [E(Ri)][E(R_{i})], as illustrated:

σi2=1Ni=1N[RiE(Ri)]2.\sigma_{i}^{2}=\frac{1}{N}\sum_{i=1}^{N}[R_{i}-E(R_{i})]^{2}. (2)

The covariance of returns measures the relative riskiness of a security within a portfolio of securities. For two securities, denoted as ii and jj, the covariance of their returns as

σi=jE{[RiE(Ri)][RjE(R)]}.\sigma_{i}{}_{j}=E\{[R_{i}-E(R_{i})][R_{j}-E(R)]\}. (3)

Furthermore, covariance can be measured depending on the variability of the two individual return series:

ρi=jσijσiσj,\rho_{i}{}_{j}=\frac{\sigma_{i}{}_{j}}{\sigma_{i}\sigma_{j}}, (4)

where ρij{\rho_{i}}_{j} is the correlation coefficient of returns, and σi\sigma_{i} and σj\sigma_{j} are the standard deviation of RitR_{it} and RjtR_{jt}. As previously stated, an efficient portfolio is characterized by selecting individual assets within the portfolio and weighting each asset. Therefore, the portfolio return is calculated as a weighted average of the returns of the individual investments within the portfolio. Next, XiX_{i} denoted as the weight and applied to each return of the portfolio takes form as follows:

Rp=t=1i=0NdiritXit=i=0NXi(t=1dirit)t=i=0NXiRi,\begin{array}[]{l}R_{p}=\sum_{t=1}^{\infty}\sum_{i=0}^{N}d_{i}{}_{t}r_{i}{}_{t}X_{i}\\ \\ =\sum_{i=0}^{N}X_{i}\left(\sum_{t=1}^{\infty}d_{i}{}_{t}r_{i}{}_{t}\right)\\ \\ =\sum_{i=0}^{N}X_{i}R_{i},\end{array} (5)

where RiR_{i} is independent of XiX_{i}. The simplified version of the variance of a portfolio can be written as

σp2=i=0NXi2σi2+i=0Nj=1NXiXjσi,j\sigma_{p}^{2}=\sum_{i=0}^{N}X_{i}^{2}\sigma_{i}^{2}+\sum_{i=0}^{N}\sum_{j=1}^{N}X_{i}X_{j}\sigma_{i}{}_{j}, (6)

where σp2\sigma_{p}^{2} is the variance of the portfolio, XiX_{i} is the percentage of the investor’s assets that are allocated to the ithi_{th} asset, and the σi2\sigma_{i}^{2} represents the variance of the asset jj and the covariance between the returns for assets ii and jj denoted as σij\sigma_{i}{}_{j}. Traditional asset allocation methods, such as the Markowitz theorem, reportedly provide solutions in percentages. This approach can suggest allocating half of a market share, which is often impractical [2]. Therefore, proposing a method for determining the number of shares for each asset is crucial; this involves the conversion of expected returns, prices, and budget into interval values and determines the priority and importance of each share by framing it within a knapsack-based model.

2.2 Knapsack Problem

In this context, a given set of items with known sizes is selected and packed into a knapsack with a fixed capacity [19]. This problem is one of the simpler NP-hard problems in combinatorial optimization because it focuses on maximizing an objective function while adhering to a single resource constraint. To find the exact solutions, some techniques have been employed, such as relaxations, bounds, reductions, and other algorithmic approaches [20]. These techniques include genetic algorithms [21], dynamic programming [22], simulated annealing [23], Tabu search [24], and greedy algorithm [25]. These classical approaches are instrumental in providing optimal solutions. Although these conventional approaches are successful and valuable, they are limitations in computation in the classical domain. Furthermore, the new paradigm of quantum computing introduces optimization techniques, including QAOA, to tackle problems such as the knapsack problem, yielding better solutions than classical computation techniques [26, 27].

2.3 Quantum Approximate Optimization Algorithm(QAOA)

In combinatorial optimization, QAOA excels as solutions tailored for quantum computing while leveraging the strengths of classical computing [12, 28]. QAOA, a hybrid quantum-classical algorithm, has demonstrated remarkable effectiveness in addressing recent NP-hard problems, including Max-Cut [29], traveling salesman problem [30], and quadratic unconstrained binary optimization (QUBO) [31]. Consider a combinatorial optimization problem involving an N-bit binary string represented as z=z1zNz=z_{1}\cdot\cdot\cdot z_{N}, with a classical objective function f(z):{0,1}Nf(z):\{0,1\}^{N}\rightarrow\mathbb{R} is maximized. The goal is to find a solution zz that provides a high approximation to the maximum values of f(z)f(z) [32]. QAOA encodes this classical objective function into a quantum Hamiltonian HcH_{c},

Hc|z=f(z)|z.H_{c}|z\rangle=f(z)|z\rangle. (7)

Furthermore, HcH_{c} operates diagonally on the computational basis states of 2N2^{N} dimensional Hilbert space (nn-qubit space). Ideally, the performance of the pp-level QAOA improves with increasing pp. For the pp-level QAOA, the state |+N\ket{+}^{\otimes N} is initialized, while the HcH_{c} and a mixing Hamiltonian:

B=j=1Nσjx,B=\sum_{j=1}^{N}{\sigma_{j}^{x}}, (8)

are applied alternately with controlled duration, resulting in a wave function:

|ψp(γ,β)=eiβpBeiγpHceiβ1Beiγ1Hc|+N.\begin{array}[]{l}\ket{\psi_{p}(\vec{\gamma},\vec{\beta})}=e^{-i\beta_{p}B}e^{-i\gamma_{p}Hc}\cdots e^{-i\beta_{1}B}e^{-i\gamma_{1}H_{c}}\ket{+}^{\otimes N}.\end{array} (9)

This variational wave function is characterized by 2p2p variational parameters, γ\gamma and β\beta. The expected value of HcH_{c} in this state is determined through repeated measurements on a computational basis:

fp(γ,β)=ψp(γ,β)|Hc|ψp(γ,β).f_{p}(\vec{\gamma},\vec{\beta})=\bra{\psi_{p}(\vec{\gamma},\vec{\beta})}H_{c}\ket{\psi_{p}(\vec{\gamma},\vec{\beta})}. (10)

Furthermore, a classical computer is used to search for the optimal parameters (γ,β)(\gamma^{*},\beta^{*}) and maximize the averaged output f(γ,β)f(\gamma^{*},\beta^{*}):

(γ,β)=argmaxγ,βfp(γ,β).\left(\overrightarrow{\gamma^{*}},\overrightarrow{\beta^{*}}\ \right)\ =\ arg\ \ \underset{\vec{\gamma},\vec{\beta}}{max}\ f_{p}\ (\vec{\gamma},\vec{\beta}). (11)

Next, the approximation is assessed by the ratio between the optimized values fp(γ,β)f_{p}(\overrightarrow{\gamma^{*}},\overrightarrow{\beta^{*}}) and the maximum possible value fmax=maxzf(z)f_{max}=max_{z}f(z), as the approximate ratio:

r=fp(γ,β)fmax.r\ =\ \frac{f_{p}\ \left(\overrightarrow{\gamma^{*}},\overrightarrow{\beta^{*}}\ \right)}{f_{max}}. (12)

This approximation ratio rr reflects how close the QAOA solution is to the optimal classical solution. Typically, the search for this approximate ratio begins with a random initial estimate of the parameter and performing gradient-based optimization [33].

3 Related Work

Recent studies have explored hybrid approaches to enhance different quantum algorithms for knapsack-based portfolio optimization problems. For example, [34] introduces Quantum-Inspired Evolutionary Algorithm (QIEAs) for difficult knapsack problems. Similarly, [35] used Quantum-inspired meta-heuristic approaches for constrained portfolio optimization problems. These advancements highlight the potential of hybrid quantum-classical approaches for tackling real-world optimization challenges.

Our study builds upon several key pieces of research that delve into the application of QAOA to the knapsack problem concerning portfolio optimization. QAOA has been employed as a portfolio optimization method. In this approach, the portfolio optimization problem is transformed into a binary version. Accordingly, the weight vector is discretized, with the element taking values of either 0 or 1. In [36], a comprehensive study of quantum computing approaches for multi-knapsack problems is proposed by investigating some of the most prominent and state-of-the-art quantum algorithms using different quantum software and hardware tools. Consequently, quantum computing offers the potential for good and fast solutions to multi-knapsack optimization problems in various fields, such as logistics (allocating goods to containers), resource allocation in computing (distributing tasks among different servers), and financial portfolio optimization (allocating assets among different investment opportunities). In [37], the Markowitz models of portfolio optimization were converted into binary knapsacks. A hard constraint model was employed by incorporating hard constraints into the quantum algorithm, involving designing mixing operators based on the constraint conditions. Additionally, a combination of XYXY- and XYYXYY-mixers was used to encode the constraints in the quantum circuit. XYXY-mixers were used to mix the quantum state and generate a superposition of feasible solutions, whereas XYYXYY-mixers were used to enforce the hard constraints. Moreover, using a hard constraint model ensured that the quantum state evolved between feasible solutions satisfying the constraints while allowing for a high degree of flexibility in opting parameters. Another intriguing study highlights the strengths of the quantum walk optimization algorithm (QWOA) [38] compared to other quantum optimization algorithms while highlighting the challenges posed by the complex and large solution space associated with its lattice structure. Moreover, the quantum mixer optimization algorithm (QMOA) was introduced as an extension of QWOA. It enhanced the efficiency of quantum optimization algorithms for portfolio optimization by reducing the number of iterations required for computations [39].

4 Knapsack-based Portfolio Optimization

In this section, we explain our overall architecture, knapsack-based portfolio formulation, and QAOA for the knapsack problem.

4.1 Overall Architecture

This section outlines the complete process from stock data preprocessing to determining the optimal portfolio configuration using a quantum-enhanced approach. As shown in Figure 1, the workflow begins by processing historical stock prices to compute the daily returns using the Markowitz-based portfolio optimization model. Algorithm 1 calculates the expected returns (E(R)), which are crucial inputs for formulating the portfolio selection as a knapsack problem. This step maps the expected returns, stock weights, and capacity constraints into a knapsack framework to define the feasible portfolio configurations. In the next phase, Algorithm 2 solves the knapsack-based portfolio optimization problem. Here, we first construct the feasible oracle using Quantum Fourier Transform (QFT) [40] to ensure that only valid solutions are considered for further optimization. Once a feasible solution is identified, the Quantum Walk Mixer (QWM) is applied within the Quantum Approximate Optimization Algorithm (QAOA), following the approach of  [38]. The combination of QWM and QAOA (QWM-QAOA) efficiently explores the solution space, minimizing computational complexity while improving the accuracy of the optimization. The final output is a binary string, where each bit represents whether a stock is included or excluded from the portfolio. For instance, a result of (1,0) for two stocks indicates that Stock A is selected, while Stock B is excluded, thus guiding the final portfolio selection and investment strategy.

Refer to caption
Figure 1: Workflow diagram of the quantum walk mixer with QAOA for knapsack-based portfolio optimization. The process starts with Algorithm 1, where a list of stock prices is collected over time to prepare historical stock prices using the Markowitz model to calculate the expected return. This expected return is crucial in mapping the knapsack problem by considering the values, weights, and capacity of the portfolio. The optimization process in Algorithm 2 involves employing a quantum walk mixer with QAOA, including the preparation of a feasible oracle. This is followed by executing the quantum walk mixer with QAOA to enhance the search for the optimal portfolio configuration. The final output is a binary string, with 11 indicating the inclusion and 0 indicating the exclusion of stocks from the portfolio, resulting in the optimal solution.

4.2 Knapsack-based Portfolio Formulation

Our methodology is based on the fundamental principles of mean-variance optimization, focusing on the Markowitz model. This model historically maximizes the anticipated yield of a portfolio while considering a predetermined level of risk, quantified by the variance of portfolio returns. We denoted the expected return E(Ri)E(R_{i}) of stock ii by using the mean return calculation. Next, we transformed the expected return into a knapsack problem. Subsequently, we extended this model by reinterpreting the expected return as a component of a knapsack problem, thereby aligning portfolio optimization with knapsack problem dynamics; this adaptation involves redefining the expected return of each stock as a value optimized under the constraints of total portfolio risk. This mathematical transformation effectively converts portfolio optimization into a knapsack problem:

maximize R(x)=i=1nxiE(Ri)\displaystyle R(x)=\sum_{i=1}^{n}x_{i}E(R_{i}) (13)
subject to i=1nxiwiC,\displaystyle\sum_{i=1}^{n}x_{i}w_{i}\leq C,

where the risk of including stock ii in the portfolio, denoted as wiw_{i}, and the total risk tolerance, denoted by CC, serves as the knapsack capacity. The binary variable xix_{i} indicates whether to include stock ii in the portfolio, and E(Ri)E(R_{i}) represents its expected return values.

This process can be summarized as Algorithm 1. It begins by extracting the historical returns of each stock within a specified time range, from the start to the end date, using the HistoricalReturnHistoricalReturn function. From line 5125-12, these historical returns are then passed into the Markowitz model through the ExpectReturnExpectReturn function, which calculates the expected returns, denoted as E(R)E(R). These expected returns provide key insights into the potential profitability of the selected stocks in the portfolio problem. Specifically, the expected returns (E(R)E(R)) are assigned as the values in the knapsack problem, and the weights for each stock are uniformly set to 1, representing equal weighting for all assets. Afterward, the algorithm also defines the capacity constraint (CC) of the knapsack problem, which is set to half the number of stocks, calculated as Length(E(R))/2Length(E(R))/2. This framework effectively transforms the portfolio optimization problem into a knapsack problem formulation. This transformation allows for a more structured handling of assets and makes it possible to apply powerful combinatorial optimization techniques.

Algorithm 1 Formulate Portfolio Optimization as a Binary Knapsack Problem

INPUT: startstart: start date of stock prices, endend: end date of stock prices, stocksstocks: list of stocks
OUTPUT: problemproblem: portfolio optimization modeled as a knapsack problem

1:procedure EncodeToKnapsack(startstart, endend, stocksstocks)
2:     // Extracte historical return
3:     pricesprices\leftarrow HistoricalReturn(startstart, endend, stocksstocks)
4:     // Calculate the expected return
5:     E(R)E(R)\leftarrow ExpectReturn(pricesprices)
6:     // Set a weight of 1 to each stock
7:     for i0i\leftarrow 0 to Length(E(R)E(R)do
8:         weights[i]1weights[i]\leftarrow 1
9:     end for
10:     // Set the capacity of knapsack
11:     CC = Length(E(R)E(R)) / 2
12:     // Formulate the problem
13:     problem(E(R),weights,C)problem\leftarrow(E(R),weights,C)
14:     return problemproblem
15:end procedure

4.3 QAOA for the knapsack problem

After formulating the portfolio optimization as a knapsack problem, we optimized it using Algorithm 2. We employed the QWM-QAOA to prepare the mixing Hamiltonian for the QAOA process. In lines 2102-10, we set up the quantum registers and other necessary preparations for QAOA using the QuantumRegisterQuantumRegister function. Line 1212 focuses on constructing the Mixing Hamiltonian HmH_{m} using the QWM-QAOA approach, which is achieved via the QWalkMixerQWalkMixer function. This step requires parameters such as a predefined trotter step mm, the number of quantum registers, weights, and ancillaries. Next, the algorithm prepares the phase Hamiltonian HcH_{c} using PhaseHamiltonianPhaseHamiltonian (line 1313), which plays a crucial role in the construction of the QAOA. More details on these concepts will be provided in the following sections. At each circuit layer pp, the algorithm computed the expectation value (line 2828), facilitating the determination of a new set of optimal 2p2p parameter (γopt,βopt)(\gamma_{opt},\beta_{opt}). These optimal parameters were identified using the SHGO optimization method and implemented as ShgoOptimizerShgoOptimizer line 2929. Finally, the algorithm measured probabilities (line 3131) through a measurement process. These probabilities were used to determine the optimal solution using the OptimalChoiceOptimalChoice function to choose the best selection of items represented as arar as the optimal choice of approximation ratio.

Algorithm 2 Optimize Knapsack Problem Using the QWM-QAOA Algorithm

INPUT problemproblem: knapsack problem, pp: circuit layer, mm: trotter step count for QAOA
OUTPUT arar: approximation ratio as optimal choice

1:procedure OptimizeKnapsack(problemproblem, ll, mm)
2:     // Determine problem choices
3:     choiceschoices = Length(problem.weightsproblem.weights)
4:     // Calculate the total weight
5:     total_weightstotal\_weights = TotalWeight(problem.weightsproblem.weights)
6:     // Setup quantum registers
7:     cregc_{reg} = QuantumRegister(choiceschoices)
8:     wregw_{reg} = QuantumRegister(total_weightstotal\_weights)
9:     // Initialize quantum register
10:     arega_{reg} = QuantumRegister(33)
11:     // Define quantum mixing
12:     HmH_{m}= QWalkMixer(problemproblem,mm, cregc_{reg}, wregw_{reg}, arega_{reg})
13:     // Define phase operations
14:     HcH_{c} = PhaseHamiltonian(cregc_{reg}, problemproblem)
15:     // Start with superposition state
16:     |ψ0|\psi_{0}\rangle = |+choices\ket{+}^{\otimes choices}
17:     for k=1k=1 to pp do
18:         if k1k\leftarrow 1  then
19:              γk,βk\gamma_{k},\beta_{k} = Initialize()
20:         else
21:              (γk\gamma_{k},βk\beta_{k}) = (γopt,βopt\gamma_{opt},\beta_{opt})
22:         end if
23:         // Apply the unitary operators
24:         UB(βk)U_{B}(\beta_{k}) = eiβkHMe^{-i\beta_{k}H_{M}}
25:         Uc(γk)U_{c}(\gamma_{k}) = eiγkHce^{-i\gamma_{k}H_{c}}
26:         |ψk=Uc(γk)UB(βk)|ψk1\ket{\psi_{k}}=U_{c}(\gamma_{k})U_{B}(\beta_{k})\ket{\psi_{k-1}}
27:         // Define the QAOA cost function
28:         cost(γ,β)cost(\gamma,\beta)=ψk|Hc|ψk\bra{\psi_{k}}H_{c}\ket{\psi_{k}}
29:         // Optimize the cost function
30:         (γopt,βopt\gamma_{opt},\beta_{opt})= ShgoOptimizer(cost(γ,β)cost(\gamma,\beta))
31:     end for
32:     // Measure the final state
33:     probabilitiesprobabilities = MeasureProbabilities(|ψp\ket{\psi_{p}}
34:     // Obtain the optimal probability
35:     arar = GetOptimalSolution(probabilitiesprobabilities)
36:     return arar
37:end procedure

4.3.1 Feasibility Oracle

The feasibility oracle is used as a hypothetical subroutine that instantly determines whether a proposed solution to the knapsack problem violates any constraints [41]. We can explore solutions within a well-defined space of bitstrings by representing our portfolio model as a binary knapsack problem. We defined K(N)=(0,1)NK(N)=(0,1)^{N} as the set of all possible bitstrings of length NN representing potential portfolio choices. Furthermore, each possible choice of any of the NN items is represented by a bitstring xK(N)x\in K(N). ). Thus, the subset feasible solution was denoted as FF for the knapsack problem, and the feasibility function was defined as

f:K(N){0,1},xf(x)={1,if xF,0,otherwise.f:K(N)\to\{0,1\},\quad x\mapsto f(x)=\begin{cases}1,&\text{if }x\in F,\\ 0,&\text{otherwise}.\end{cases} (14)

Considerably, the feasibility oracle to be unitary UfU_{f} as:

Uf|x,y=|x,yw(x),xK(N),yK(1)U_{f}\ket{x,y}=\ket{x,y\oplus w(x)},\quad\forall x\in K(N),\quad y\in K(1) (15)

In portfolio optimization, a state |x\ket{x} symbolizes a specific stock allocation, which is deemed feasible (i.e., xFx\in F) if the total weight w(x)w(x) does not exceed the capacity CC. This oracle toggles a flag qubit |y\ket{y} based on the feasibility of the state |x\ket{x}, representing a possible portfolio configuration.

Next, we allocated qubits for storage as follows: SS to record the formulated knapsack choices, KwK_{w} to hold the weight of the item choice, and KFK_{F} as the flag qubit indicating the feasibility of the state SS. Remarkably, the number of qubits required for SS, KwK_{w}, and KFK_{F} are deonted by QSQ_{S}, QwQ_{w}, and QFQ_{F} respectively. Upon that, the total number of qubits that are required is QS+Qw+QFQ_{S}+Q_{w}+Q_{F}.

Furthermore, the total weight w(x)w(x) is calculated by adding the weight of each item to register KwK_{w}, controlled by the corresponding bit in register SS. We also compare the computed weight w(x)w(x) to the capacity CC using an inequality check facilitated by a multiple-controlled NOT gate.

For suitable W0W_{0}\in\mathbb{N}, the inequality can be verified using the following condition:

w(x)Cw(x)+C0<C+C0+1w(x)\leq C\Leftrightarrow w(x)+C_{0}<C+C_{0}+1 (16)

This condition ensures that the binary representation of w(x)+C0w(x)+C_{0} has zeros in all positions beyond kk. The feasibility oracle UfU_{f} employs two primary unitary operations-U1U_{1} and U2U_{2}. U1U_{1} augments KwK_{w} with a predetermined offset C0C_{0}, facilitating the binary representation required for the feasibility check; U2U_{2} is applied conditionally based on U1U_{1}’s outcome.

We begin by illustrating how U1U_{1} is prepared. Quantum Fourier Transform (QFT) [40] is employed within the unitary operation U1U_{1} to facilitate the process of adding weights in the knapsack problem.

This process starts with the initialization of the ancillary weight register KwK_{w} to |0\ket{0}. Next, QFT is applied to KwK_{w} to prepare the register for quantum addition, even though the QFT does not change the state for state |0\ket{0}. This step is necessary for nonzero initial states KwK_{w}. Post-state transformation of KwK_{w} from the computational basis to the Fourier basis, the weight representation was distributed across the amplitude of the quantum state:

QFT|Kw=12nk=02n1e2πi0k/2n|kQFT\ket{K_{w}}=\frac{1}{\sqrt{2^{n}}}\sum_{k=0}^{2^{n}-1}e^{2\pi i\cdot 0\cdot k/2^{n}}\ket{k} (17)

where we use the notaion e(t)=exp(2πit)e(t)=exp(2\pi it), and kk\in\mathbb{Z} is the binary representation of kn1,,k0k_{n}-1,\cdot\cdot\cdot,k_{0}. Furthermore, weights were added to QFT|KwQFT\ket{K_{w}} using controlled operations applying phase rotations. These operations are conditioned on the bits of the bitstring xx indicating the selection of items. Each bit in xx determines whether the corresponding weight wiw_{i} should be added to KwK_{w}. The addition in the Fourier space was related to phase rotation and implemented by a sequence of controlled phase gates. The magnitude of the rotation was determined by wiw_{i} and the position of the bit controlling the operation. The implementation of controlled additions can be described as follows: for each selected item (where the corresponding bit in xx is |1\ket{1}, a controlled phase rotation is applied to KwK_{w}. The phase added to each computational basis state |k\ket{k} within KwK_{w} is proportional to wiw_{i}:

|Kw={|Kw+wi,if xi=1,|Kw,otherwise.\ket{K_{w}}=\begin{cases}\ket{K_{w}+w_{i}},&\text{if }x_{i}=1,\\ \ket{K_{w}},&\text{otherwise.}\end{cases} (18)

This phase rotation effectively encodes the addition of wiw_{i} into the quantum state. After completing this process, the step transformed the register back to the computational basis required, where

QFT1|KwQFT^{-1}\ket{K_{w}} (19)

The inverse QFT decodes the phase information back into a computational state representing the total weight of the selected items. If QFT encodes the weight as a superposition of phases, the inverse QFT converts these phases back into a binary number the sum of the weights. The final state of the register KwK_{w} after applying U1U_{1} was the binary representation of the total weight of the items:

U1|x,0,y=|x,w(x)+C0,yU_{1}\ket{x,0,y}=\ket{x,w(x)+C_{0},y} (20)

Figure 2 shows how U1U_{1} is implemented using an algorithm based on QFT. Following the implementation of the unitary operation U1U_{1}, U2U_{2} is described in Figure 3, which comprises a quantum circuit that conditionally modifies the state of an ancillary qubit concerning the sum of weights represented in the register KwK_{w}. Referring to Equation 16, the ancillary qubit |y\ket{y} underwent a state flip to signal a valid configuration when the total weight w(x)w(x), augmented by a constant offset C0C_{0} is less than the predefined threshold C+C0+1C+C_{0}+1. This transformation was executed through several multi-controlled-NOT gates, where each gate was influenced by a qubit distinct from the weight register. The successful transition of the ancillary qubit’s state post U2U_{2} signified a feasible solution, adhering to the knapsack’s capacity, which effectively segregates the solution space into permissible and impermissible weights.

Refer to caption
Figure 2: Circuit implementation of U1U_{1}. It encodes the total weights of item selections into the ancillary register KWK_{W} using quantum Fourier transform-based arithmetic. A predefined offset C0C_{0} is added to the register to facilitate subsequent feasibility checking.
Refer to caption
Figure 3: Circuit implementation of U2U_{2}. It executes a conditional check based on the total weight calculated by U1U_{1} using several multi-controlled NOT gates to flip the ancillary qubit if the weight condition is satisfied.

4.3.2 Quantum Walk Mixer for Enforcing Constraints

This process relies on the mixing operator UB(β)U_{B}(\beta) generated by mixing Hamiltonian BB from Equation 8 as follows:

UB(β)=eiβBU_{B}(\beta)=e^{-i\beta B} (21)

Alternatively, by leveraging the feasible function ff in Equation 14 and neighboring states ni(x)n_{i}(x) for exploring the solution space, BB can be described as

B|x=i=0N1fi(x)|ni(x),xK(N)B\ket{x}=\sum_{i=0}^{N-1}f_{i}(x)\ket{n_{i}(x)},\quad\forall x\in K(N) (22)

where ni(x)n_{i}(x) is the ithi_{th} neighbor of xx (xx with ithi_{th} bit flipped). Using this alternative representation, it is easy to observe that x,xK(N)\forall x,x^{\prime}\in K(N).

x|B|x={1,if Ham(x,x)=1,0,otherwise\bra{x}B\ket{x^{\prime}}=\begin{cases}1,&\text{if }\operatorname{Ham}(x,x^{\prime})=1,\\ 0,&\text{otherwise}\end{cases} (23)

where Ham (x,x)(x,x^{\prime}) represents the Hamming distance between two binary strings xx and xx^{\prime}, which is the count of positions where the corresponding bits differ. The exact implementation of the desired mixing operator UB(β)U_{B}(\beta) presents challenges due to its Hamiltonian, requiring additional resources and non-commuting elements. To address this, we employ an alternative operator B~\tilde{B}, closely resembling BB. This operator is constructed from ViV_{i}, and the inverse ViV_{i}^{\dagger} for encoding feasibility information of neighboring states into auxiliary qubits that enable the controlled state manipulation. Additionally, the operator includes single-qubit XiX_{i} gates for creating neighboring state exploration. Moreover, UfU_{f} the feasible oracle is included to determine the feasibility of states by ensuring that only valid states are mixed. Finally, RiX(2β)R_{i}^{X}(2\beta) aids in adjusting the amplitudes of states based on feasibility and further refining the mixing process, whereas auxiliary qubits are employed to store feasibility information.

Refer to caption
Figure 4: General circuit for a single-qubit quantum walk mixer. It illustrates the core operations involved in mixing a quantum state with its feasible neighbor, guided by feasibility oracles and single-qubit rotations, as part of a constrained optimization algorithm.

As shown in Figure 4, the process starts from:

ViVi|x,0,0,0=|x,0,0,0V_{i}V_{i}^{\dagger}\ket{x,0,0,0}=\ket{x,0,0,0} (24)

which implies that the behavior of ViV_{i} when acting on a state |x,0,0,0\ket{x,0,0,0} is to transform it into a new state with additional information encoded in the auxiliary qubits, dependent on the feasibility function ff and its value at neighboring points. Therefore, the state of VjV_{j} can be described as

Vi|x,0,0,0=|x,f(ni(x)),f(x),fi(x)V_{i}\ket{x,0,0,0}=\ket{x,f(n_{i}(x)),f(x),f_{i}(x)} (25)

Next, neighboring state mapping is performed using ViV_{i}^{\dagger} to determine whether the original and neighboring states have the same feasibility. Thus, Equation 24 can be written as

Vi|x,f(ni(x)),f(x),fi(x)\displaystyle V_{i}^{\dagger}\ket{x,f(n_{i}(x)),f(x),f_{i}(x)} (26)
=|ni(x),f(x)f(ni(x)),f(x)f(ni(x)),fi(x)fi(x)\displaystyle\quad=\ket{n_{i}(x),f(x)\oplus f(n_{i}(x)),f(x)\oplus f(n_{i}(x)),f_{i}(x)\oplus f_{i}(x)}
={|ni(x),0,0,0,if f(x)=f(ni(x)),|ni(x),1,1,0,otherwise\displaystyle\quad=\begin{cases}\ket{n_{i}(x),0,0,0},&\text{if }f(x)=f(n_{i}(x)),\\ \ket{n_{i}(x),1,1,0},&\text{otherwise}\end{cases}

Then, the bit flip of the ithi-{th} qubit acts as:

Xi|x=|ni(x)X_{i}\ket{x}=\ket{n_{i}(x)} (27)

Therefore, we can describe the encoded feasibility information after applying ViV_{i} and based on Equation 25 as follows:

(Xi𝕀2|11|)Vi|x,0,0,0\displaystyle(X_{i}\otimes\mathbb{I}^{\otimes 2}\otimes\ket{1}\bra{1})V_{i}\ket{x,0,0,0} (28)
=fi(x)|ni(x),f(ni(x)),f(x),fi(x)\displaystyle\quad=f_{i}(x)\ket{n_{i}(x),f(n_{i}(x)),f(x),f_{i}(x)}

Next,

Vi(Xi𝕀2|11|)Vi|x,0,0,0\displaystyle V_{i}^{\dagger}\left(X_{i}\otimes\mathbb{I}^{\otimes 2}\otimes\ket{1}\bra{1}\right)V_{i}\ket{x,0,0,0} (29)
=fi(x)|ni(x),0,0,0\displaystyle\quad=f_{i}(x)\ket{n_{i}(x),0,0,0}

Thus, for a given B~\tilde{B} operator, which approximates the original BB operator, we have

B~=i=0N1Vi(Xi𝕀2|11|)Vi\tilde{B}=\sum_{i=0}^{N-1}V_{i}^{\dagger}\left(X_{i}\otimes\mathbb{I}^{\otimes 2}\otimes\ket{1}\bra{1}\right)V_{i} (30)

Moreover, B~\tilde{B} implements BB given three ancillary qubits, or more precisely, it is represented as:

B~|x,0,0,0\displaystyle\tilde{B}\ket{x,0,0,0} =i=0N1fi(x)|ni(x),0,0,0\displaystyle=\sum_{i=0}^{N-1}f_{i}(x)\ket{n_{i}(x),0,0,0} (31)
=(B𝕀3)|x,0,0,0,xK(N).\displaystyle=(B\otimes\mathbb{I}^{\otimes 3})\ket{x,0,0,0},\quad\forall x\in K(N).

It follows that

eiβB~|x,0,0,0\displaystyle e^{-i\beta\tilde{B}}\ket{x,0,0,0} =eiβ(B𝕀3)|x,0,0,0\displaystyle=e^{-i\beta(B\otimes\mathbb{I}^{\otimes 3})}\ket{x,0,0,0} (32)
=(UB(β)𝕀3)|x,0,0,0\displaystyle=\left(U_{B}(\beta)\otimes\mathbb{I}^{\otimes 3}\right)\ket{x,0,0,0}

where B~\tilde{B} is used to generate UBU_{B}. Moreover, B~\tilde{B} is not commute and should use three ancilla qubits. Therefore, the approximate implementation of eiβB~e^{-i\beta\tilde{B}} needs to use the trotter product formula. Meanwhile, using the identity RiX(2β)R_{i}^{X}(2\beta), the state representing the rest of the circuit in Figure 4.

eiβVi(Xi𝕀2|11|)Vi\displaystyle e^{-i\beta V_{i}^{\dagger}\left(X_{i}\otimes\mathbb{I}^{\otimes 2}\otimes\ket{1}\bra{1}\right)V_{i}} (33)
=Vi(RiX(2β)𝕀2|11|+𝕀(N+2)|00|)Vi\displaystyle=V_{i}^{\dagger}\left(R_{i}^{X}(2\beta)\otimes\mathbb{I}^{\otimes 2}\otimes\ket{1}\bra{1}+\mathbb{I}^{\otimes(N+2)}\otimes\ket{0}\bra{0}\right)V_{i}

where RiX(2β)=cos(β)𝕀Nisin(β)XiR_{i}^{X}(2\beta)=cos(\beta)\mathbb{I}^{\otimes N}-isin(\beta)X_{i}. Furthermore, we optimized UB(β)𝕀3U_{B}(\beta)\otimes\mathbb{I}^{\otimes 3} with the trotter product formula as

eβB~=\displaystyle e^{-\beta\tilde{B}}= (i=0N1Vj(RiX(2βm)𝕀2|11|\displaystyle\left(\prod_{i=0}^{N-1}V_{j}^{\dagger}\left(R_{i}^{X}\left(\frac{2\beta}{m}\right)\otimes\mathbb{I}^{\otimes 2}\otimes\ket{1}\bra{1}\right.\right. (34)
+𝕀(N+2)|00|)Vj)m\displaystyle\left.\left.\quad+\mathbb{I}^{\otimes(N+2)}\otimes\ket{0}\bra{0}\right)V_{j}\right)^{m}
+O(Nβ2m)\displaystyle\quad+O\left(\frac{N\beta^{2}}{m}\right)

Moreover, to maintain β\beta the validity of the approximation within the new parameter range, the β\beta range needs to be adjusted accordingly to β[0,mπ)\beta\in[0,m\pi).

As an objective function, we use the value function vv. Therefore, the corresponding phase separation can be described as follows:

UC(γ)|x=eiγv(x)|xU_{C}(\gamma)\ket{x}=e^{-i\gamma v(x)}\ket{x} (35)

4.3.3 Number of Qubit Requirements

The presented illustration implies that using a feasibility oracle with nfn_{f} ancilla qubits requires N+nf+3N+n_{f}+3 qubits. In contrast, there is an exigency for an additional three qubits, specifically for generating the unitary UBU_{B} (Equation 32).

5 Evaluation

This section presents the numerical results by evaluating the effectiveness of the proposed algorithm across different asset numbers along with the impact of parameter configuration.

5.1 Experimental Setup

We present the experimental setup for evaluation, specifically the datasets, hyperparameter configuration, and model setup used to evaluate our proposed approach.

5.1.1 Hyperparameter Configuration

Initially, we implemented the proposed method using the Qiskit library [42], a widely used open-source quantum computing framework. We run the algorithms on the QASM simulator, a tool provided by Qiskit for simulating quantum circuits, which helped us gain insights into the behavior and performance of the algorithms before moving on to the real quantum device. Moreover, we used a fake backend noise from 127 qubits of IBM FakeWashington. While using the real device, we used IBM Nazca, a 127-qubit quantum device, for quantum computations, which offers the opportunity to test the algorithms in a real-world quantum computing environment. The experimental phase involves conducting several tests in which we select varying stocks from yahoofinanceyahoofinance, such as Apple Inc. (AAPL), Amazon.com Inc. (AMZN), Alphabet Inc. (GOOGL), Microsoft Corporation (MSFT), NVIDIA Corporation (NVDA), and Tesla, Inc. (TSLA), Netflix, Inc. (NFLX), and Visa Inc. (N). Notably, the selection of these stocks was based on different scenarios, including all cases from two to eight stocks. Postselection, we proceeded with the experimental setup of the proposed method. During the optimization process, we focused on optimizing QAOA, which was achieved by optimizing the 2p2p angle parameters, i.e., β\beta and γ\gamma, using the classical optimizer SHGO [43]. Additionally, we integrated quantum walk to boost optimization by leveraging its benefits for refining the process and achieving superior results.

Table 1: Hyperparameter Configuration
Hyperparameter Value
Number of circuit layers 3
Number of trotter steps 3
Financial data provider yahoo finance
Portfolio valuation module PyPortfolioOpt
Classical optimizer SHGO
Framework for architecture implementation Qiskit

5.1.2 Problem Setup

To evaluate our proposed method’s performance, we defined our algorithm’s problem based on the number of assets to be optimized (Table 2). First, we selected 2–8 subsets of stocks using the capabilities of PyPortfoliopt [44]. The values represent the expected return of stocks counting from January 1, 2018, to January 1, 2023. The knapsack capacity CapCap is the maximum weight, where in our case we set it to be half of the total number of assets. This step clarifies the problem and enables us to tailor our algorithm accordingly. We aimed to evaluate the effectiveness of the QAOA optimization technique in portfolio optimization. To achieve this, we specifically evaluated the performance of the algorithm using the best-known solution (BKS), a result of using a classical algorithm [45], where 11 signifies selection and 0 denotes exclusion. This technique compared the results obtained from our algorithm with those of the classical solution, providing a benchmark for assessing its performance and effectiveness. By undertaking this evaluation, we can gain valuable insights into the capabilities and limitations of the QAOA optimization technique in portfolio optimization.

Table 2: The optimal stock selection and values for various portfolio sizes under the binary knapsack constraint. It includes the number of selected stocks (#Ss), stock types (Type), their values, knapsack capacity (Cap), Best Known Solution (BKS), and qubits used (#Qs). The BKS column shows the binary string representation of the optimal solution.
#Ss Type Values Cap BKS #Qs
2 MSFT 0.2430 1 (0,1) 7
AAPL 0.2602
3 MSFT 0.2430 1 (0,1,0) 8
AAPL 0.2602
NVDA 0.2430
4 MSFT 0.2430 2 (1,1,0,0) 10
AAPL 0.2602
GOOGL 0.1047
NVDA 0.2430
5 MSFT 0.2430 2 (0,1,0,0,1) 11
AAPL 0.2602
GOOGL 0.1047
AMZN 0.0716
NVDA 0.2430
6 MSFT 0.2430 3 (0,1,0,0,1,1) 12
AAPL 0.2602
GOOGL 0.1047
AMZN 0.0716
NVDA 0.2430
TSLA 0.4203
7 MSFT 0.2430 3 (0,1,0,0,1,1,0) 13
AAPL 0.1870
GOOGL 0.1749
AMZN 0.1898
NVDA 0.2856
TSLA 0.4203
NFLX 0.0797
8 MSFT 0.2430 4 (1,1,0,0,1,1,0,0) 15
AAPL 0.1899
GOOGL 0.1780
AMZN 0.1903
NVDA 0.2874
TSLA 0.4203
NFLX 0.0797
V 0.1341

5.2 Performance Evaluation

In this section, we present our model performance and its sensitivity analysis.

5.2.1 Model Performance

By meticulously exploring the variable settings within our QWM-QAOA, we identified that a circuit layer depth of p=3p=3 and a Trotter step value of m=3m=3 yielded the best results. Figure 5 illustrates the approximation ratios for knapsack-based portfolio optimization with varying numbers of stocks (ranging from 2 to 8 stocks) under three different environmental conditions: noise-free (simulator), noisy (using FakeWashington as a simulated backend), and noisy (real device: IBM Nazca with 127 qubits).

  • Noise-free (Simulator): The approximation ratios remain very high across all stock configurations, ranging from 100% (for 2 and 3 stocks) to 96% (8 stocks), indicating that the algorithm performs near-perfectly in an ideal, noise-free environment.

  • Noisy (Fake Backend): The introduction of noise through the simulated FakeWashington backend results in a decline in performance. The approximation ratios range from 98% to 70%, with lower values observed for larger portfolios. For example, 2 stocks achieve an approximation ratio of 98%, while 6 and 7 stocks drop to 70%. Interestingly, for 8 stocks, the approximation ratio slightly improves to 78%, indicating a non-linear impact of noise for larger portfolios.

  • Noisy (Real Device): The experiment is executed on the real IBM Nazca device with the approximation ratios dropping further, ranging from 96% (for 2 stocks) to 51% (for 6 stocks). Surprisingly, for 7 and 8 stocks, the approximation ratios increased to 52% and 55%, respectively.

This performance reduction is due to real-world factors, such as gate errors and decoherence, which exert a more significant impact as the number of stocks increases. This unexpected result hints at the potential for further improvements, even as the number of stocks increases in a noisy environment [46]. These issues highlight the importance of advanced error mitigation techniques, though such methods are beyond the scope of this study [47, 48].

Refer to caption
Figure 5: Approximation ratio for different scenarios involving various numbers of stocks under three distinct environmental conditions: noise-free with the simulator, noisy with Fake Washington, and noisy with the IBM Nazca device.

5.2.2 Sensitivity Analysis

We conducted a sensitivity analysis of key parameters using our QWM–QAOA algorithms, such as the circuit layer (p)(p) and the number of trotter steps (m)(m). These parameters are crucial for shaping the effectiveness of our proposed algorithm. Through a methodical examination and evaluation, we present details of the relationship between these parameters and how much they influence the overall efficiency and resilience of our QWM–QAOA.

  • Circuit Layer: Figure 6 shows that as the circuit layer increases beyond the initial value of p3p\geqslant 3, the approximation ratio of the diverse portfolio optimization result consistently reaches an impressive result ranging from 100% to 95%, categorically based on the setup cases of portfolio optimization. This empirical evidence emphatically establishes that our performance consistently produces an efficient result even at some circuit layers.

    Refer to caption
    Figure 6: Approximation ratio of the circuit layer (p)(p) is 1–5 across all problems. Remarkably, when p3p\geqslant 3, the approximation ratio reaches 100%, indicating that the proposed method is efficient even at the lower circuit layer.
  • Trotter Step in QWM-QAOA: We aimed to find the parameter mm, representing the trotter step counts in the QWM–QAOA algorithm while maintaining a constant circuit layer of p=3p=3 and optimize β\beta, γ\gamma for the resulting circuit of 1–5. Table 3 shows that the approximation ratio for various stock selections increasingly exhibits a better result starting from m=3m=3, ranging from 100% to 95%. When m=5m=5, we obtained efficient optimization results from our proposed method ranging from 100% to 96%. The approximation ratios demonstrate how increasing the trotter steps improves the portfolio optimization results, particularly when m3m\geqslant 3, yielding consistently higher performance across different portfolio problem sizes.

    Table 3: Performance of QWM-QAOA with varying Trotter steps across different stock selection scenarios. The table presents the approximation ratios for various numbers of stocks, ranging from 2 to 8, using the QWM-QAOA algorithm with different Trotter step values (1 to 5).
    #Stocks 𝒎m = 1 𝒎m = 2 𝒎m = 3 𝒎m = 4 𝒎m = 5
    2 1.00 0.96 1.00 1.00 1.00
    3 1.00 0.60 1.00 1.00 1.00
    4 0.77 0.99 0.99 0.99 0.99
    5 0.96 0.96 0.98 0.98 0.98
    6 0.96 0.97 0.98 0.98 0.98
    7 0.96 0.96 0.95 0.96 0.96
    8 0.96 0.96 0.96 0.96 0.96

6 Discussion and Limitation

our research provides a novel application of quantum computing, specifically through the Quantum Walk Mixer combined with a Quantum Approximate Optimization Algorithm (QWM-QAOA) integrating with Quantum Fourier Transform (QFT), to address the knapsack-based financial portfolio optimization problem. By transforming the traditional portfolio optimization problem into a binary knapsack problem formulation, we were able to leverage quantum computing to provide efficient and effective optimization strategies, particularly for NP-hard problems. The results from our experiment on noise-free simulation indicate that the QWM-QAOA approach can yield high approximation ratios in both fake backend and real quantum devices, demonstrating the potential of quantum computing in financial optimization tasks. Our study also highlights the importance of various QAOA parameters, such as circuit layer pp and trotter step mm, in optimizing the performance of our proposed algorithm. Through sensitivity analysis, we found that a circuit layer of p3p\geqslant 3 and the number of trotter steps m3m\geqslant 3 provided the most converged results, with approximation ratios consistently reaching between 100% and 96% in the best cases. This empirical evidence supports the notion that QAOA with the proper configuration, can outperform classical optimization approaches in the context of financial portfolio optimization problems. However, our experiments on real quantum hardware revealed some limitations. The approximation ratio dropped significantly due to unavoidable hardware noise such as gate errors and decoherence errors, with real-device performance yielding ratios as low as 50%. Despite these current limitations of quantum hardware, this finding emphasizes the pressing need for continued research in quantum error mitigation (QEM) techniques and hardware advancements to unlock the full potential of our proposed QWM-QAOA method on portfolio optimization problems in real-world applications.

Noise and Hardware Constraints: The most significant limitation encountered in this study was the impact of overall gate errors when using real quantum devices [49]. While the QAOA algorithm performed well in simulators and fake backend environments, real hardware results showed a substantial drop in approximation ratios (below 50%). This limitation reflects the current state of NISQ devices, which are not yet fully capable of handling complex optimization problems without significant fidelity loss.

Scalability: While our approach worked well for smaller portfolios, scaling QWM-QAOA to larger datasets faces challenges due to the increasing number of required qubits and the limitations of current quantum hardware, such as limited qubit availability and short coherence times. These constraints hinder its applicability to larger portfolio optimization problems. Advancements in quantum hardware and quantum error mitigation (QEM) techniques along with hybrid approaches are needed to extend QWM-QAOA to more complex real-world scenarios.

Limited Dataset: The experimental evaluations were conducted on a small selection of stocks, ranging from two to eight, providing a controlled setting to demonstrate the algorithm’s effectiveness. However, to determine its practical value, future evaluations must incorporate historical data, transaction costs, and market dynamics. Expanding the tests to larger and more diverse datasets will be crucial for assessing the broader applicability of the QWM-QAOA approach in more complex, real-world financial scenarios.

7 Conclusion

In this research, we proposed a novel approach to financial portfolio optimization by leveraging the capabilities of quantum computing, specifically through the Quantum Walk Mixer integrated with a Quantum Approximate Optimization Algorithm (QWM-QAOA). We reformulated the traditional portfolio optimization problem into a knapsack problem, enabling us to address the NP-hard nature of this financial decision-making challenge. Our experimental evaluations, conducted across simulated, fake, and real quantum devices, demonstrated the effectiveness of our approach in yielding high approximation ratios, particularly in noise-free environments. The results of our study reveal that the QWM-QAOA approach is capable of producing efficient portfolio selections, with approximation ratios ranging from 100% to 95% in noise-free conditions and from 98% to 70% on noisy fake devices. However, when tested on real quantum hardware, the results showed a decline in performance due to noise and gate errors, reducing the approximation ratios to approximately 50%. These findings highlight the current limitations of quantum hardware, particularly in dealing with noisy intermediate-scale quantum (NISQ) devices. While our proposed method showed promise, especially in noise-free environments, future work is needed to address the noise in real quantum devices. Error mitigation techniques with further exploration of quantum algorithms for optimization will be crucial in enhancing the robustness and scalability of this approach in real-world applications. Our study contributes to the growing field of quantum finance, offering insights into how quantum algorithms can be applied to complex financial problems such as portfolio optimization.

Code Availability

The code that supports the findings of this study is openly available in the Github repository, QWM-QAOA.

Acknowledgment

This research was supported by the "Regional Innovation Strategy (RIS)" through the National Research Foundation of Korea (NRF), funded by the Ministry of Education (MOE) (2023RIS-007).

References

  • [1] L. S. Speidell, D. H. Miller, and J. R. Ullman, “Portfolio optimization: A primer,” Financial Analysts Journal, vol. 45, no. 1, pp. 22–30, 1989.
  • [2] F. Vaezi, S. J. Sadjadi, and A. Makui, “A portfolio selection model based on the knapsack problem under uncertainty,” PLOS ONE, vol. 14, pp. 1–19, 05 2019.
  • [3] Z. X. Loke, S. L. Goh, G. Kendall, S. Abdullah, and N. R. Sabar, “Portfolio optimization problem: A taxonomic review of solution methodologies,” IEEE Access, vol. 11, pp. 33 100–33 120, 2023.
  • [4] S. Martello and P. Toth, “Algorithms for knapsack problems,” North-Holland Mathematics Studies, vol. 132, pp. 213–257, 1987.
  • [5] R. Mansini, W. ‚odzimierz Ogryczak, M. G. Speranza, and E. T. A. of European Operational Research Societies, Linear and mixed integer programming for portfolio optimization.   Springer, 2015, vol. 21.
  • [6] P. C. Chu and J. E. Beasley, “A genetic algorithm for the multidimensional knapsack problem,” Journal of heuristics, vol. 4, pp. 63–86, 1998.
  • [7] W. Honggang, M. Liang, Z. Huizhen, and L. Gaoya, “Quantum-inspired ant algorithm for knapsack problems,” Journal of Systems Engineering and Electronics, vol. 20, no. 5, pp. 1012–1016, 2009.
  • [8] A. Gunjan and S. Bhattacharyya, “Quantum-inspired meta-heuristic approaches for a constrained portfolio optimization problem,” Evolutionary Intelligence, pp. 1–40, 2024.
  • [9] D. Herman, C. Googin, X. Liu, Y. Sun, A. Galda, I. Safro, M. Pistoia, and Y. Alexeev, “Quantum computing for finance,” Nature Reviews Physics, vol. 5, no. 8, pp. 450–465, 2023.
  • [10] H. Cao, S. Garg, S. Mumtaz, M. Alrashoud, L. Yang, and G. Kaddoum, “Softwarized resource allocation in digital twins-empowered networks for future quantum-enabled consumer applications,” IEEE Transactions on Consumer Electronics, 2024.
  • [11] A. Saxena, J. Mancilla, I. Montalban, and C. Pere, Financial Modeling Using Quantum Computing: Design and manage quantum machine learning solutions for financial analysis and decision making.   Packt Publishing Ltd, 2023.
  • [12] E. Farhi, J. Goldstone, and S. Gutmann, “A quantum approximate optimization algorithm,” arXiv preprint arXiv:1411.4028, 2014.
  • [13] W. v. Dam, K. Eldefrawy, N. Genise, and N. Parham, “Quantum optimization heuristics with an application to knapsack problems,” in 2021 IEEE International Conference on Quantum Computing and Engineering (QCE), 2021, pp. 160–170.
  • [14] K. Kea, C. Huot, and Y. Han, “Leveraging knapsack qaoa approach for optimal electric vehicle charging,” IEEE Access, vol. 11, pp. 109 964–109 973, 2023.
  • [15] H. M. Markowitz, “Markowitz revisited,” Financial Analysts Journal, vol. 32, no. 5, pp. 47–52, 1976.
  • [16] K. P. Anagnostopoulos and G. Mamanis, “A portfolio optimization model with three objectives and discrete variables,” Computers & Operations Research, vol. 37, no. 7, pp. 1285–1297, 2010.
  • [17] A. Gunjan and S. Bhattacharyya, “A brief review of portfolio optimization techniques,” Artificial Intelligence Review, vol. 56, no. 5, pp. 3847–3886, 2023.
  • [18] C. Y. F. Anton Abdulbasah Kamil and L. K. Kok, “Portfolio analysis based on markowitz model,” Journal of Statistics and Management Systems, vol. 9, no. 3, pp. 519–536, 2006.
  • [19] A. J. Kleywegt and J. D. Papastavrou, “The dynamic and stochastic knapsack problem,” Operations research, vol. 46, no. 1, pp. 17–35, 1998.
  • [20] D. Du and P. M. Pardalos, Handbook of combinatorial optimization.   Springer Science & Business Media, 1998, vol. 4.
  • [21] T. Pradhan, A. Israni, and M. Sharma, “Solving the 0–1 knapsack problem using genetic algorithm and rough set theory,” in 2014 IEEE International Conference on Advanced Communications, Control and Computing Technologies, 2014, pp. 1120–1125.
  • [22] L. E. Schäfer, T. Dietz, M. Barbati, J. R. Figueira, S. Greco, and S. Ruzika, “The binary knapsack problem with qualitative levels,” European Journal of Operational Research, vol. 289, no. 2, pp. 508–514, 2021.
  • [23] D. Delahaye, S. Chaimatanan, and M. Mongeau, “Simulated annealing: From basics to applications,” Handbook of metaheuristics, pp. 1–35, 2019.
  • [24] X. Lai, J.-K. Hao, and D. Yue, “Two-stage solution-based tabu search for the multidemand multidimensional knapsack problem,” European Journal of Operational Research, vol. 274, no. 1, pp. 35–48, 2019.
  • [25] S. Abidin, “Greedy approach for optimizing 0-1 knapsack problem,” Communications, vol. 7, pp. 1–3, 2017.
  • [26] P. D. de la Grand’rive and J.-F. Hullo, “Knapsack problem variants of qaoa for battery revenue optimisation,” arXiv preprint arXiv:1908.02210, 2019.
  • [27] C. Patvardhan, S. Bansal, and A. Srivastav, “Quantum-inspired evolutionary algorithm for difficult knapsack problems,” Memetic Computing, vol. 7, pp. 135–155, 2015.
  • [28] B. Chen, H. Wu, H. Yuan, L. Wu, and X. Li, “Quantum portfolio optimization: Binary encoding of discrete variables for qaoa with hard constraint,” arXiv preprint arXiv:2304.06915, 2023.
  • [29] G. E. Crooks, “Performance of the quantum approximate optimization algorithm on the maximum cut problem,” arXiv preprint arXiv:1811.08419, 2018.
  • [30] J. Zawalska and K. Rycerz, “Solving the traveling salesman problem with a hybrid quantum-classical feedforward neural network,” in Parallel Processing and Applied Mathematics, R. Wyrzykowski, J. Dongarra, E. Deelman, and K. Karczewski, Eds.   Cham: Springer International Publishing, 2023, pp. 199–208.
  • [31] A. Borle, V. E. Elfving, and S. J. Lomonaco, “Quantum approximate optimization for hard problems in linear algebra,” SciPost Phys. Core, vol. 4, p. 031, 2021.
  • [32] G. Ausiello, P. Crescenzi, G. Gambosi, V. Kann, A. Marchetti-Spaccamela, and M. Protasi, “Combinatorial optimization problems and their approximability properties,” Complexity and Approximation. Springer-Verlag, 1999.
  • [33] L. Zhou, S.-T. Wang, S. Choi, H. Pichler, and M. D. Lukin, “Quantum approximate optimization algorithm: Performance, mechanism, and implementation on near-term devices,” Phys. Rev. X, vol. 10, p. 021067, Jun 2020.
  • [34] C. Patvardhan, S. Bansal, and A. Srivastav, “Quantum-inspired evolutionary algorithm for difficult knapsack problems,” Memetic Computing, vol. 7, pp. 135–155, 2015.
  • [35] A. Gunjan and S. Bhattacharyya, “Quantum-inspired meta-heuristic approaches for a constrained portfolio optimization problem,” Evolutionary Intelligence, pp. 1–40, 2024.
  • [36] A. Awasthi, F. Bär, J. Doetsch, H. Ehm, M. Erdmann, M. Hess, J. Klepsch, P. A. Limacher, A. Luckow, C. Niedermeier et al., “Quantum computing techniques for multi-knapsack problems,” arXiv preprint arXiv:2301.05750, 2023.
  • [37] S. Brandhofer, D. Braun, V. Dehn, G. Hellstern, M. Hüls, Y. Ji, I. Polian, A. S. Bhatia, and T. Wellens, “Benchmarking the performance of portfolio optimization with qaoa,” Quantum Information Processing, vol. 22, no. 1, p. 25, 2022.
  • [38] S. Marsh and J. Wang, “A quantum walk-assisted approximate algorithm for bounded np optimisation problems,” Quantum Information Processing, vol. 18, pp. 1–18, 2019.
  • [39] J. Shunza, M. Akinyemi, and C. Yinka-Banjo, “Application of quantum computing in discrete portfolio optimization,” Journal of Management Science and Engineering, 2023.
  • [40] Y. S. Weinstein, M. A. Pravia, E. M. Fortunato, S. Lloyd, and D. G. Cory, “Implementation of the quantum fourier transform,” Phys. Rev. Lett., vol. 86, pp. 1889–1891, Feb 2001.
  • [41] P. Chawla, S. Singh, A. Agarwal, S. Srinivasan, and C. Chandrashekar, “Multi-qubit quantum computing using discrete-time quantum walks on closed graphs,” Scientific Reports, vol. 13, no. 1, p. 12078, 2023.
  • [42] G. Aleksandrowicz, T. Alexander, P. Barkoutsos, L. Bello, Y. Ben-Haim, D. Bucher, F. J. Cabrera-Hernández, J. Carballo-Franquis, A. Chen, C.-F. Chen et al., “Qiskit: An open-source framework for quantum computing,” Accessed on: Mar, vol. 16, 2019.
  • [43] S. C. Endres, C. Sandrock, and W. W. Focke, “A simplicial homology algorithm for lipschitz optimisation,” Journal of Global Optimization, vol. 72, pp. 181–217, 2018.
  • [44] R. A. Martin, “Pyportfolioopt: portfolio optimization in python,” Journal of Open Source Software, vol. 6, no. 61, p. 3066, 2021.
  • [45] S. Martello, D. Pisinger, and P. Toth, “Dynamic programming and strong bounds for the 0-1 knapsack problem,” Management Science, vol. 45, no. 3, pp. 414–424, 1999.
  • [46] S. Johnstun and J.-F. Van Huele, “Understanding and compensating for noise on IBM quantum computers,” American Journal of Physics, vol. 89, no. 10, pp. 935–942, 10 2021.
  • [47] M. Alam, A. Ash-Saki, and S. Ghosh, “Analysis of quantum approximate optimization algorithm under realistic noise in superconducting qubits,” arXiv: Quantum Physics, 2019.
  • [48] B. Gaur, T. Humble, and H. Thapliyal, “Noise-resilient and reduced depth approximate adders for nisq quantum computing,” in Proceedings of the Great Lakes Symposium on VLSI 2023, 2023, pp. 427–431.
  • [49] S. K. Satpathy, V. Vibhu, B. K. Behera, S. Al-Kuwari, S. Mumtaz, and A. Farouk, “Analysis of quantum machine learning algorithms in noisy channels for classification tasks in the iot extreme environment,” IEEE Internet of Things Journal, 2023.