Skip to content

Commit

Permalink
count all valid bitstrings with each appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiaangelo committed May 21, 2024
1 parent 11a76d6 commit 635fab0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Ising_mixerXY.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from copy import deepcopy

num_rot = 2
file_path = "RESULTS/XY-QAOA/4res-2rot.csv"
file_path = "RESULTS/XY-QAOA/5res-2rot.csv"
file_path_depth = "RESULTS/Depths/XY-QAOA/4res-2rot.csv"

########################### Configure the hamiltonian from the values calculated classically with pyrosetta ############################
Expand Down Expand Up @@ -323,7 +323,8 @@ def calculate_bitstring_energy(bitstring, hamiltonian, backend=None):
all_bitstrings[bitstring]['count'] += 1

total_bitstrings = len(final_bitstrings) + sum(len(data['quasi_distributions'][0]) for data in intermediate_data)
hamming_satisfying_bitstrings = len(all_bitstrings)
# hamming_satisfying_bitstrings = len(all_bitstrings)
hamming_satisfying_bitstrings = sum(bitstring_data['count'] for bitstring_data in all_bitstrings.values())
fraction_satisfying_hamming = hamming_satisfying_bitstrings / total_bitstrings
print(f"Fraction of bitstrings that satisfy the Hamming constraint: {fraction_satisfying_hamming}")

Expand Down

0 comments on commit 635fab0

Please sign in to comment.