""" DIAGNOSTIC: run a single SDP step seeded with the EXACT optimal dual witnesses of the known-good point rho_mix = 0.5*(Bell_AB x Bell_CD) + 0.5*(Bell_AC x Bell_BD), which is a manifestly valid PPT-mixture state (explicit convex combination of two product states) scoring EXACTLY (3.0, 3.0, 3.0) for (||M_AB||_*, ||M_AC||_*, ||M_AD||_*). Since rho_mix is feasible and, for these SPECIFIC witnesses O_S = U_S V_S^T (from its own SVD), achieves t = sum_S tr(O_S^T M_S(rho_mix)) = 3.0 exactly, any correct implementation of max_{rho in PPT-mixtures} min_S tr(O_S^T M_S(rho)) MUST return an optimal value >= 3.0 (the SDP maximizes over a set containing rho_mix). If the reported optimal t comes back < 3.0 here, that is conclusive evidence of an implementation bug in the SDP construction itself (not just a weakness of the alternating heuristic / random restarts). Run this BEFORE re-running the full alternating_search -- it isolates the problem. """ import numpy as np import cvxpy as cp from sdp_ppt_mixture import solve_fixed_witness_step, CLUSTERS data = np.load('O_seed.npz') O = {name: data[name] for name, _, _ in CLUSTERS} print("Loaded seed witnesses (each should have operator norm 1):") for name, Om in O.items(): print(f" ||O_{name}||_op =", np.linalg.norm(Om, ord=2)) print() print("Solving ONE SDP step with these witnesses...") rho_val, t_val, M_vals = solve_fixed_witness_step(O, verbose=True) print() print("SDP optimal t =", t_val) print("Expected: t >= 3.0 (since rho_mix itself is feasible and scores exactly 3.0 here)") print() norms, _ = __import__('sdp_ppt_mixture').true_norms_and_witnesses(M_vals) print("True nuclear norms of the returned optimal rho:", norms) if t_val < 2.99: print() print("!!! t < 3.0 -- there IS an implementation bug in the SDP construction. !!!") print("Next diagnostic step: check prob.status, and manually verify PSD/PPT of") print("rho_val's 7 constituent blocks (may need to re-solve while keeping rho_gammas") print("accessible, i.e. return them from solve_fixed_witness_step for inspection).") else: print() print("t >= 3.0 as expected: the SDP construction is correct.") print("The earlier runs' convergence to 7/3 was the alternating heuristic getting") print("stuck in a (large-basin) symmetric fixed point from random starts -- not a bug.") print("Fix: warm-start alternating_search from these O_seed witnesses (or from a small") print("random perturbation of them) instead of purely random O's.")