Manuscript En02-D@4 · En02-D-v4.tex · section · e19ec871
Computational supplement
Computational supplement · lines 2257–2332
def compile_tex(tex): tex = Path(tex).resolve() need(tex.exists(),"missing TeX source") target = ROOT/tex.name shutil.copy2(tex,target) for run in (1,2): p = subprocess.run(["pdflatex","-interaction=nonstopmode", "-halt-on-error",target.name], cwd=ROOT,stdout=subprocess.PIPE, stderr=subprocess.STDOUT,text=True) (ROOT/("pdflatex_run_ need(p.returncode==0,"pdfLaTeX failure") need((ROOT/(tex.stem+".pdf")).exists(),"missing compiled PDF")
def main(): global ROOT,SOLVER parser = argparse.ArgumentParser() parser.add_argument("–mode",choices=("audit","pilot","extend"),default="audit") parser.add_argument("–solver",default="SCS") parser.add_argument("–tex") parser.add_argument("–compile",action="store_true") args = parser.parse_args() SOLVER = args.solver stamp = datetime.datetime.now(datetime.timezone.utc).strftime(" ROOT = Path("en02d_v4_"+stamp) ROOT.mkdir() source = Path(__file__).resolve() shutil.copy2(source,ROOT/source.name) manifest = "status":"RUNNING","mode":args.mode,"python":sys.version, "numpy":np.__version__,"solver":SOLVER, "audit_tolerance":TOL,"solver_tolerance":STOL, "source_sha256":hashlib.sha256(source.read_bytes()).hexdigest(), "synthetic":True,"formal_certificate":False path = ROOT/"manifest.json" path.write_text(json.dumps(manifest,indent=2)) try: benchN,expected = benchmark_audit() loss_domain_audit() transport_audit() multiparticle_audit() absorption_audit() for e in range(5): for m in range(3): ops = stream_ops(e,m) check("generic_stream_Kraus_ sum((A.conj().T@A for A,rec in ops), np.zeros((2**e,2**e),complex)),np.eye(2**e)) if args.mode!="audit": import cvxpy manifest["cvxpy"] = cvxpy.__version__ manifest["installed_solvers"] = cvxpy.installed_solvers() need(SOLVER in cvxpy.installed_solvers(),"solver not installed") solver_audit(benchN,expected) pilot(3) if args.mode=="extend": pilot(4) if args.compile: need(args.tex is not None,"–compile requires –tex") compile_tex(args.tex) elif args.tex: shutil.copy2(Path(args.tex),ROOT/Path(args.tex).name) dump() manifest["status"] = "NUMERICAL_CHECKS_AND_COMPILATION_PASSED" \ if args.compile else "NUMERICAL_CHECKS_PASSED_COMPILATION_NOT_RUN" manifest["scope"] = "finite floating-point regression; not certified optimum" except BaseException: dump() (ROOT/"failure.txt").write_text(traceback.format_exc()) manifest["status"] = "FAILED" path.write_text(json.dumps(manifest,indent=2)) raise finally: manifest["artifact_sha256"] = { f.name:hashlib.sha256(f.read_bytes