Let us a consider a simple scenario to put what we've learnt about QAOA into practice.

Let be the cost Hamiltonian whose ground state we want to obtain and the mixer Hamiltonian that will help us in our task. Then, the QAOA circuit for a number of layers will be:

Complete the code below to implement this QAOA circuit. Note that in this case the initial state is because this is the ground state of

Hint. You might use the following qml.qaoa.cost_layer, qml.qaoa.mixer_layer and qml.layer methods in PennyLane.

or to submit your code

To interact with codercises, please switch to a larger screen size.

Learning Objectives:

  • Describe the QAOA algorithm.
  • Solve simple combinatorial problems using QAOA.