Let's use amazon braket to solve a simple combinatorial optimization problem today.
The most common way to solve combinatorial optimization problems on quantum gated quantum computers is to use QAOA or VQE, QAOA is a cousin of quantum annealing, and VQE is a brute force algorithm to find the eigenvalues of a matrix.
If you want to know more about QAOA, you can do a search on blueqat.com. This time, I'm going to make it with some knowledge of QAOA.
Copy
from braket.circuits import Circuit
from braket.devices import LocalSimulator
import matplotlib.pyplot as plt
%matplotlib inline
First, to solve the combinatorial optimization problem, we need to find the eigenvalues of the matrix, so we set up the matrix.
H=Z0∗Z1+Z0
Z in this equation takes values ranging from -1 to +1. Each term is expected to have a minimum value when -1-1=-2. At that time, Z0 should be -1 and Z1 should be 1.
The values of the qubits in that case are 1 for the zeroth qubit and 0 for the first qubit.
In this case, the equation is simplified and two parameters are provided (if you want to use QAOA).
Adiabatic time development, but since both of the above coefficients are 1, the circuit will be RZZ and RZ.
|0> -H-RZZ-RZ--RX--M
|0> -H-RZZ-----RX--M
The eigenstates are first prepared in superposition, and RX is the transverse magnetic field with the time evolution of X prepared.
The parameters for RZZ and RZ are the same.
In this case, we will use rigetti. Check the gate set.
Copy
from braket.aws import AwsDevice
device = AwsDevice("arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-2")
print(device.properties.action['braket.ir.jaqcd.program'].supportedOperations)
Now we are done, and in QAOA it is the expected value that we want to minimize, but the expected value of Z0Z1 can be easily obtained by counting the number of times it has the same sign and different signs. The expected value of Z0 can also be obtained by counting the number of times 0 and 1 appear.