|
128 | 128 | """ |
129 | 129 | Plotting Data |
130 | 130 | """ |
131 | | - # fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(16, 8)) |
132 | | - |
133 | | - # fig.suptitle(r"VQO of Non-$n$-Locality on IBM Quantum Computers", size=24, fontweight="bold") |
134 | | - |
135 | | - # axes = [ax1, ax2, ax3, ax4] |
136 | | - # titles = [ |
137 | | - # "CHSH Network", |
138 | | - # "Bilocal Network", |
139 | | - # "\nTrilocal Chain Network", |
140 | | - # "\nTrilocal Star Network", |
141 | | - # ] |
142 | | - # ylabels = [ |
143 | | - # r"Bell Score ($S_{\mathrm{CHSH}}$)", |
144 | | - # r"Bell Score ($S_{\mathrm{Bilocal}}$)", |
145 | | - # r"Bell Score ($S_{3\mathrm{-Chain}}$)", |
146 | | - # r"Bell Score ($S_{3\mathrm{-Star}}$)", |
147 | | - # ] |
148 | | - # num_steps_list = [num_chsh_steps, num_bilocal_steps, num_chain_steps, num_star_steps] |
149 | | - # quantum_bounds = [2 * np.sqrt(2), np.sqrt(2), np.sqrt(2), np.sqrt(2)] |
150 | | - # classical_bounds = [2, 1, 1, 1] |
151 | | - # ideal_data_sets = [ |
152 | | - # chsh_ideal_scores, |
153 | | - # bilocal_ideal_scores, |
154 | | - # chain_ideal_scores, |
155 | | - # star_ideal_scores, |
156 | | - # ] |
157 | | - # data_sets = [chsh_data, bilocal_data, chain_data, star_data] |
158 | | - # for i in range(4): |
159 | | - # ax = axes[i] |
160 | | - # num_steps = num_steps_list[i] |
161 | | - |
162 | | - # ax.plot( |
163 | | - # range(num_steps), |
164 | | - # [quantum_bounds[i]] * num_steps, |
165 | | - # "-", |
166 | | - # linewidth=3, |
167 | | - # label="Quantum\nBound", |
168 | | - # color="C0", |
169 | | - # ) |
170 | | - # ax.plot( |
171 | | - # range(num_steps), |
172 | | - # [classical_bounds[i]] * num_steps, |
173 | | - # "--", |
174 | | - # linewidth=3, |
175 | | - # label="Classical\nBound", |
176 | | - # color="C1", |
177 | | - # ) |
178 | | - # ax.plot( |
179 | | - # range(num_steps), |
180 | | - # [data_sets[i]["max_theoretical_score"]] * num_steps, |
181 | | - # linestyle=(0, (3, 2, 1, 2, 1, 2)), |
182 | | - # linewidth=3, |
183 | | - # label="Theoretical\nMax Score", |
184 | | - # color="C6", |
185 | | - # ) |
186 | | - # ax.plot( |
187 | | - # range(num_steps), |
188 | | - # [data_sets[i]["mean_theoretical_score"]] * num_steps, |
189 | | - # "-.", |
190 | | - # label="Theoretical\nMean Score", |
191 | | - # linewidth=3, |
192 | | - # color="C5", |
193 | | - # ) |
194 | | - # ax.plot( |
195 | | - # range(num_steps), |
196 | | - # ideal_data_sets[i], |
197 | | - # ":d", |
198 | | - # markersize=8, |
199 | | - # linewidth=3, |
200 | | - # label="Noiseless\nOptimized\nMax Score", |
201 | | - # color="C2", |
202 | | - # ) |
203 | | - # ax.plot( |
204 | | - # range(num_steps), |
205 | | - # data_sets[i]["max_scores"], |
206 | | - # ":o", |
207 | | - # markersize=7, |
208 | | - # linewidth=3, |
209 | | - # label="Optimized\nMax Score", |
210 | | - # color="C3", |
211 | | - # ) |
212 | | - # ax.errorbar( |
213 | | - # range(num_steps), |
214 | | - # data_sets[i]["mean_scores"], |
215 | | - # data_sets[i]["stderr_scores"], |
216 | | - # linestyle=":", |
217 | | - # linewidth=3, |
218 | | - # label="Optimized\nMean Score", |
219 | | - # color="C4", |
220 | | - # ) |
221 | | - |
222 | | - # ax.set_title(titles[i], size=20) |
223 | | - # if i >= 2: |
224 | | - # ax.set_xlabel("Gradient Descent Step", size=18) |
225 | | - |
226 | | - # ax.set_ylabel(ylabels[i], size=18) |
227 | | - |
228 | | - # if i == 0: |
229 | | - # plt.figlegend( |
230 | | - # ncol=1, |
231 | | - # loc="center right", |
232 | | - # fontsize=18, |
233 | | - # bbox_to_anchor=(0, 0, 1, 1), |
234 | | - # labelspacing=1.1, |
235 | | - # ) # , bbox_to_anchor=(0, 0,1,1,)) |
236 | | - |
237 | | - # fig.subplots_adjust(left=0.05, right=0.82) |
| 131 | + fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(16, 8)) |
238 | 132 |
|
239 | | - # datetime_ext = datetime.utcnow().strftime("%Y-%m-%dT%H-%M-%SZ") |
240 | | - # filename = "simple_ansatzes_" + datetime_ext |
241 | | - # plot_dir = "data/plots/vqo_ibm_hardware/" |
242 | | - |
243 | | - fig, (ax2) = plt.subplots(1, 1, figsize=(25, 18)) |
244 | | - |
245 | | - fig.suptitle("VQO of Star Network Nonlocality on\nNoisy IBM Quantum Computers", size=80, fontweight="bold") |
246 | | - |
247 | | - num_steps = num_star_steps |
248 | | - quantum_bound = np.sqrt(2) |
249 | | - classical_bound = 1 |
250 | | - ideal_data_set = star_ideal_scores |
251 | | - data_set = star_data |
252 | | - |
253 | | - ax2.semilogy( |
254 | | - range(num_steps), |
255 | | - np.sqrt(2) - data_set["mean_scores"], |
256 | | - linestyle=":", |
257 | | - marker="s", |
258 | | - markersize=32, |
259 | | - linewidth=8, |
260 | | - label="VQO Mean", |
261 | | - color="C4", |
262 | | - ) |
263 | | - ax2.semilogy( |
264 | | - range(num_steps), |
265 | | - np.sqrt(2) - data_set["max_scores"], |
266 | | - ":o", |
267 | | - markersize=32, |
268 | | - linewidth=10, |
269 | | - label="VQO Max", |
270 | | - color="C3", |
271 | | - ) |
272 | | - ax2.semilogy( |
273 | | - range(num_steps), |
274 | | - np.sqrt(2) - ideal_data_set, |
275 | | - ":d", |
276 | | - markersize=32, |
277 | | - linewidth=10, |
278 | | - label="Noiseless VQO Max", |
279 | | - color="C2", |
280 | | - ) |
281 | | - |
282 | | - ax2.semilogy( |
283 | | - range(num_steps), |
284 | | - np.sqrt(2) - [classical_bound] * num_steps, |
285 | | - "--", |
286 | | - linewidth=10, |
287 | | - label="Classical Bound", |
288 | | - color="C0", |
289 | | - ) |
290 | | - ax2.semilogy( |
291 | | - range(num_steps), |
292 | | - np.sqrt(2) - [data_set["mean_theoretical_score"]] * num_steps, |
293 | | - "-.", |
294 | | - label="Noisy Quantum Bound", |
295 | | - linewidth=10, |
296 | | - color="C1", |
297 | | - ) |
298 | | - ax2.legend( |
299 | | - ncol=1, |
300 | | - fontsize=56, |
301 | | - loc="lower left", |
302 | | - ) |
| 133 | + fig.suptitle(r"VQO of Non-$n$-Locality on IBM Quantum Computers", size=24, fontweight="bold") |
303 | 134 |
|
304 | | - # ax1.tick_params(axis='both', which='major', labelsize=52) |
305 | | - ax2.tick_params(axis='both', which='major', labelsize=56) |
| 135 | + axes = [ax1, ax2, ax3, ax4] |
| 136 | + titles = [ |
| 137 | + "CHSH Network", |
| 138 | + "Bilocal Network", |
| 139 | + "\nTrilocal Chain Network", |
| 140 | + "\nTrilocal Star Network", |
| 141 | + ] |
| 142 | + ylabels = [ |
| 143 | + r"Bell Score ($S_{\mathrm{CHSH}}$)", |
| 144 | + r"Bell Score ($S_{\mathrm{Bilocal}}$)", |
| 145 | + r"Bell Score ($S_{3\mathrm{-Chain}}$)", |
| 146 | + r"Bell Score ($S_{3\mathrm{-Star}}$)", |
| 147 | + ] |
| 148 | + num_steps_list = [num_chsh_steps, num_bilocal_steps, num_chain_steps, num_star_steps] |
| 149 | + quantum_bounds = [2 * np.sqrt(2), np.sqrt(2), np.sqrt(2), np.sqrt(2)] |
| 150 | + classical_bounds = [2, 1, 1, 1] |
| 151 | + ideal_data_sets = [ |
| 152 | + chsh_ideal_scores, |
| 153 | + bilocal_ideal_scores, |
| 154 | + chain_ideal_scores, |
| 155 | + star_ideal_scores, |
| 156 | + ] |
| 157 | + data_sets = [chsh_data, bilocal_data, chain_data, star_data] |
| 158 | + for i in range(4): |
| 159 | + ax = axes[i] |
| 160 | + num_steps = num_steps_list[i] |
| 161 | + |
| 162 | + ax.plot( |
| 163 | + range(num_steps), |
| 164 | + [quantum_bounds[i]] * num_steps, |
| 165 | + "-", |
| 166 | + linewidth=3, |
| 167 | + label="Quantum\nBound", |
| 168 | + color="C0", |
| 169 | + ) |
| 170 | + ax.plot( |
| 171 | + range(num_steps), |
| 172 | + [classical_bounds[i]] * num_steps, |
| 173 | + "--", |
| 174 | + linewidth=3, |
| 175 | + label="Classical\nBound", |
| 176 | + color="C1", |
| 177 | + ) |
| 178 | + ax.plot( |
| 179 | + range(num_steps), |
| 180 | + [data_sets[i]["max_theoretical_score"]] * num_steps, |
| 181 | + linestyle=(0, (3, 2, 1, 2, 1, 2)), |
| 182 | + linewidth=3, |
| 183 | + label="Theoretical\nMax Score", |
| 184 | + color="C6", |
| 185 | + ) |
| 186 | + ax.plot( |
| 187 | + range(num_steps), |
| 188 | + [data_sets[i]["mean_theoretical_score"]] * num_steps, |
| 189 | + "-.", |
| 190 | + label="Theoretical\nMean Score", |
| 191 | + linewidth=3, |
| 192 | + color="C5", |
| 193 | + ) |
| 194 | + ax.plot( |
| 195 | + range(num_steps), |
| 196 | + ideal_data_sets[i], |
| 197 | + ":d", |
| 198 | + markersize=8, |
| 199 | + linewidth=3, |
| 200 | + label="Noiseless\nOptimized\nMax Score", |
| 201 | + color="C2", |
| 202 | + ) |
| 203 | + ax.plot( |
| 204 | + range(num_steps), |
| 205 | + data_sets[i]["max_scores"], |
| 206 | + ":o", |
| 207 | + markersize=7, |
| 208 | + linewidth=3, |
| 209 | + label="Optimized\nMax Score", |
| 210 | + color="C3", |
| 211 | + ) |
| 212 | + ax.errorbar( |
| 213 | + range(num_steps), |
| 214 | + data_sets[i]["mean_scores"], |
| 215 | + data_sets[i]["stderr_scores"], |
| 216 | + linestyle=":", |
| 217 | + linewidth=3, |
| 218 | + label="Optimized\nMean Score", |
| 219 | + color="C4", |
| 220 | + ) |
| 221 | + |
| 222 | + ax.set_title(titles[i], size=20) |
| 223 | + if i >= 2: |
| 224 | + ax.set_xlabel("Gradient Descent Step", size=18) |
| 225 | + |
| 226 | + ax.set_ylabel(ylabels[i], size=18) |
| 227 | + |
| 228 | + if i == 0: |
| 229 | + plt.figlegend( |
| 230 | + ncol=1, |
| 231 | + loc="center right", |
| 232 | + fontsize=18, |
| 233 | + bbox_to_anchor=(0, 0, 1, 1), |
| 234 | + labelspacing=1.1, |
| 235 | + ) # , bbox_to_anchor=(0, 0,1,1,)) |
| 236 | + |
| 237 | + fig.subplots_adjust(left=0.05, right=0.82) |
306 | 238 |
|
307 | | - # ax1.set_xlabel("Gradient Descent Step", fontsize=52) |
308 | | - ax2.set_xlabel("Gradient Descent Step", fontsize=72) |
| 239 | + datetime_ext = datetime.utcnow().strftime("%Y-%m-%dT%H-%M-%SZ") |
| 240 | + filename = "simple_ansatzes_" + datetime_ext |
| 241 | + plot_dir = "data/plots/vqo_ibm_hardware/" |
309 | 242 |
|
310 | | - # ax1.set_ylabel("Nonlocal Star Score", fontsize=52) |
311 | | - ax2.set_ylabel("Distance to Max Bell Violation", fontsize=72) |
312 | 243 |
|
313 | | - plt.grid(linewidth=4) |
314 | | - fig.tight_layout(pad=2) |
| 244 | + # """ |
| 245 | + # semilog plot of data |
| 246 | + # """ |
| 247 | + |
| 248 | + # fig, (ax2) = plt.subplots(1, 1, figsize=(25, 18)) |
| 249 | + |
| 250 | + # fig.suptitle("VQO of Star Network Nonlocality on\nNoisy IBM Quantum Computers", size=80, fontweight="bold") |
| 251 | + |
| 252 | + # num_steps = num_star_steps |
| 253 | + # quantum_bound = np.sqrt(2) |
| 254 | + # classical_bound = 1 |
| 255 | + # ideal_data_set = star_ideal_scores |
| 256 | + # data_set = star_data |
| 257 | + |
| 258 | + # ax2.semilogy( |
| 259 | + # range(num_steps), |
| 260 | + # np.sqrt(2) - data_set["mean_scores"], |
| 261 | + # linestyle=":", |
| 262 | + # marker="s", |
| 263 | + # markersize=32, |
| 264 | + # linewidth=8, |
| 265 | + # label="VQO Mean", |
| 266 | + # color="C4", |
| 267 | + # ) |
| 268 | + # ax2.semilogy( |
| 269 | + # range(num_steps), |
| 270 | + # np.sqrt(2) - data_set["max_scores"], |
| 271 | + # ":o", |
| 272 | + # markersize=32, |
| 273 | + # linewidth=10, |
| 274 | + # label="VQO Max", |
| 275 | + # color="C3", |
| 276 | + # ) |
| 277 | + # ax2.semilogy( |
| 278 | + # range(num_steps), |
| 279 | + # np.sqrt(2) - ideal_data_set, |
| 280 | + # ":d", |
| 281 | + # markersize=32, |
| 282 | + # linewidth=10, |
| 283 | + # label="Noiseless VQO Max", |
| 284 | + # color="C2", |
| 285 | + # ) |
| 286 | + |
| 287 | + # ax2.semilogy( |
| 288 | + # range(num_steps), |
| 289 | + # np.sqrt(2) - [classical_bound] * num_steps, |
| 290 | + # "--", |
| 291 | + # linewidth=10, |
| 292 | + # label="Classical Bound", |
| 293 | + # color="C0", |
| 294 | + # ) |
| 295 | + # ax2.semilogy( |
| 296 | + # range(num_steps), |
| 297 | + # np.sqrt(2) - [data_set["mean_theoretical_score"]] * num_steps, |
| 298 | + # "-.", |
| 299 | + # label="Noisy Quantum Bound", |
| 300 | + # linewidth=10, |
| 301 | + # color="C1", |
| 302 | + # ) |
| 303 | + # ax2.legend( |
| 304 | + # ncol=1, |
| 305 | + # fontsize=56, |
| 306 | + # loc="lower left", |
| 307 | + # ) |
| 308 | + # ax2.tick_params(axis='both', which='major', labelsize=56) |
| 309 | + |
| 310 | + # ax2.set_xlabel("Gradient Descent Step", fontsize=72) |
| 311 | + |
| 312 | + # ax2.set_ylabel("Distance to Max Bell Violation", fontsize=72) |
| 313 | + |
| 314 | + # plt.grid(linewidth=4) |
| 315 | + # fig.tight_layout(pad=2) |
315 | 316 |
|
316 | 317 |
|
317 | | - datetime_ext = datetime.utcnow().strftime("%Y-%m-%dT%H-%M-%SZ") |
318 | | - filename = "simple_ansatzes_" + datetime_ext |
319 | | - plot_dir = "data/plots/vqo_ibm_hardware/" |
| 318 | + # datetime_ext = datetime.utcnow().strftime("%Y-%m-%dT%H-%M-%SZ") |
| 319 | + # filename = "simple_ansatzes_" + datetime_ext |
| 320 | + # plot_dir = "data/plots/vqo_ibm_hardware/" |
320 | 321 |
|
321 | | - plt.savefig(plot_dir + filename) |
| 322 | + # plt.savefig(plot_dir + filename) |
0 commit comments