The HHL Dragon vs LSS vs CPLEX
Harrow–Hassidim–Lloyd (HHL) vs Least Squares Solver (LSS) vs CPLEX
In HHL Portfolio Optimization, Round 1, The Quantum Dragon decided that he wants a better return on his wealth than he can earn by hoarding treasure in his cave, so he used QCentroid to take the HHL algorithm for a test flight to optimize a stock portfolio. At the time, he noted that classical solvers tend to minimize variance so well that the expected returns tend to be quite low, and that the HHL algorithm seemed to allow higher variance with a corresponding increase in expected returns. However, that insight was based on personal experience rather than direct comparisons. Therefore, he decided that Round 2 would compare the HHL algorithm to at least one classical solver.
Handicap Match
The Quantum Dragon ultimately decided to face two opponents simultaneously. Why? Because fighting unarmed humans one-on-one isn’t enough of a challenge to get a dragon to wake up from a nap.
So, he selected CPLEX and LSS. CPLEX is a well-known, highly regarded classical solver, and the free license handles respectably sized problems. The least squares solver (LSS) is actually used with the HHL algorithm to determine the relative error and refine the result, so the LSS solver here is simply using that solver independently.
QCentroid Results
One of the benefits of using QCentroid is that all the solvers run simultaneously. A second benefit is that more classical compute is available than I have on my laptop, which already overheats with The Quantum Dragon breathing near it.
Speed. We see that LSS ran the quickest, while HHL ran the slowest. For now, we’re attributing the latter to the SDK, which consumes quite a bit of RAM generating the quantum circuit.
Cost. There are no actual differences in cost at the moment since we’re just testing.
Expected Return. LSS slightly outperformed HHL, while CPLEX lagged far behind.
Sharpe Ratio. Despite slightly trailing LSS in expected returns, HHL boasts a somewhat higher Sharpe ratio.
Variance. CPLEX focuses on minimizing variance, as experience suggested it would. LSS had the most variance, which is what gave HHL the Sharpe ratio advantage.
Conclusion
You can’t draw too many conclusions with 30 assets and minimal constraints, because many classical solvers can quickly solve this problem. The performance insights will come from larger datasets with real-world constraints, because that’s when the classical solvers start to slow down. However, we see that different solvers focus on different parts of the objective function, thus favoring different metrics.
It is important to note that there is a bottleneck on the quantum side involving circuit generation. It takes hundreds of MB of RAM just to generate the circuit in use here. Therefore, The Quantum Dragon’s next step is to port the algorithm to other SDKs in hopes of finding one that is efficient enough to tackle more realistic problems.
HHL Portfolio Optimization Series
Round 3: The Qiskit vs PennyLane Dragons
Premium: Burned to a Qrisp
Premium: HHL Behind-the-Scenes
Round 2: HHL vs LSS vs CPLEX
Round 1: HHL
Image generated by OpenAI's DALL·E.