Skip to content
This repository was archived by the owner on Aug 17, 2026. It is now read-only.

Commit 704e49a

Browse files
committed
correcting for the fact that QVM/QPU returns solution by reverse indices
1 parent d8d92ce commit 704e49a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

grove/pyqaoa/qaoa.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ def unembed_solution(self, embedded_solution):
271271
"""
272272
In case an embedding of logical to physical qubits was used.
273273
Unembedding the solution string since QAOA returns solution string
274-
that is sorted based on indices of physical qubits which might not
275-
match up with qubit ordering in logical space.
274+
that is reverse sorted based on indices of physical qubits which
275+
might not match up with reverse qubit index ordering in logical space.
276276
277277
:param embedded_solution: (list) Solution string returned from QAOA.
278278
:return: Unembedded (correctly ordered) solution string.
279279
:rtype: List.
280280
"""
281-
pos_list = [x[1] for x in sorted(self.inv_embedding.items(),key=lambda x: x[0])]
281+
pos_list = [x[1] for x in sorted(self.inv_embedding.items(),key=lambda x: x[0], reverse=True)]
282282
return tuple([embedded_solution[i] for i,_ in sorted(enumerate(pos_list),key=lambda x: x[1])])

0 commit comments

Comments
 (0)