I have always been fascinated by computing. Thanks to my friends Ernesto Adorio (♱) and Augusto Hermosilla, both of whom are mathematicians, who introduced me to optimization. Ernie and I built the first MathNOW (Network of Workstations) in the University of the Philippines powered by Linux and MPI (Message Passing Interface). We then used this cluster to come up with a paper on Parallel Genetic Algorithms. This blog post is a first part of a series about how Quantum Computing is used to tackle NP-Complete problems.
Doing Quantum Computing is like creating musical scores as you can see from the image above. That' s probably what inspired me to give this blog the title "I Sing Quantum Computing". Apart from that, this blog post is about the Ising Model of Quantum Physics.
The Ising model is a model to describe magnetic materials as a lattice of particles with spin-up or spin-down orientation. When a magnetic material such as iron is hot, the orientation of the spins is random. But when it cools, spins tend to form regions (called magnetic domains) such that the spins in each region is aligned. Each particle interacts with its nearest neighbor with a weight of wij=wji. The Hamiltonian (total energy) of the system of particles is given by
H=−ij∑wijσiσj
where σi is either 1 or -1 representing the spin of the particle. From the hamiltonian, we can compute the minimum eigenvalue and the corresponding eigenstate. The eigenstate will correspond to the orientations of the spins of each particle.
Mapping NP-Complete Problems to the Ising Model
Consider a graph of N nodes and edges between nodes. Each edge has a weight wij corresponding to the interaction between the nodes connected by the edge. Partition this graph into 2 subsets by assigning a value of 0 or 1 to each node. Get the total interaction of this partitioning by summing the interaction term for every edge that connects a node from subset 1 to subset 2, that is
C=i,j∑wi,jxi(1−xj)
The total interaction C is called the cost function. Now we want to find a subset such that the cost function is maximum. This is called the max-cut problem. It's like cutting the graph into 2 subsets and maximizing the sum of the interaction terms of each edge that crosses the cut.
An Example: Maximum Cut
Suppose we have 4 nodes connected to each other in the following way and wij=1:
Assign 0 or 1 to each node and compute the cost function C. An example assignment looks like:
(1,0,0,0)
Since node0 is connected to node1, node2 and node3, then we have
C=w01+w02+w03=1+1+1=3
Below are 16 possible ways to assign 0's and 1's and the corresponding value of the cost function computed using the above method:
Therefore, to maximize C, we need to minimize the Ising Hamiltonian:
H=i<j∑2wijZiZj
Representing the Nodes as Qubits
Using qubits, we can represent an assignment of 0's and 1's as a tensor product of single qubits ∣qi⟩:
∣q3⟩⊗∣q2⟩⊗∣q1⟩⊗∣q0⟩=∣q3⟩∣q2⟩∣q1⟩∣q0⟩=∣q3q2q1q0⟩
In this basis, we can compute the matrix representation of Z0. Remember that Zi means that the Pauli Z operator operates on the ith qubit. For example,
Z0∣0000⟩=∣0⟩⊗∣0⟩⊗∣0⟩⊗Z0∣0⟩=∣0000⟩
In the same way,
Z3∣1000⟩=Z3∣1⟩⊗∣0⟩⊗∣0⟩⊗Z0∣0⟩=−∣1000⟩
Given the above, we can now compute the matrix representation of Z0 and is given by
Since H is a diagonal matrix, the eigenvalues are the diagonal elements themselves. Looking at the values, we see that the minimum value is -1.5 which corresponds to ∣0101⟩ and ∣0101⟩. Coloring the node with state ∣0⟩ as blue and ∣1⟩ as red, we get the configuration of ∣0101⟩ below: