From 4c99079de57014cce8a974211ebc3942bd32171c Mon Sep 17 00:00:00 2001 From: Jorge Saavedra <139413905+JorgeSaavedraB@users.noreply.github.com> Date: Sat, 2 Nov 2024 20:41:57 -0600 Subject: [PATCH 1/5] Corrections for a few typographical errors. --- demonstrations/tutorial_QUBO.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demonstrations/tutorial_QUBO.py b/demonstrations/tutorial_QUBO.py index 3b4a0cbe30..0b336ceedd 100644 --- a/demonstrations/tutorial_QUBO.py +++ b/demonstrations/tutorial_QUBO.py @@ -235,7 +235,7 @@ def time_to_solution(n, time_single_case): # .. math:: S = 2^0 s_0 + 2^1 s_1 + 2^2 s_2 + 2^3 s_3 + 2^4 s_4 # # To compact our equation later, let’s rename our slack variables by :math:`s_0=x_5`, :math:`s_1=x_6,` -# :math:`s_3=x_7`, :math:`s_4=x_8,` and :math:`s_5=x_9.` Then we have +# :math:`s_2=x_7`, :math:`s_3=x_8,` and :math:`s_4=x_9.` Then we have # # .. math:: S = 1 x_5 + 2 x_6 + 4 x_7 + 8 x_8 + 16 x_9. # @@ -352,19 +352,19 @@ def time_to_solution(n, time_single_case): import pennylane as qml shots = 5000 # Number of samples used -dev = qml.device("default.qubit", shots=shots) +dev = qml.device("default.qubit", shots=shots, wires=num_qubits) @qml.qnode(dev) def qaoa_circuit(gammas, betas, h, J, num_qubits): wmax = max( - np.max(np.abs(list(h.values()))), np.max(np.abs(list(h.values()))) + np.max(np.abs(list(h.values()))), np.max(np.abs(list(J.values()))) ) # Normalizing the Hamiltonian is a good idea p = len(gammas) # Apply the initial layer of Hadamard gates to all qubits for i in range(num_qubits): qml.Hadamard(wires=i) - # repeat p layers the circuit shown in Fig. 1 + for layer in range(p): # ---------- COST HAMILTONIAN ---------- for ki, v in h.items(): # single-qubit terms From 70705ff4b0fb90b8cb56ca28291bf21738c54bff Mon Sep 17 00:00:00 2001 From: Jorge Saavedra <139413905+JorgeSaavedraB@users.noreply.github.com> Date: Sat, 2 Nov 2024 21:03:19 -0600 Subject: [PATCH 2/5] Corrections for some typographical errors --- demonstrations/tutorial_QUBO.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demonstrations/tutorial_QUBO.py b/demonstrations/tutorial_QUBO.py index 0b336ceedd..fcef15a19b 100644 --- a/demonstrations/tutorial_QUBO.py +++ b/demonstrations/tutorial_QUBO.py @@ -352,7 +352,7 @@ def time_to_solution(n, time_single_case): import pennylane as qml shots = 5000 # Number of samples used -dev = qml.device("default.qubit", shots=shots, wires=num_qubits) +dev = qml.device("default.qubit", shots=shots) @qml.qnode(dev) From f757ad9d4fbd0c3faedaef029915af0ea126993e Mon Sep 17 00:00:00 2001 From: Jorge Saavedra <139413905+JorgeSaavedraB@users.noreply.github.com> Date: Sat, 2 Nov 2024 21:33:36 -0600 Subject: [PATCH 3/5] Corrections in QUBO tutorial. --- demonstrations/tutorial_QUBO.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demonstrations/tutorial_QUBO.py b/demonstrations/tutorial_QUBO.py index fcef15a19b..86cbc70085 100644 --- a/demonstrations/tutorial_QUBO.py +++ b/demonstrations/tutorial_QUBO.py @@ -356,7 +356,7 @@ def time_to_solution(n, time_single_case): @qml.qnode(dev) -def qaoa_circuit(gammas, betas, h, J, num_qubits): +def qaoa_circuit(gammas, betas, h, J, num_qubits, wires=num_qubits): wmax = max( np.max(np.abs(list(h.values()))), np.max(np.abs(list(J.values()))) ) # Normalizing the Hamiltonian is a good idea From b3ef25d22c8529829a8c79ce73ead6cec4cd94e5 Mon Sep 17 00:00:00 2001 From: Jorge Saavedra <139413905+JorgeSaavedraB@users.noreply.github.com> Date: Sat, 2 Nov 2024 22:01:48 -0600 Subject: [PATCH 4/5] Corrections for some typographical errors in the QUBO tutorial. --- demonstrations/tutorial_QUBO.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demonstrations/tutorial_QUBO.py b/demonstrations/tutorial_QUBO.py index 86cbc70085..d8c8f64035 100644 --- a/demonstrations/tutorial_QUBO.py +++ b/demonstrations/tutorial_QUBO.py @@ -356,7 +356,7 @@ def time_to_solution(n, time_single_case): @qml.qnode(dev) -def qaoa_circuit(gammas, betas, h, J, num_qubits, wires=num_qubits): +def qaoa_circuit(gammas, betas, h, J, num_qubits, wires=n_qubits): wmax = max( np.max(np.abs(list(h.values()))), np.max(np.abs(list(J.values()))) ) # Normalizing the Hamiltonian is a good idea From d32ea655c48688ab599cbd22153ae0a3bc14ff98 Mon Sep 17 00:00:00 2001 From: Jorge Saavedra <139413905+JorgeSaavedraB@users.noreply.github.com> Date: Sun, 3 Nov 2024 00:16:25 -0600 Subject: [PATCH 5/5] Correction in QUBO tutorial --- demonstrations/tutorial_QUBO.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demonstrations/tutorial_QUBO.py b/demonstrations/tutorial_QUBO.py index d8c8f64035..0c14c535e7 100644 --- a/demonstrations/tutorial_QUBO.py +++ b/demonstrations/tutorial_QUBO.py @@ -352,11 +352,11 @@ def time_to_solution(n, time_single_case): import pennylane as qml shots = 5000 # Number of samples used -dev = qml.device("default.qubit", shots=shots) +dev = qml.device("default.qubit", shots=shots, wires=n_qubits) @qml.qnode(dev) -def qaoa_circuit(gammas, betas, h, J, num_qubits, wires=n_qubits): +def qaoa_circuit(gammas, betas, h, J, num_qubits): wmax = max( np.max(np.abs(list(h.values()))), np.max(np.abs(list(J.values()))) ) # Normalizing the Hamiltonian is a good idea