Quantum Algorithms for Mixed Binary Optimization applied to Transaction Settlement

We extend variational quantum optimization algorithms for Quadratic Unconstrained Binary Optimization problems to the class of Mixed Binary Optimization problems. This allows us to combine binary decision variables with continuous decision variables, which, for instance, enables the modeling of inequality constraints via slack variables. We propose two heuristics and introduce the Transaction Settlement problem to demonstrate them. Transaction Settlement is defined as the exchange of securities and cash between parties and is crucial to financial market infrastructure. We test our algorithms using classical simulation as well as real quantum devices provided by the IBM Quantum Computation Center.


INTRODUCTION
Quantum computers process information using the laws of quantum mechanics. They are well suited for a number of tasks such as simulating quantum mechanical systems [1,2] and factoring [3]. Additionally, quantum computers can provide a quadratic speed-up over classical Monte-Carlo simulations which may be used to evaluate risk [4,5] and price financial derivatives [6,7]. Another possible application area for quantum computers is optimization, particularly combinatorial optimization. It is not believed that quantum computers will be able to solve NP-hard problems in polynomial time [8]. There is, however, a significant effort in designing quantum heuristics that could be practically useful by finding near optimal solutions [9][10][11][12]. Algorithms such as the Variational Quantum Eigensolver (VQE) [9] and the Quantum Approximate Optimization Algorithm (QAOA) [10] are designed to tackle Quadratic Unconstrained Binary Optimization (QUBO) problems. However, many relevant problems in business and science are Mixed Binary Optimization (MBO) problems, with discrete and continuous variables, or with constraints that cannot be modelled as part of a QUBO problem, e.g. inequality constraints. In this paper, we introduce an approach to extend the existing quantum methods to more general MBO problem classes.
We test our algorithm on the Transaction Settlement problem by focusing on securities settlement in capital markets. Here, transaction settlement is the process in which securities (tradeable financial assets such as shares, c Barclays and International Business Machines Corporation 2019. BARCLAYS is a registered trade mark of Barclays plc, all rights are reserved. IBM and IBM Q are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product or service names may be trademarks or service marks of Barclays, IBM or other companies. * Electronic address: wor@zurich.ibm.com bonds and derivatives) are delivered usually against a payment. This exchange between parties can be facilitated by a clearing house, which also mitigates the counterparty risk [13]. Financial institutions submit the details of the trades (e.g. buy x shares of some company for an amount y of some currency) to the clearing house, which runs a complex optimization algorithm on the resulting batch of transactions while taking into account credit and collateral facilities. The objective is typically to settle as many transactions as possible or to maximize the total value of the settled transactions. Transaction settlement is a difficult optimization problem due to a combination of both the legal constraints that must be satisfied when settling delivery-versus-payment transactions and the additional optionality introduced by collateralizing assets and utiltizing credit facilities. A variety of approaches are currently employed, ranging in complexity from basic gross settlement systems (which settle on a simple transaction-by-transaction basis) to sophisticated probabilistic techniques such as simulated annealing (whereby an optimization process is performed to identify a sufficient subset of transactions that can settle and then that subset is actually settled). This is an industry process of systemic importance because of the volume and value of transactions settled, e.g. over $1.85 quadrillion of securities transactions were processed in 2018 by subsidiaries of the post-trade market infrastructure DTCC [14].
Our manuscript is structured as follows. In Sec. II, we define QUBO problems and discuss their relation to MBO problems. In Sec. III, we introduce hybrid quantum-classical optimization algorithms for MBO by extending the known algorithms. In Sec. IV we map the transaction settlement problem to this framework and, in Sec. V, we demonstrate the performance of our hybrid algorithm on concrete instances using cloud-based quantum hardware. We conclude in Sec. VI and discuss open questions and directions of further research.

II.
MIXED BINARY OPTIMIZATION QUBO problems, defined as min x∈{0,1} n where A ∈ R n×n , b ∈ R n , and c ∈ R, have a wide range of applications such as portfolio optimization or the traveling salesman problem, but are hard to solve [12,15]. Variational quantum algorithms for combinatorial optimization can find good solutions to QUBO problems once mapped to an Ising Hamiltonian H by setting +1} and replacing z i by Pauli Z-matrices σ Z i . This allows us, for instance, to use VQE or QAOA to approximate the ground state of H, which corresponds to the optimal solution of the QUBO problem.
Since many industry relevant problems, such as portfolio optimization with budget constraints [16] or the knapsack problem and its variants [17], are not QUBO problems, we also consider MBO problems, here defined as min x∈{0,1} n y∈Y where Y ⊂ R m is the feasible set for the continuous variables y and A : R m → R n×n , b : R m → R n and c : R m → R are given functions of y. MBO problems therefore combine discrete and continuous variables x and y, respectively. Furthermore, for a fixed y ∈ Y , the MBO problem (2) corresponds to the QUBO problem (1). While other definitions of MBO exist, we have chosen this one to be compatible with the variational heuristics we want to extend.
In QUBO problems we model linear equality constraints by adding quadratic penalty terms of the form (u T x + v) 2 , with given u ∈ R n and v ∈ R, scaled by a large weight λ, to the objective. This forces optimal solutions to satisfy u T x + v = 0. Other types of constraints are usually not possible in QUBO, since they cannot be represented as quadratic penalty terms. In the Quantum Alternating Operator Ansatz the mixing operator in QAOA is adjusted to keep the process in the feasible set assuming a feasible initial state [18]. This is a promising, but non-generic, approach to incorporate constraints.
Since MBO problems allow continuous variables, we may introduce a slack variable s ≥ 0 to enforce the equality constraint u T x + v + s = 0. This is equivalent to the inequality constraint u T x + v ≤ 0, without s. Thus, by allowing binary and continuous variables we extend the type of constraints we can model. The lower bound on s needs to be included as a continuous constraint defining the feasible set Y .

III. QUANTUM OPTIMIZATION ALGORITHMS FOR MBO
Variational quantum algorithms for QUBO first translate the problem into an Ising Hamiltonian H, as discussed in Sec. II. Classical optimization can then find the values of the parameters θ of a trial wavefunction |ψ(θ) to, for instance, minimize the expected value The expected value is easily estimated by repeatedly measuring |ψ(θ) along the Z-axis as H only consists of σ Z -terms. Since we consider classical optimization, we can translate every measurement of |ψ(θ) into a n-bit string and directly evaluate (1). If we measure |ψ(θ) Ntimes and denote the resulting bit strings by x j (θ) where j = 1, . . . , N , the resulting optimization problem is We may improve the performance of the optimization algorithm by replacing the sample average in problem (4) by another aggregation function such as the Conditional Value at Risk (CVaR). That is, for a given α ∈ (0, 1], we only average over the best αN samples, which can help the classical optimization process find better results [12]. In this paper, we consider two variational algorithms. First, VQE with a generic trial wavefunction |ψ(θ) and second, QAOA, where we construct |ψ(θ) based on H. In the following, we discuss how to extend these algorithms to be applicable to MBO problems.
If a generic trial-solution |ψ(θ) is given, as in VQE, we can map a MBO problem to a continuous optimization problem for which solutions can be approximated using classical optimization schemes.
Let us now consider a rule to derive a trial wavefunction |ψ H (θ) from a given Hamiltonian H such as given by QAOA. For MBO, every fixed y ∈ Y defines a QUBO and can, thus, be translated to an Ising Hamiltonian H(y). This allows us to define trial wavefunctions |ψ H(y) (θ) that now depend on y. As in (5) we can translate the MBO to a continuous optimization problem, where the measurements x j (θ, y) depend on θ as well as y. In summary, A(y), b(y), and c(y) define the Hamiltonian H(y), which in turn defines the θand y-dependent trial wavefunction |ψ H(y) (θ) . These two approaches allow us to extend the existing quantum heuristics from QUBO to MBO enabling us to test variational quantum algorithms on a larger problem class.
Next, we introduce a heuristic that is designed to handle slack variables resulting from modelling inequality constraints explicitly. This can help the classical optimizer used to solve (5) to move out of local minima. Suppose, for simplicity, that we have a problem with only binary variables and a single slack variable, coming from an inequality constraint, formally given by The large scalar λ > 0 enforces The new heuristic consists of repeating the following three steps a fixed number of times, or until some pre-defined termination criterion is met: 1. Perform a preset fixed number of iterations of a classical optimizer to jointly optimize θ and s, and store the resulting samples x j (θ) from the last iteration.
2. Analyze every individual sample x j (θ) and define In other words, for each sampled binary vector x j (θ), we derive the slack variable s j such that the constraint u T x+v +s = 0 is satisfied, if possible, or such that we minimize the violation. Evaluate the overall objective value for x j (θ) and s j and identify the candidate solution that performs best, i.e., that achieves the smallest objective value.
3. Fix the s j determined in the previous step and rerun the classical optimizer over θ only for a preset fixed number of iterations.
This simple heuristic can help significantly to move out of local optima of the considered continuous optimization problem in θ and s. The algorithmic parameters, such as number of cycles and number of iterations per cycle need to be determined according to the problem of interest. As we show in the following section, applying a classical optimizer directly to solve (5) often gets stuck in local optima, while our new heuristic reliably found the globally optimal solution of the considered test case. The introduced algorithm can be easily extended to more complex problems with additional continuous variables and multiple inequality constraints/slack variables.

IV. TRANSACTION SETTLEMENT
In this section, we introduce the Transaction Settlement problem in which parties continuously submit the details of the trades to a clearing house. All of the corresponding delivery-versus-payment transactions recorded by the clearing house during a predefined time interval, plus all the unsettled transactions remaining from the previous batch, form a new batch of I transactions submitted by K parties. Γ k is the set of transactions of party k. The clearing house must then settle as many transactions as possible within the given batch. The ith transaction involving a party k is described by a sparse vector v ik of length J, the total number of security and currency accounts, with only two nonzero entries, one for the security (delivery) and one for the currency (payment). The transaction vectors of two parties k and k that participate in a transaction i sum to zero: v ik + v ik = 0. To each transaction i we associate a binary variable x i to indicate settlement. We, thus, seek to maximize the weighted sum of settled transactions The weight ω i may, for instance, be the total monetary value of transaction i, or ω i = 1 ∀i if we seek to optimize the number of settled transactions. The K vector constraints in (8) feature the balance vector b k , which encodes the securities and currencies that party k owns before any transactions settle. Additionally, party k may be granted credit for some or all accounts, which is encoded by l k . There are K × J constraints in (8), but, in practice, the sparsity of b k v ik , and l k reduces the number of constraints. Thus, the optimization described by Eq. (8) must ensure that the credit limits are not exceeded. The transaction settlement optimization problem is complex and may feature dependency chains and even cyclical dependencies between transactions, as seen in Figs. 1 and 2.
Each account (associated with a security or currency) owned by a party can optionally participate in a simpli- fied credit and collateral facility, which permits the account to contribute to a collateral pool and also use the resulting credit pool. Several accounts owned by a party can participate in the same credit and collateral facility, permitting shared pools (in principle, several credit and collateral facilities can be defined for each party). The accounts owned by party k may add to or draw from the credit pool such that a total credit amount p k is not exceeded. This can be modeled as an additional continuous constraint for each party k that participates in a credit and collateral facility. The exchange factors r k represent the conversion of a currency/security in one account into a currency/security of another account when exchanged via the facility and may be party dependent. In this scenario, the credit limits l k can now be variable, instead of fixed for each account, to reflect the amount contributed to or drawn from the shared pool. The notation we use to formulate this problem is summarized in Tab. I.
We now transform problem (8), following Sec. II, into the form given in (2) which may be solved using the variational quantum solvers discussed in Sec. III. Nonnegative slack variables s k are used to cast the inequality constraints into equality constraints, i.e. (8) becomes Next, we map this constrained optimization problem to an unconstrained optimization problem by transforming the equality constraint into a quadratic penalty term scaled by a large number λ ≥ 0: In this form, we can solve the optimization problem using the methods of Sec. III, where the number of qubits needed to represent the trial wavefunction is equal to the number of transactions under consideration. The nonnegativity constraint on the slack variables as well as constraint (9) are handled by the classical optimizer as they do not involve the decision variables x i . Our formulation of the transaction settlement problem assumes that the order in which transactions are settled within a batch can be ignored. Therefore, only the settled transactions affect the balances.
We now describe the Transaction Settlement problem for three concrete test cases, with numerical results discussed later in Sec. V. The first two test cases involve three transactions between three parties of a single currency and security, while the third test case is a batch of seven payments of a single currency between six parties. In all three problems, we maximize the total number of transactions. The first problem instance, shown in Fig. 1(a), does not feature a credit and collateral facility, while the second instance, shown in Fig. 1(b), utilizes one for both accounts held by the first party. Starting with the first instance, we solve the following: where, for each party P i , the account balances, transaction values, and account credit limits are indicated by vectors (C, S) specifying the amounts of currency C and security S. The optimal solution settles transactions T 2 , T 3 , that is, (x 1 , x 2 , x 3 ) = 011, while a greedy algorithm may be able to settle only a single transaction, T 1 .
Next, we consider the batch of three transactions in the presence of a simplified credit and collateral facility. In this model, illustrated in Fig. 1(b), the two accounts held by party P 1 can contribute to and draw from a shared credit pool F 1 containing a net zero balance. We adjust the balance of P 1 such that no transactions can settle without the credit and collateral facility, while the optimal solution settles T 2 and T 3 with the facility (note that settling only T 1 is a valid solution, though not optimal).
The constraints for P 1 are then modified from those in Eq. (12) to Party P 1 now has an effective credit line for each account, l C and l S . We assume that the credit and collateral facility F 1 has a zero net balance so that l C and l S sum to zero with the appropriate exchange factors between accounts. In particular, the credit limit l C on the currency account cannot extend past −1S × (2C/S) = −2C, where 1S is the starting balance of the security account and 1S = 2C is the exchange factor. A similar analysis holds for the security account: l S ≥ 0.
The final problem instance, illustrated in Fig. 2, involves a batch of seven payments of a single currency between six parties. The objective and full list of constraints is the following set of equations: In all four cases, the optimal solution (x1, x2, x3) = 011, indicating that transactions T2 and T3 settle, is sampled with the highest probability. Both problems used the Ry variational circuit of depth d = 2 shown in Fig. 4, a penalty factor λ = 10 3 for adding constraints to the objective function, the CVaR aggregation function with α = 25%, and 150 iterations of COBYLA (without additional cycles to explicitly handle slack variables, see Sec. III).
where the constraints for P 3 and P 4 are always satisfied and can be removed from the model. Several optimal solutions exist, for example with payments T 2 , T 3 , T 6 , T 7 settling. In the next section, we discuss numerical results for each of these three problem instances.

V. RESULTS
We solve each problem instance described in Sec. IV using the hybrid/quantum classical algorithms outlined in Sec. III. Following [11], we use COBYLA as the classical optimizer, since it is well suited to handle continuous variable constraints. For each problem instance, we classically simulate the hybrid quantum-classical algorithm using Qiskit [19] and, for the first two problem instances, compare the simulations to runs on the Valencia 5-qubit quantum processor of the IBM Quantum Computation Center. We employ readout-error mitigation using Qiskit Ignis [19,20] to correct measurement errors. The variational circuit we use, shown in Fig. 4, is composed of d + 1 layers of single-qubit Y -rotations interleaved with d blocks of controlled-Z gates [1]. We set a quadratic penalty factor of λ = 10 3 for the problem constraints [see Eq. (11)], and utilize the CVaR aggregation function mentioned in Sec. III with α = 25% in place of the sample average for 8,192 samples drawn from each trial wavefunction.
The results of the quantum algorithm for the first two problem instances using a simulator and the Valencia quantum processor, are shown in Fig. 3. We compare the results for the first problem (12) from classical simulation in Fig. 3(a) to those found from running on Valencia in Fig. 3(b), and similarly for the second problem (13) in Figs. 3(c) and 3(d), respectively. For Results for six parties and seven payments of a single currency using classical simulation. The problem is first approached without (a, b) and then with (c, d) explicit handling of slack variables, i.e. the heuristic described in Sec. III. In the first approach, we apply COBYLA with 300 iterations, while in the second, we run 1 cycle with 100 + 100 iterations of COBYLA (the first 100 iterations on the full problem and the second 100 iterations on the parameters of the variational form only). We show here the probabilities of the ten most frequent states resulting from the optimization process (a, c), where candidate solutions are grouped into feasible (green bars) and infeasible (grey hatched bars) sets and then sorted left to right by descending value of the objective function (number of trades settled). In (a), the feasible solutions sampled are sub-optimal, the best one having a single payment settled. In (b), an optimal solution with 4 payments settled is found with a probability larger than 40%. In addition, we show the progress during the optimization, where it can clearly be seen how the explicit handling of slack variables (d) achieves the optimal solution while the direct application of COBYLA gets stuck in a local optimum (b). Results shown here used a Ry variational circuit of depth d = 3, a penalty factor λ = 10 3 for adding constraints to the objective function, and the CVaR aggregation function with α = 25%.
both problem instances, with and without the credit and collateral facility, we find good agreement between simulation and experiment. The optimal solution that settles T 2 and T 3 (the bitstring 011) appears with the highest probability.
For the third problem instance (14), we simulate classically and compare the algorithm with explicit handling of slack variables and without, as described in the heuristic of Sec. III. In the latter case, we find that the objective function never reaches the maximum value of four (i.e. four settled transactions), but saturates at unity as seen in Fig. 5(b). As a result, only sub-optimal feasible solutions are sampled, see Fig. 5(a). In contrast, with explicit handling of slack variables, Fig. 5(d) shows how the objective function achieves the maximum value within the second part (step 3, evaluations 100-200) of the first cycle, and that we now sample a globally optimal solution settling payments T 2 , T 3 , T 6 , T 7 (the bitstring 0110011) in 5(c). Note that the heuristic finds only one out of the three possible globally optimal solutions. To influence the actual solution found, we could adjust the weights w i in Eq. (10), for instance, to prioritize transactions with a larger volume.
All the algorithms described here have been implemented in Qiskit [19], which has been used to access the classical simulator as well as the quantum hardware.

VI. CONCLUSIONS
In this paper we extended the existing work on quantum optimization to the class of Mixed Binary Optimization and propose the first hybrid quantum/classical heuristics to address such problems. This allows us, for instance, to model inequality constraints, which significantly extends the applicability of these algorithms. Inequality constraints are crucial for many applications such as portfolio optimization, where to date, quantum algorithms were always assuming a cardinality equality constraint instead of a real budget constraint [12,16]. We tested our algorithms on the Transaction Settlement problem for batches of payment and deliveryversus-payment securities transactions, which is a difficult and important optimization challenge in capital markets. Better algorithms could increase settlement efficiency (in terms of the number of transactions settled for a given batch), thereby minimizing the time intervals between trade and settlement. This could reduce replacement cost risk (the risk of loss of unrealized gains due to delay in settlement), reduce liquidity risk (substantial liquidity pressures can emerge if a participant fails to settle its net funds debit positions), and reduce credit risk (particularly if there is a decline in value of the securities).
The algorithms presented in this paper are exploiting only very little of the structure of a problem. Although this allows for great flexibility, it also clearly indicates directions of future research. By restricting to problems with certain properties such as, for instance, convexity in the continuous variables, it may be possible to derive algorithms that outperform the current state-of-theart and maybe even derive some guarantees on convergence under assumptions of the underlying quantum algorithms. The proposed structure also allows for the use of problem specific variational forms, such as those proposed by QAOA, which may further improve the performance.