diff options
| author | ottjk <joshott16@gmail.com> | 2023-12-05 23:39:46 -0500 |
|---|---|---|
| committer | ottjk <joshott16@gmail.com> | 2023-12-05 23:39:46 -0500 |
| commit | cbd5da1ba1524e1a50376f50d2867482fed10383 (patch) | |
| tree | 46d24d15845afc5a01ca78c949012e494cb9812e /prob_plots.py | |
| parent | 427f50d3c93432ff85caac923fac10191d519d49 (diff) | |
| download | graph-coloring-cbd5da1ba1524e1a50376f50d2867482fed10383.tar.gz graph-coloring-cbd5da1ba1524e1a50376f50d2867482fed10383.zip | |
update
Diffstat (limited to 'prob_plots.py')
| -rw-r--r-- | prob_plots.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/prob_plots.py b/prob_plots.py new file mode 100644 index 0000000..741eaec --- /dev/null +++ b/prob_plots.py @@ -0,0 +1,27 @@ +from main import * + +import matplotlib +matplotlib.use('module://matplotlib-backend-sixel') +import matplotlib.pyplot as plt + +n_layers = 4 + +def get_probs(qc): + print(f'Finding probabilities for {qc.n_vertices}-vertex graph') + params = qc.qaoa_color() + probs = qc.probability_circuit(params) + print(f"{len(probs[probs > max(probs) * 3/4])}") + + plot = plt.bar(range(2 ** qc.n_wires), probs) + plt.savefig(f'figures/{qc.n_vertices}-node-probs.pdf') + +n_vertices = 5 +graph = [(0,1),(0,2),(0,3),(0,4),(1,2),(1,3),(2,3),(2,4),(3,4)] +qc_5 = QC(graph, n_vertices, n_layers) + +n_vertices = 6 +graph = [(0,1),(0,2),(0,3),(0,4),(0,5),(1,2),(2,3),(3,4),(4,5),(5,1)] +qc_6 = QC(graph, n_vertices, n_layers) + +# get_probs(qc_5) +get_probs(qc_6) |