The Quantum Approximate Algorithm for Solving Traveling Salesman Problem

The Quantum Approximate Optimization Algorithm (QAOA) is an algorithmic framework for finding approximate solutions to combinatorial optimization problems. It consists of interleaved unitary transformations induced by two operators labelled the mixing and problem Hamiltonians. To fit this framework, one needs to transform the original problem into a suitable form and embed it into these two Hamiltonians. In this paper, for the well-known NP-hard Traveling Salesman Problem (TSP), we encode its constraints into the mixing Hamiltonian rather than the conventional approach of adding penalty terms to the problem Hamiltonian. Moreover, we map edges (routes) connecting each pair of cities to qubits, which decreases the search space significantly in comparison to other approaches. As a result, our method can achieve a higher probability for the shortest round-trip route with only half the number of qubits consumed compared to IBM Q’s approach. We argue the formalization approach presented in this paper would lead to a generalized framework for finding, in the context of QAOA, high-quality approximate solutions to NP optimization problems.


Introduction
The Traveling Salesman Problem (TSP), a notorious NP-hard problem, has intrigued computer scientists and mathematicians for over two centuries. It involves a salesman traveling from city to city. The salesman needs to find the shortest possible round-trip route that visits all cities exactly once. This problem can be abstracted in terms of graphs. The TSP asks for a Hamiltonian cycle (a closed path) that connects every vertex of a weighted graph once with the lowest total sum of edges. Applying brute-force search among all possible permutation of n nodes takes time O(n!). The first algorithm to apply dynamic programming solves this problem in O(n 2 2 n ) time [Dantzig, Fulkerson and Johnson (1954)]. In the following decades, many approaches, such as Minimum Spanning Trees [Held and Karp (1970)], Branch-and-Bound [Balas and Toth (1983)], Branch-and-Cut Rinaldi (1987, 1991)] have improved on this time-bound. However, since the problem is a NP-hard, these exact algorithms run in exponential time. In practice, various heuristics and approximation algorithms are used to yield sufficiently high-quality approximate solutions. These approaches, including simulated annealing [Geng, Chen, Yang et al. (2011)], genetic algorithms [Grefenstette, Gopal, Rosmaita et al. (1985)], ant colony algorithms [Dorigo and Gambardella (1997)] can find solutions for extremely large problems (millions of cities) within a reasonable time. The solutions are often, with high probability, just 2-3% away from the optimal solution [Rego, Gamboa, Glover et al. (2011)]. In recent years, with the progress of practical quantum computing, such as Quantum Security Communication [Liu, Xu, Yang et al. (2019)] and Quantum Machine Learning [Ruan, Xue, Liu et al. (2017);Liu, Gao, Yu et al. (2018);Liu, Gao, Wang et al. (2019)], the application to approximate combinational optimization has also become tantalizing. In 2014, Farhi et al. [Farhi, Goldstone and Gutmann (2014)] proposed the Quantum Approximate Optimization Algorithm (QAOA) as a candidate to outperform the best classical optimization algorithm in the NISQ (Noisy Intermediate-Scale Quantum) era [Preskill (2018)]. QAOA not only arouses the interest of academia but also intrigues big enterprises. To name a few, IBM [Moll, Barkoutsos, Bishop et al. (2018)], Google [McClean, Boixo, Smelyanskiy et al. (2018)], and Intel [Guerreschi and Matsuura (2019)] have researched this algorithm. In the following sections, we will describe QAOA, then present our QAOA-based scheme for solving the TSP. We finally discuss the advantages and disadvantages of our approach by comparing it with other quantum computing methods.

Quantum approximate optimization algorithm
The quantum approximate optimization algorithm (QAOA) [Farhi, Goldstone and Gutmann (2014)] is an algorithmic framework derived from an approximation to the quantum adiabatic algorithm (QAA) [Farhi, Goldstone, Gutmann et al. (2001)]. The QAOA coarsely approximates adiabatic evolution by the application of the Suzuki-Trotter theorem [Nielsen and Chuang (2002)]. The framework breaks the time-dependent QAA Hamiltonian into a sequence of 2p time-independent Hamiltonians. Each of these time-independent operators have the form H can be considered as a "mixing operator", which serves to 'mix' quantum amplitude between the different solutions. The total adiabatic evolution is then produced by alternating applications of these two operators, where is some efficiently-prepared initial state.
When the expectation value of the final QAOA state with respect to C H is maximized (or minimized), the state , β γ records the optimal solution available to the parameter space. This approach depends on 2p parameters of the form β and γ . The values of each of these parameters can be found by a classical optimization algorithm such as Nelder-Mead, with the objective function being the expected quality of the solution. The expected quality of the final QAOA state can be found by sampling. Such a quantumclassical hybrid approach is illustrated in Fig. 1. This approach is regarded as a promising candidate for demonstrating quantum supremacy in the NISQ era [Preskill (2018)]. We note that when , the QAOA approaches the quantum adiabatic algorithm (QAA) perfectly and thus guarantees the optimal solution [Farhi, Goldstone and Gutmann (2014)]. Nevertheless we, consistent with prior research, have found that very small p frequently leads to high-quality approximate solutions.

Data structure
We map each city to a vertex i on a graph, with the route between city i and city j corresponding to the edge (i, j). According to the traveling expense between two cities, we assign a weight ij w to each edge. If city i and city j do not have a direct route, set = ij w ∞ (in practice, assign a large value). This transforms the problem to that of finding the edge sequence with minimal cost on a complete graph. The complete graph with n vertices has n(n-1)/2 edges. We map each edge to a bit variable, and regard the solution as a binary vector x  , where 1 indicates that the corresponding edge is included in the solution. Thus, the problem Hamiltonian C H can be defined as: We express the Hamiltonian cycle constraint as a polynomial function of ( 1) / 2 n n − binary variables can be selected independently). Thus, the polynomial constraint function f can be simplified to  Hence, the constraint that a closed path includes all vertices only once can be described as (4) We note this equation is a necessary condition, not a sufficient condition, for the constraint of TSP. For example, when the number of vertices is greater than 6, there are independent closed routes (each includes 3 vertices) satisfying Eq. (4), but they do not form a Hamiltonian cycle. We now present an Oracle function validate, to check this.

Oracle function validate
Associated with every NP optimization problem is an efficient algorithm validate, which checks if a solution meets the problem constraints [Kolaitis and Thakur (1994)]. The below algorithm is the specific validate for TSP, checking if the edge sequence represents a Hamiltonian cycle. The possible number of elements in Γ is no more than ( 1) / 2 n n − , so the time performance of the above algorithm is bounded by 2 ( ) O n and is thus efficient.

Construct constraint-encoded B H
Since the oracle function validate determines whether a given solution satisfies the constraints of TSP efficiently, we can use it to obtain a superposition over all feasible solutions. Prepare a superposition state containing all combinatorial solutions and add an auxiliary qubit with initial value 0 . Then, by applying the quantum oracle that maps 0 ( ) x x validate x → , we can select all feasible solutions in Ω with a controlled operation on the ancilla: In our scheme, we have transformed the city traveling graph into a complete graph, so any vertex sequence is a valid sequence. Using a 6-city example,  to the desired accuracy [Aharonov and Ta-Shma (2003)].

Scheme steps
Step 1 Prepare the superposition state including all feasible solutions.
Since we have oracle function validate at hand, prepare the system as per Eq.(5), then do a further projection 1 1 I ⊗ , to provide the initial state . * Step 2 Prepare B H and C H as per Eqs. (6) and (2) Step 3  As p is chosen to be higher, the average solution quality increases at the cost of a deeper quantum circuit.
Step 5 Perform the QAOA state evolution:

Numerical simulation
Here we give a concrete 5-city example. The costs of traveling between each city are shown in Fig. 3(a), and the result returned by p=4 QAOA is shown in Fig. 3 We can easily verify that this edge-selection is the optimal solution to this specific problem.

Discussion
The numerical simulations were conducted on a computer with an i7 CPU and 8 GB main memory. For numbers of cities greater 6, 15+ qubits are required to represent the solution space, which quickly becomes infeasible for classical simulation. The classical optimization method used to obtain the above results is the Nelder Mead simplex algorithm. We replace with other classical optimization algorithms provided by Mathematica © to observe the influence of different classical optimization methods for obtaining the final probability. We find that the QAOA ends up with almost identical results by exploiting varied classical optimization algorithms. This observation manifests the classical optimization method is not a vital factor in the performance of QAOA. Rather, p determines the depth of the quantum circuit, which determines the complexity of QAOA. IBM Q also presented a method to solve TSP [IBM Q (2018)]. They take the approach named variational quantum Eigensolver (VQE) [Peruzzo, McClean, Shadbolt et al. (2014), Wang, Higgott and Brierley (2019)], a quantum-classical algorithm proposed earlier than QAOA. In comparison, our method has two advantages.
First, we map each edge to a qubit so the total qubits we used are ( 1) / 2 n n − . IBM Q uses two-dimensional qubits-mapping, one is for each vertex, and the other is for the order in the vertex sequence. Hence, the qubits needed are 2 n . Clearly, our method consumes only half the number of qubits, a constant-factor improvement. Second, we improve on the handling of constraints. IBM Q takes the conventional method for encoding constraints, adding "penalty" terms to the problem Hamiltonian whenever a constraint is violated [Lucas (2014)]. These terms add extra energy scales to the problem Hamiltonian, which in practice increases the difficulty of getting the final solution. In addition, there is the distinct possibility of the algorithm returning an invalid solution. Instead, our approach does not use penalty terms. We instead encode the constraint directly in the mixer B H . This idea stemmed from the work of Hen et al. [Hen (a) [Ruan, Marsh, Xue et al. (2020)].

Conclusion
In this paper, we have proposed a QAOA-based scheme to solve the well-known NP-hard Traveling Salesman Problem. We use a unique approach in comparison to previous methods, in mapping edges to qubits and encode the closed tour constraint in the mixing operator B H . The results and comparison with other schemes demonstrated our approach's effectiveness and efficiency for solving TSP, albeit only for the small problem instances that can be analyzed with classical computers. We consider QAOA as a high-performing algorithm for resolving NP-optimization problems. However, QAOA, the hybrid quantum-classical variational optimization scheme, can only be considered a heuristic. Theoretically, QAOA is the approximation of QAA only produces the optimal result with certainty when p → ∞ [Farhi, Goldstone and Gutmann (2014)]. However, the presented approach for solving TSP reinforces the observation made in Farhi et al. [Farhi, Goldstone and Gutmann (2014)], that a small value p appears adequate to obtain the optimal (or at least, a high-quality) solution. If this is indeed the case for large problem instances, QAOA is a powerful utility that can be applied to a wide range of real-world optimization problems to obtain high-quality approximate solutions efficiently.

Conflicts of Interest:
The authors declare that they have no conflicts of interest to report regarding the present study.