You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
full naive solution vector: [-0.1197614 0.13218384]`
classical state: [-0.17013578 -0.05340129]
There seems to be a rather large discrepancy in the results. When I rounded each element of the matrix to an integer, the answer was correct again. I'm not sure what would cause this error.
How can we reproduce the issue?
Here's my code:
import numpy as np
from linear_solvers import NumPyLinearSolver, HHL
from qiskit.quantum_info import Statevector
from matplotlib import pyplot as plt
matrix = np.array([ [19.98, -10], [-10, 19.98] ])
vector = np.array([-2.8653, 0.6344])
naive_hhl_solution = HHL().solve(matrix/(np.linalg.norm(vector)), vector/(np.linalg.norm(vector)))
classical_solution = NumPyLinearSolver().solve(matrix, vector)
def get_solution_vector(solution):
"""Extracts and normalizes simulated state vector
from LinearSolverResult."""
solution_vector = Statevector(solution.state).data[16:18].real
norm = solution.euclidean_norm
return norm * solution_vector / np.linalg.norm(solution_vector)
print('full naive solution vector:',get_solution_vector(naive_hhl_solution))
print('classical state:', classical_solution.state)
Any help would be greatly appreciated.
Thanks!
What should happen?
Please explain why the HHL algorithm results in this disagreement between the results.
Any suggestions?
No response
The content you are editing has changed. Please copy your edits and refresh the page.
The deprecated modules factorizers and linear_solvers, containing HHL and Shor have been removed from qiskit.algorithms. These functionalities were originally deprecated as part of the 0.22.0 release (released on October 13, 2022). You can access the code through the Qiskit Textbook instead: Linear Solvers (HHL) , Factorizers (Shor)
As you will find in the textbook for HHL the code that was in Qiskit was relocated here https://github.com/anedumla/quantum_linear_solvers and I created an issue there linking to the set of issues in HHL that were still unresolved at the time which were simply closed when the code was removed #9832 You might find a similar issue there with some info.
I will also note that qiskit.algorithms was deprecated and had already been removed from the main branch here in readiness for the next release. The function was moved here to separate pkg/repo https://github.com/qiskit-community/qiskit-algorithms - that does not include HHL either since it had already been removed at the time the code was relocated.
As this code no longer exists and is no longer supported I am closing this. If your code comes from the other repository I suggest opening the issue there although I am not sure if there is any activity there any more either.
Environment
What is happening?
Hello, I am trying to compare the HHL algorithm to classical methods. I'm testing the algorithm for a 2x2 case where A and b are:
Running the algorithms give:
There seems to be a rather large discrepancy in the results. When I rounded each element of the matrix to an integer, the answer was correct again. I'm not sure what would cause this error.
How can we reproduce the issue?
Here's my code:
Any help would be greatly appreciated.
Thanks!
What should happen?
Please explain why the HHL algorithm results in this disagreement between the results.
Any suggestions?
No response
Tasks
The text was updated successfully, but these errors were encountered: