Drift-Balanced Adaptive Constraint Multiplier / noisy_sweep.py

Unverified

Raw ⬇ ZIP
 1import json
 2import numpy as np
 3from experiment import run
 4
 5rows = []
 6for alpha in [.01, .05, .1, .2, .4, .8, 1.6, 3.2, 6.4]:
 7    x = run(alpha, steps=2500, beta=.2, tau=.2, lam_max=5,
 8            batch=16, noisy=True, seed=2346)
 9    tail = slice(1500, None)
10    rows.append({
11        'alpha': alpha,
12        'violation_std': float(np.std(x['v'][tail])),
13        'lambda_std': float(np.std(x['lam'][tail])),
14        'mean_violation': float(np.mean(x['v'][tail])),
15        'cap_fraction': float(np.mean(x['lam'][tail] > 4.999)),
16    })
17with open('noisy_sweep.json', 'w') as f:
18    json.dump({'seed': 2346, 'steps': 2500, 'tail_start': 1500,
19               'batch': 16, 'rows': rows}, f, indent=2)
20print(json.dumps(rows, indent=2))