Abstract
The application of quantum algorithms has attracted much attention as it holds the promise of solving practical problems that are intractable to classical algorithms. One such application is the recent development of a quantum-walk-based optimization algorithm approach to portfolio optimization under the modern portfolio theory framework. In this paper, we demonstrate an experimental realization of the alternating phase-shift and continuous-time quantum walk unitaries that underpin this quantum algorithm using optical networks and single photons. The experimental analysis confirms that the probability of states corresponding to high-quality solutions is efficiently amplified by increasing the number of phase-shift and quantum walk iterations. This work provides strong evidence for practical applications of quantum-walk-based algorithms such as financial portfolio optimization.
Export citation and abstract BibTeX RIS
Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 license. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
1. Introduction
Quantum computation promises advantages for certain problems, such as prime factoring, exhaustive search and optimization [1–9]. Although only small quantum processors are currently available, there are tremendous expectations for quantum technology to assist with the solving of difficult real-life problems in the near future [10–12]. Modern financial trading relies on extensive computational resources for the analysis of historical data, high-frequency trading, portfolio optimization and risk analysis [13–16]. In the case of portfolio optimization, the computational complexity stems from the analysis of the balance between return and risk of portfolios involving many assets, motivating quantum computing to solve financial problems [17–23].
Recent works have combined financial services and quantum software to implement and test a financial portfolio rebalancing use case using hybrid quantum–classical algorithms [24]. Based on the mean-variance Markowitz model [25] with discrete asset constraints, Hodson et al explored the problem of portfolio optimization and rebalancing with the help of the quantum approximate optimization algorithm and quantum alternating operator ansatz, collectively known as QAOA [26–36].
Such heuristic, or approximation, algorithms are designed to identify high-quality solutions to optimization problems [37–40]. The problem solution space is mapped to a superposition of quantum states that is acted on by an interleaved sequence of solution-quality-dependent phase shits and mixing operations parameterised by classically tunable variational parameters. These are tuned using a classical algorithm that seeks to optimise the mean of the measured solution qualities. In doing so, constructive interference is produced at states corresponding to high-quality solutions.
Extending the QAOA schema to constrained optimization problems requires strategies for restricting or guiding probability amplitude to a subset of the problem solution space. The Quantum Walk-based Optimization Algorithm (QWOA) achieves this using an efficient indexing algorithm for the valid solutions and generalizing the QAOA mixing operation to a Continuous-Time Quantum Walk (CTQW) [41]. Slate et al proposed an application of the QWOA to the portfolio optimization problem, with numerical results indicating a significant advantage over previously explored methods [42]. Key to this was the ability of the QWOA to restrict the quantum search and, consequently, variational parameter optimization to a non-degenerate subspace of valid solutions.
This paper investigates the efficacy of the QWOA mixing operator as applied to the portfolio optimization problem. Using linear optical elements and single photons, we realize the first experimental implementation of the QWOA mixing unitary and demonstrate its reliable convergence to high-quality solutions over a wide range of quantum circuit depths. Our work provides strong evidence for the potential of quantum-walk-based algorithms to solve complex optimization problems of practical significance.
2. QWOA for combinatorial optimization
Combinatorial optimization problems seek solutions of the form
where the problem cost-function C(s) is defined to map a solution s from an ordered set of problem solutions to , s is a k-permutation of discrete elements selected from a finite set and,
is the valid problem solution space where
represents constraints imposed on , while defines the constraints.
The QWOA [41, 43] begins by establishing an injective map from the complete solution space to a Hilbert space consisting of n qubits where in order to define the quality operator
where .
We next require that there exists an efficient indexing algorithm from the complete solution space to the subset of valid solutions , which makes possible an indexing unitary
where maps the states corresponding to valid solutions to the indexed states . This enables the preparation of an initial state that is equally superposed over qubits corresponding only to the valid solution space ,
The quality operator Q and the indexing unitary are used as part of a variational quantum circuit that works to amplify probability density associated with high-quality (low-cost) solutions. The variational quantum circuit implements a sequence of alternating operators. The first of these is the 'phase-shift' unitary
where , applies a quality-dependent phase shift to all quantum states .
Next is the indexed-walk unitary,
where and for i ≠ j is equivalent to the adjacency matrix of a complete graph. The indexed-walk unitary Uw indexes and induces a maximal unbiased coupling over the valid solution subspace which drives the mixing of probability amplitude between states in the subspace. Equivalent to a CTQW for time t, during this stage phase differences encoded by UQ contribute to constructive and destructive interference. After competition of the CTQW, the indexing unitary un-indexes such that measurement is conducted with respect to the unindexed states .
An application of UQ and Uw is carried out for p repetitions, with the final state of the quantum system being
With each of the p iterations, the potential for probably amplitude concentration at corresponding to high-quality solutions increases—given suitable values for the variational parameters γ and t [44, 45]. Optimal variational parameters γ and t are obtained using a classical optimiser that minimises with respect to the objective function
such that a lowering of entails an increased probability of measuring a quantum state that corresponds to a high-quality solution. In this sense, the QWOA is a hybrid algorithm whereby a small set of classical values parametrise the evolution of an exponentially larger quantum Hilbert space.
3. The portfolio optimization problem
Consider an investor with a portfolio of assets of size M. For each asset, they must take one of three positions:
- (i)Short position: the buying and short-term selling of an asset under the expectation that it will drop in value.
- (ii)Long position: the buying and long-term holding of an asset with the expectation that it will increase in value.
- (iii)No position: not investing in the asset (taking neither the long nor short position).
A quantum encoding of the possible solutions si to qubit states uses two qubits per asset:
- (i).
- (ii).
- (iii)or .
Such that for a portfolio of size M we require qubits for complete representation of the solution space .
The discrete mean-variance Markowitz model implements a cost function for a given combination of solutions that takes into account the historical behavior of the assets. It may be expressed as a minimization problem with respect to the above quantum mapping as a
where σij is the covariance between assets i and j, ri is the average return, and represents a choice of long, short and no position respectively. As , the optimal portfolio is one providing maximum returns, while as , the optimal portfolio is the one that minimizes asset volatility. Equation (11) is subject to the constraint
which maintains the relative net position for a pre-existing portfolio.
Altogether, the key steps of the QWOA algorithm as applied to the portfolio optimization problem are:
- (i)Preparation of over (solutions satisfying constraint a).
- (ii)Computation of by p applications of with phase-shift quality operator and indexed-walk unitary .
- (iii)Minimization of via classical optimization of variational parameters and .
The QWOA algorithm, originating from a quantum walk perspective [46], can be implemented using a sequence of quantum gates, as detailed in [41]. Extensive simulations [42] highlight QWOA's advantages over other QAOA-based algorithms, notably due to its significantly reduced search space, achieving high-quality portfolios with fewer iterations. Furthermore, the inherent global symmetry in the QWOA mixing operator contributes to an unbiased convergence to optimal solutions with sufficient quantum circuit depth. QWOA has also shown great promise in handling diverse optimization challenges with intricate constraints and solution domains. The portfolio optimization problem can be efficiently solved using the QWOA with a gate complexity of [42]. These theoretical results depend on the efficient encoding of Q into the phase of the states, implementation of the indexed-mixing operator , and identification of (at least) locally optimal variational parameters γ and t.
4. Experimental implementation
In this work, we consider a partial physical implementation of the QWOA as applied to the portfolio optimization problem to experimentally verify the effectiveness of the alternating phase-shift and quantum-walk operations. We consider a restricted phase-shift operator which encodes the cost of only the valid solutions over a Hilbert space of size and a corresponding quantum walk unitary . Within this framework, solutions in are computed and indexed classically.
A portfolio consisting of three stocks (Google, IBM and Microsoft) is considered under the constraint a = 0, for which there are seven valid solutions (). We show the seven valid solutions in the supplemental material. The quality values qi have been calculated classically from the adjusted closing prices between 1/1/2019 and 12/31/2020 [47]. These are used to simulate the QWOA using the software package QuOp_MPI to obtain optimal values of t and γ for p = 1 to 8 [48]. Optimization of γ and t is carried out using the BFGS algorithm [49] with initial values generated following a uniform distribution between 0 and 2π for 20 repeats at each p.
The restricted QWOA operators and are implemented with single photons following the experimental setup as illustrated in figure 1(a). The seven computational basis states correspond to the QWOA indexes representing valid portfolios. In a 7-dimensional qudit, the basis states are encoded as , , , ⋯, , . Here, i () denotes the spatial modes of the single photons, and indicates the horizontal (vertical) polarization of the photons.
In this experiment, the initial state of the qudit is prepared in an equal superposition state represented as . Initially, the photons pass through a polarizing beam splitter (PBS) and a half-wave plate (HWP) set at , which divides the transmitted photons with different polarizations into two parallel paths using a beam displacer (BD). Next, in the upper and lower modes, two additional HWPs at and are inserted, respectively. Finally, the initial state is prepared as by passing through the second BD, followed by four HWPs set at 90∘, 22.5∘, , and 22.5∘.
We simulate the probability amplification process in the QWOA using the mixing operator and the phase shift operator . The mixing operator is the CTQW on the complete graph K7 with adjacency matrix W shown in figure 1(b), which connects all valid solutions. The phase shift operator is a diagonal unitary that applies a phase shift proportional to the variational parameter γ and the value of the mean-variance Markowitz model, , where the quality operator is a diagonal operator defined by solution qualities. Thus, we apply the unitary operation () on the state . Details of the variational parameters ti and γi can be found in supplemental material.
With the method introduced in [1, 50, 51], an arbitrary n × n unitary matrix can be decomposed into a product of two-level unitary matrices, which act non-trivially only on two-dimensional subspaces of the n-dimensional Hilbert space. In this experiment, each unitary operator Up () can be decomposed as
where are two-level unitary matrices. A two-level unitary matrix takes the form with only four elements , , and , which are neither 0 or 1. For the remaining elements, all the diagonal elements are set to 1, while all the off-diagonal elements are set to 0.
According to the requirement of realizing a two-level matrix [52], the horizontal and vertical polarization states of the photons in different paths are recombined into polarization states of the photons in the same path via BDs and 45∘ HWPs. Then we apply a unitary transformation to the polarization state of this path, which can be realized via a set of wave plates (WPs), thus producing an exact correspondence with equations (4) and (8).
The complexity of our experimental setup is independent of the number of the iterations and only depends on the dimension of Up which in our experiment is always 7. In this case, we employ a total of 10 beam displacers (BDs) to implement each Up . The variational parameters, which can be considered as parameters of , are adjusted by configuring the setting angles of WPs. A detailed resource analysis of our experimental implementation of QWOA mixing unitary with the bulk optics is included in Supplemental Material, together with the corresponding system-agnostic quantum circuits.
Once the transformation Up is implemented, we determine the square of the overlap between the final state and the basis states through a projection measurement. To perform the projective measurement, a PBS is employed to map the basis states of the qudit state onto separate spatial modes. By calculating the proportion of photon counts in each spatial mode to the total photon counts, we estimate the probability of the photons being measured in each basis state.
5. Experimental results
Theoretical predictions and experimental results of the probability distribution for the final states are presented in figure 2, covering iterations p = 1 to 6. The probabilities of the final state projected onto basis state after the 1st, 2nd, ⋯, and 6th iterations are , , , , and , respectively. These results align closely with the theoretical predictions of 0.363, 0.567, 0.876, 0.970, 0.998 and 0.998, respectively. Thus, the probability of the optimal portfolio occupying the valid solution space increases with the number of iterations and finally tends to be stable. The experimental results show that we will find the highest-quality portfolio with a probability close to 1.
Download figure:
Standard image High-resolution imageIn addition, we measure the expectation value of the quality operator that encodes the objective function, given by , as shown in figure 3. It can be seen that as the number of iterations increases, the value of the objective function is in a gradual downward trend, which indicates that the probability of the high-quality portfolio is gradually increasing. In our experiment, the imperfections of the results include the imperfections of the interferometers and inaccuracies of WPs. The former leads to the dephasing whose impact on the objective function can be estimated by assuming the dephasing rate is .
Download figure:
Standard image High-resolution image6. Conclusion
The implementation of quantum optimization algorithms on current quantum processors is still constrained by the compounding effects of system noise [31–33]. In contrast, we present the realization of a variational search up to p = 6 with strong agreement with predictions for a noise-free system. At all considered p, minimization of the objective function amplifies probability at the basis state corresponding to the highest-quality solution.
We consider a 3 asset portfolio where, as two qubits are used to encode the position per asset, the complete Hilbert space is of size . However, the QWOA reduces the quantum search to a globally-symmetric sub-space of seven valid solutions. For the portfolio optimization problem, compared to the QAOA, this significantly reduces the search space and eliminates bias resulting from mixing asymmetry.
In this paper, we present compelling evidence that demonstrates the applicability of quantum algorithms in solving portfolio optimization problems. Our experimental approach is direct, flexible, and holds the potential for scalability. The exploration of quantum algorithms in practical applications is gaining momentum [53–55], even though they are currently in a preliminary stage. With the dedicated efforts of scientific researchers, we anticipate that quantum technology will soon be leveraged to tackle challenging real-life problems.
Acknowledgments
This work is supported by the National Key R\&D Program of China (Grant No. 2023YFA1406701) and the National Natural Science Foundation of China (Grant Nos. 92265209, 12025401, 12104009 and 12305008) and an Australian Government Research Training Program Scholarship at the University of Western Australia. D K Q acknowledge support from the China Postdoctoral Science Foundation (Grant No. 2023M730198) and the fellowship of China National Postdoctoral Program for Innovative Talents (Grant No. BX20230036). J B W wishes to express gratitude to Yuying Li and Song Wang for valuable and insightful discussions, particularly within the domain of computational finance.
Data availability statement
No new data were created or analysed in this study.
Conflict of interest
The authors declare no conflict of interest.
Appendix A: The Markowtiz model
The mean-variance Markowitz model expresses the problem of choosing the optimal set of positions through minimization of the objective function,
which is subject to,
for the case of discrete asset constraints. Variable ri represents the expected returns for a given asset, σij represents the covariance between assets i and j, represents long, short and no position respectively, and ω is between 0 and 1 [42]. Equation (A.1) formalizes the idea of asset diversification. For a pair of assets in a given portfolio, the first term is minimized by taking the same position on both assets if they are anti-correlated or by taking a short position on one asset and a long position on the other if they are correlated. The second term is minimized by taking a long position on appreciating assets and a short position on depreciating assets. The ω parameter balances the influence of risk and potential return with the value chosen according to the preference of the portfolio manager. Equation (A.2) arises in the context of portfolio rebalancing, with constraint value a preserving the net position with respect to a pre-existing portfolio.
With M assets with three possible positions per asset (long, short or none), the size of the unconstrained solution space is 3M . Introducing the constraint defined in equation (A.2), the number of valid solutions with net position a is
where, if the bottom parameter of the rightmost binomial coefficient is not an integer, it is set to 0 [42]. While is always less than 3M , for any possible a, the number of valid solutions nevertheless grows exponentially with M.
Consider a portfolio of three stocks: Google, IBM and Microsoft, under the constraint that we have the same number of long and short positions (a = 0). This results in a valid solution space spanning 7 computational basis states.
The daily closing and opening prices of the three stocks between the and were obtained from Yahoo Finance, and the expected returns and covariance matrix (σij ) calculated see table A1. The 7 valid solution qualities, as given by the mean-variance Markowitz model with ω = 0.5 are shown in table A2. These define the diagonal, , of the Q operator. Note that, for a problem of this size, the qi are of the order 10−4. To assist in the optimization process all qi have been scaled by a constant factor of 250.
Table A1. Mean return of the assets and covariance between the assets from to .
Covariance (σij ) | Mean return (ri ) | |||
---|---|---|---|---|
Stock | IBM | Microsoft | — | |
0.000407 | 0.000243 | 0.000344 | 0.001245 | |
IBM | 0.000243 | 0.000415 | 0.000270 | 0.000604 |
Microsoft | 0.000344 | 0.000270 | 0.000460 | 0.001833 |
Table A2. Quality vector, q , describes the 7 valid solutions under the given the constraint of a = 0. The position on each stock (Google, IBM and Microsoft) can be read from the 6 qubits, where denotes a long position, denotes a short position and is no position.
QWOA Index | quantum encoding | qi |
---|---|---|
0.0 | ||
0.19537791107281657 | ||
−0.1119084583542568 | ||
0.09592313540638248 | ||
−0.038186379903069514 | ||
−0.05124555365045395 | ||
0.12193130046716749 |
Appendix B: The optimal variational parameters
The optimal variational parameters of ti and γi are obtained by the software package QuOp_MPI, for which detailed instructions and simulation code for the portfolio optimization problem are provided in [48, 56]. We experimentally realize the unitary operator of p-iteration QWOA () as follows
Appendix C: Resource analysis of realization of QWOA in bulk optical setup
The key to running QWOA on hardware is to implement the unitary matrix . For larger databases, the bulk optical setup can realize QWOA with the n × n arbitrary unitary matrix and the number of the beam displacers increases with n linearly, i.e. , as shown in figure C1. An arbitrary n × n unitary matrix can be decomposed into a product of two-level unitary matrices, which act non-trivially only on two-dimensional subspaces of the n-dimensional Hilbert space:
Therefore, such an implementation does make a significant contribution to the general scheme of QWOA.
Download figure:
Standard image High-resolution imageAppendix D: Quantum circuit of QWOA
In this section, we present the quantum circuit of QWOA to demonstrate that the algorithm can also be implemented in other systems. The design of quantum circuits is based on the cosine-sine decomposition (CSD) [57, 58]. As an example, we describe the factorization of an arbitrary unitary matrix using the CSD. For the unitary matrix U8, it can be decomposed as , where and are block diagonal,
and L4, , R4, and are unitary matrix. The matrix S4 is an orthogonal cosine-sine matrix,
For convenience, the unitary transformations and can be written as
Then the unitary transformations can be implemented by three controlled three-qubit transformations in figure D1(a). In addition, the unitary matrix U4 (L4, , R4, and ) can be decomposed as , where
are block-diagonal, and L, Lʹ, R, and Rʹ are unitary transformations. The unitary transformations , S4, and can be rewritten as
where and . Then these unitary transformations can be implemented by three controlled two-qubit transformations in figures D1(b) and (c). The decomposition method can be used to decomposed higher-dimensional unitary operators. Therefore, our idea can in principle design quantum circuit of any dimension, so as to realize the unitary matrix required by QWOA for generalization in other systems.
Download figure:
Standard image High-resolution image