Skip to content

Commit

Permalink
Ignore imaginary terms of problem matrix
Browse files Browse the repository at this point in the history
If the imaginary part of all matrix elemts is zero, the matrix is tranformed into a real matrix. If there are imaginary terms != 0, a warning is lgged.
  • Loading branch information
Marvmann authored Mar 26, 2024
1 parent 4eef3de commit 3c9b29e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/solvers/QAOA.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ def run(self, mapped_problem: any, device_wrapper: any, config: Config, **kwargs
"""

j = mapped_problem['J']

if np.any(np.iscomplex(j)):
logging.warning("The problem matrix of the QAOA solver contains imaginary numbers."
"This may lead to an error later in the run.")
else:
j = np.real(j)

Check failure on line 159 in src/modules/solvers/QAOA.py

View workflow job for this annotation

GitHub Actions / Pylint

src/modules/solvers/QAOA.py#L159

Trailing whitespace (trailing-whitespace, C0303)
# set up the problem
n_qubits = j.shape[0]

Expand Down

0 comments on commit 3c9b29e

Please sign in to comment.