quantum-shadow-maps_v2/scripts/dps_hierarchy/07_dps_level3_single.py
2026-07-26 14:09:49 +02:00

30 lines
1.3 KiB
Python

"""
07_dps_level3_single.py
A single DPS level-3 feasibility check on the pure Tiles state, to confirm
the construction works and see its cost before committing to a full
noise-threshold bisection (see 08_dps_level_k_bisection.py).
In the original sandbox this took ~137s with SCS (single solve, cold
start). Expect similar or better on a modern laptop; likely far faster
with an interior-point solver (MOSEK, if you have a license) since the
PSD cone here (81x81 complex Hermitian) is small by modern SDP standards
-- SCS is a first-order method tuned for large sparse problems and is not
especially fast on small/dense feasibility problems like this one.
Expected result: status "infeasible" (i.e. entanglement IS detected).
"""
import time
import cvxpy as cp
from common import RHO_TILES
from dps_hierarchy import build_dps_problem, dps_feasible
SOLVER = cp.SCS # try cp.MOSEK if available -- likely much faster at this size
prob, rho_param, sigma = build_dps_problem(d=3, k=3)
print(f"sigma shape: {sigma.shape} "
f"PPT-constraint (PSD cone) size: {3 * 3 ** 3} x {3 * 3 ** 3}")
t0 = time.time()
ok = dps_feasible(prob, rho_param, RHO_TILES, solver=SOLVER, eps=1e-6, max_iters=20000)
print(f"DPS level-3 feasible: {ok} status={prob.status} [{time.time() - t0:.1f}s]")