Skip to content

Commit

Permalink
svaing multiple runs to same file
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiaangelo committed May 15, 2024
1 parent 27363d3 commit a16efff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Ising_mixerXY.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import pandas as pd
import time
import os
from copy import deepcopy

num_rot = 2
Expand Down Expand Up @@ -222,9 +223,9 @@ def generate_initial_bitstring(num_qubits):
"basis_gates": simulator.configuration().basis_gates,
"coupling_map": simulator.configuration().coupling_map,
"seed_simulator": 42,
"shots": 1000,
"shots": 5000,
"optimization_level": 3,
"resilience_level": 0
"resilience_level": 3
}

def callback(quasi_dists, parameters, energy):
Expand Down Expand Up @@ -350,7 +351,13 @@ def calculate_bitstring_energy(bitstring, hamiltonian, backend=None):
}

df = pd.DataFrame(data)
df.to_csv(file_path, index=False)

if not os.path.isfile(file_path):
# File does not exist, write with header
df.to_csv(file_path, index=False)
else:
# File exists, append without writing the header
df.to_csv(file_path, mode='a', index=False, header=False)

# %%
print("\n\nThe result of the noisy quantum optimisation using QAOA is: \n")
Expand Down

0 comments on commit a16efff

Please sign in to comment.