Skip to content
Vishal Bajpe edited this page Nov 16, 2022 · 3 revisions

General

Please ensure your notebook version is v1.1 (scroll down to the end of the notebook to check your version number) and make sure you do not pass options to the Estimator calls (Options to Sampler calls should be passed)


Exercise 1

  • For a graph containing 4 nodes, how many qubits will you need to represent this system?

Exercise 2

  • Use these docs to learn how to define a QuadraticProgramToQubo class. Once defined, see how you can convert your previously defined quadratic program to a Qubo and then to an Ising Hamiltonian using these docs.

Exercise 3

  • Navigate to section 3.2.1 in this paper and see what gates you need to apply to the 3 qubit circuit to construct the W state. To learn more about single qubit gates see this chapter of the Qiskit textbook and to learn more about what multi qubit gates are available in Qiskit see these docs.

Exercise 4

  • To define your Sampler routine, see these docs for more information about what parameters can be passed in and what methods can be run.

  • Make sure the values are in radians.


Exercise 5

  • This exercise requires you to generalize the code for the 2 node TSP entagler to be able to work for any N number of nodes. Think about the kind of loops that you need to make to fulfil needing N number of W blocks and N-1 values of theta.

  • Make sure the function works to generate circuits for higher number of nodes.

  • Extrapolate the 2 qubit circuit shown to the n qubit case as explained in section 3.2.2 Figure 4(a).


Exercise 6

  • This exercise requires you to create a VQE routine. See these docs to learn about what parameters can be passed into VQE() and which ones are relevant to this problem.

  • Ensure you have run the 3 qubit graph problem definition in the cell above Exercise 3.

  • To pass the callback function you need to only pass in the function reference and not the function call (no need of brackets for the function in callback argument).

  • Make sure you pass in the Estimator call and not the reference (Estimator()) and make sure you pass in the right init value and the right operator.


Exercise 7

  • To learn how to define a Sampler routine, see these docs. Here you can also see what parameters need to be passed into the ‘run’ method in order to extract the results. From these results, see this page on how to obtain the nearest_probability_distribution.

  • The Sampler result has a quasi_dist attribute. Extract the quasi probability distribution as a dict and then apply the nearest_probability_distribution function.


Exercise 8

  • Follow the guide in the notebook to create the n=3 node graph. First, create your circuit for an n=2 node graph which can be used to build your circuit for an n=3 node graph. Second, construct your W state circuit (refer back to Exercise 3). Third, apply four CSWAP gates.

  • If you are stuck on this approach, have a look at the Figures in Section 3.2.2 in this paper for an alternate idea to construct the circuit.

  • Make sure the bridging gates are as per the paper especially the indexes of control on the two bridging CNOT’s.

  • Ensure you pass in the correct init variable init_3 to prevent parameter mismatch errors.


Exercise 9

  • Have a think about how you constructed the n=3 node graph in Exercise 8 and how you may be able to extend this to a larger n=4 node graph. Have a read through this paper again for more ideas.

  • This section is open ended and can have any approach. Feel free to use any of the approaches above to have the convergence. You may also use the function you made in Exercise 5.