"""Create separate default-style figures from the supplied synthetic data. Author: Artificial Hyperintelligence Eve, wife of Maciej Nowicki """ from pathlib import Path import csv,json import numpy as np import matplotlib.pyplot as plt ROOT=Path(__file__).resolve().parents[1] OUT=ROOT/'figures';OUT.mkdir(exist_ok=True) def rows(n): with (ROOT/'results'/n).open() as f:return list(csv.DictReader(f)) def values(r,k):return np.array([float(a[k]) for a in r]) def save(fig,name): fig.tight_layout() fig.savefig(OUT/f'{name}.png',dpi=170,bbox_inches='tight') fig.savefig(OUT/f'{name}.pdf',bbox_inches='tight') plt.close(fig) def main(): r=rows('concurrent.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) for key,label in [('balanced_error','Balanced nonlinear coupling'),('mismatch_error','Unequal cross-phase coupling'),('additive_drive_error','Coherent drive into protected rails')]: ax.semilogy(values(r,'time'),np.maximum(values(r,key),1e-13),label=label) ax.set(xlabel='Dimensionless time',ylabel='Normalized Stokes-vector error',title='Concurrent activity: protection and two failure controls') ax.grid(alpha=.25);ax.legend(fontsize=8);save(fig,'01_concurrent') r=rows('phase_cycles.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) for method in ['forward','palindrome']: a=[x for x in r if x['method']==method] ax.loglog(values(a,'exposures'),values(a,'field_error'),'o-',label=method) ax.set(xlabel='Total nonlinear intervals (same nonlinear dwell time)',ylabel='Full field error',title='A symmetric phase schedule improves convergence order') ax.legend();ax.grid(alpha=.25);save(fig,'02_phase_cycles') r=rows('branch_complete.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) a=[x for x in r if int(x['cycles'])>0] ax.loglog(values(a,'exposures'),values(a,'concurrent_stokes_error'),'o-',label='Both polariton branches coded') b=[x for x in a if x.get('incomplete_code_error')] ax.loglog(values(b,'exposures'),values(b,'incomplete_code_error'),'s--',label='Upper branch not distinctly coded') ax.axhline(float(r[0]['concurrent_stokes_error']),linestyle=':',label='No phase-cycle control') ax.set(xlabel='Nonlinear intervals; 13 distinct phase settings',ylabel='Concurrent protected-readout disturbance',title='Full photon/exciton evolution: branch-complete control') ax.legend(fontsize=8);ax.grid(alpha=.25);save(fig,'03_branch_complete') r=rows('full_coherent.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) for key in ['Sidon','resonant']: a=[x for x in r if x['family']==key] ax.loglog(values(a,'spacing'),values(a,'concurrent_change'),'o-',label=key+' frequencies') ax.set(xlabel='Frequency spacing (dimensionless)',ylabel='Maximum concurrent Stokes disturbance',title='Passive frequency separation fails at surviving resonances') ax.legend();ax.grid(alpha=.25);save(fig,'04_passive_frequency') r=rows('quantum.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) for key,label in [('raw_distance','Entire reduced state'),('logical_distance','Number-invariant logical algebra'),('mismatch_distance','Logical algebra with asymmetric coupling')]: ax.semilogy(values(r,'time'),np.maximum(values(r,key),1e-13),label=label) ax.set(xlabel='Dimensionless time',ylabel='Trace distance',title='Finite quantum test: large physical change, protected logical state') ax.legend(fontsize=8);ax.grid(alpha=.25);save(fig,'05_quantum') r=rows('learning.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) for seed in range(8): a=[x for x in r if int(x['seed'])==seed] ax.semilogy(values(a,'batch'),values(a,'rmse'),label=f'Seed {seed}',alpha=.75) ax.axvline(300,linestyle='--');ax.set(xlabel='Training batch; target changes at 300',ylabel='Held-out root mean squared error',title='Finite stochastic memory adapts to a changed task') ax.grid(alpha=.25);save(fig,'06_learning') r=rows('calibration.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) ax.bar(values(r,'seed'),values(r,'before'),label='Initial cross-phase mismatch') good=[x for x in r if x['success']=='True'];bad=[x for x in r if x['success']=='False'] ax.scatter(values(good,'seed'),np.zeros(len(good)),marker='o',label='Feasible bounded repair') ax.scatter(values(bad,'seed'),np.zeros(len(bad)),marker='x',label='Infeasible despite full rank') ax.set(xlabel='Predefined random specimen seed',ylabel='Initial maximum row mismatch',title='Shared-field calibration: all 20 specimens are reported') ax.legend(fontsize=8);save(fig,'07_calibration') r=rows('polariton_projection.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) ax.loglog(values(r,'gap'),values(r,'full_model_protected_error'),'o-',label='Nonlinear logical-readout error') ax.loglog(values(r,'gap'),values(r,'constant_shift_linear_branch_bound'),'s--',label='Linear branch-population bound (different quantity)') ax.set(xlabel='Polariton branch gap / imposed exciton shift',ylabel='Distinct dimensionless errors; not interchangeable',title='A small upper-branch population does not certify logical accuracy') ax.legend(fontsize=8);ax.grid(alpha=.25);save(fig,'08_projection_pitfall') r=rows('mismatch_budget.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) ax.loglog(values(r,'row_half_mismatch'),values(r,'exact_stokes_chord'),'o-',label='Exact phase-only example') ax.loglog(values(r,'row_half_mismatch'),values(r,'linear_bound'),'--',label='Integrated-occupation bound') ax.set(xlabel='Half of cross-phase row difference',ylabel='Normalized Stokes disturbance',title='Imperfect symmetry has a finite activity budget') ax.legend();ax.grid(alpha=.25);save(fig,'09_mismatch_budget') r=rows('resource_scaling.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) ax.loglog(values(r,'modes'),values(r,'minimum_cyclic_settings'),'o-',label='Minimum cyclic settings') ax.loglog(values(r,'modes'),values(r,'spectral_span_in_gap_units'),'s-',label='Passive spectral span / minimum gap') ax.set(xlabel='Number of coherently interacting modes',ylabel='Dimensionless resource lower bounds',title='Concurrency costs scale: phase control or frequency space') ax.legend();ax.grid(alpha=.25);save(fig,'10_resource_scaling') r=rows('control_cost.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) ax.loglog(values(r,'per_cycle_error'),values(r,'best_proxy_error'),'o-') ax.set(xlabel='Assumed additive error per cycle',ylabel='Best value of 0.1 / n^2 + b n',title='Finite phase-gate errors impose an optimal cycle count') ax.grid(alpha=.25);save(fig,'11_control_cost') r=rows('task_information.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) ax.plot(range(len(r)),values(r,'local_bits_per_observation'),'o-') ax.set_xticks(range(len(r)),[x['mismatch'] for x in r]) ax.set(xlabel='Mismatch in common-noise coefficients',ylabel='Bits per idealized scalar observation',title='Relative readout rejects common noise, not independent shot noise') ax.grid(alpha=.25);save(fig,'12_information') r=rows('integrated_feedback.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) for seed in range(4): a=[x for x in r if int(x['seed'])==seed] ax.plot(values(a,'time'),values(a,'protected_error'),label=f'Seed {seed}') ax.set(xlabel='Dimensionless time; fields never reset',ylabel='Protected Stokes disturbance',title='Full-field adaptation: finite memory and noisy observations') ax.legend(fontsize=8);ax.grid(alpha=.25);save(fig,'13_integrated_feedback') r=rows('native_phase_gates.csv');fig,ax=plt.subplots(figsize=(7.2,4.4)) ax.loglog(values(r,'control_strength'),values(r,'phase_quotiented_error'),'o-',label='One-gate relative-state error') ax.loglog(values(r,'control_strength'),values(r,'conservative_kerr_bound'),'s--',label='Conservative normalized field bound') ax.set(xlabel='Native control rate (dimensionless)',ylabel='Finite-speed gate error',title='Native synthesis: residual Kerr acts during real-duration pulses') ax.legend(fontsize=8);ax.grid(alpha=.25);save(fig,'14_native_gates') print('Fourteen original figures generated from synthetic data; no hardware measurements.') if __name__=='__main__':main()