Ersetzt die irrefuehrende Oracle-Leiter durch eine ehrliche Messmethodik (Oracle aus, Read via Memory/Posterior gegen eine gezogene Gegner-Population). Stufen: - 0 Exploitation-Luecke: +18.98 bb/100 gegen die gezogene Population - 1 Kalibrierung an echte HUD-Daten (lesen/kalibrierung.py) - 2 Zwillings-Tor (EGTA + Exploitability-Waechter): Offense +43.95, Boden gto -36.25 (verliert gegen Balancierte - die Oracle-verdeckte Wurzel) - 3 Adaptive Liga L0-L3 (reaktiv / modellierend / Liga) - 4 Sim-to-Real: HUD-Gap (sim::simreal) + Outcome-Abgleich (lesen/liveabgleich.py): real -266.75 vs Sim +43.95 => Gap -311; A/B-Pipeline + Runbook fertig, nur der geldechte Live-Lauf unter beiden Armen bleibt offen - 5 Optimizer (Diagonal-CMA-ES, parallel): Nemesis -414.81 bb/100 Befunde und Architektur in docs/notizen/. Lab-Tests gruen (Rust lib 92/0, python liveabgleich/kalibrierung/gegnersignal gruen). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
3.8 KiB
Rust
73 lines
3.8 KiB
Rust
//! Is the benchmark's variance reduction world-class, or just a fixed beta=1 guess?
|
|
//!
|
|
//! The ladder stores, per deal, hero's net result corrected by a luck control signal: `net - luck`
|
|
//! (`sim::session`). That is a control variate with coefficient FIXED at beta = 1. Because the luck
|
|
//! signal has expectation ~0, `net - beta*luck` is unbiased for EVERY beta, and the
|
|
//! variance-minimising coefficient is beta* = Cov(net, luck) / Var(luck) -- not necessarily 1.
|
|
//! AIVAT learns beta* by cross-fitting (`sim::aivat`), so it never beats the raw estimator by less
|
|
//! and, when beta* != 1, beats the hard-coded beta = 1 too.
|
|
//!
|
|
//! This binary MEASURES the gap on real sim data, for the high-variance scenarios the ladder cares
|
|
//! about, before any estimator change. Same mean across all three estimators = unbiased; the CI
|
|
//! ratios say how much, if anything, cross-fitting buys over the current bench.
|
|
//!
|
|
//! Run: `cargo run --release --bin aivat_bench`.
|
|
|
|
use rechner::sim::aivat::{control_variate, raw};
|
|
use rechner::sim::opponent::Opponent;
|
|
use rechner::sim::reader::Style;
|
|
use rechner::sim::session::{deal_net_and_luck, ReadMode, Setup};
|
|
|
|
const SEED: u64 = 0x5EED_0001;
|
|
const STACK_BB: f64 = 100.0;
|
|
const FOLDS: usize = 10;
|
|
|
|
fn setup(players: u8, opponent: Opponent, deals: u32, read: ReadMode) -> Setup {
|
|
Setup { players, opponent, deals, stack_bb: STACK_BB, seed: SEED, read }
|
|
}
|
|
|
|
/// A single-run win-rate estimate three ways. `beta = 0` is the raw mean; `beta = 1` is the ladder's
|
|
/// current luck-corrected sample; `beta*` is the cross-fitted AIVAT control variate. Units: bb/100.
|
|
fn report(name: &str, s: &Setup) {
|
|
let (net, luck) = deal_net_and_luck(s);
|
|
let n = net.len();
|
|
|
|
// beta = 0: raw net, no correction.
|
|
let (m0, h0) = raw(&net);
|
|
// beta = 1: the current ladder sample net - luck.
|
|
let corrected: Vec<f64> = net.iter().zip(&luck).map(|(y, c)| y - c).collect();
|
|
let (m1, h1) = raw(&corrected);
|
|
// beta*: cross-fitted optimal coefficient (AIVAT). mu_c = 0 (luck is mean-zero by construction).
|
|
let (ms, hs) = control_variate(&net, &luck, 0.0, FOLDS).unwrap();
|
|
|
|
// Empirical beta* on the whole sample, for the record.
|
|
let mc = luck.iter().sum::<f64>() / n as f64;
|
|
let my = net.iter().sum::<f64>() / n as f64;
|
|
let cov = net.iter().zip(&luck).map(|(y, c)| (y - my) * (c - mc)).sum::<f64>() / n as f64;
|
|
let varc = luck.iter().map(|c| (c - mc).powi(2)).sum::<f64>() / n as f64;
|
|
let beta_star = if varc > 1e-12 { cov / varc } else { 0.0 };
|
|
|
|
println!("\n{name} ({n} deals)");
|
|
println!(" mean bb/100 raw(b=0) {:+7.2} bench(b=1) {:+7.2} aivat(b*) {:+7.2}", 100.0 * m0, 100.0 * m1, 100.0 * ms);
|
|
println!(" ci95 bb/100 raw(b=0) {:7.2} bench(b=1) {:7.2} aivat(b*) {:7.2}", 100.0 * h0, 100.0 * h1, 100.0 * hs);
|
|
println!(" beta* = {beta_star:.3} (bench assumes 1.000)");
|
|
println!(
|
|
" variance factor aivat/raw {:.2}x aivat/bench {:.2}x bench/raw {:.2}x",
|
|
(h0 / hs).powi(2),
|
|
(h1 / hs).powi(2),
|
|
(h0 / h1).powi(2)
|
|
);
|
|
let drop = 100.0 * (1.0 - hs / h1);
|
|
println!(" AIVAT over current bench: CI {drop:+.1} % (positive = narrower)");
|
|
}
|
|
|
|
fn main() {
|
|
println!("=== Benchmark estimator audit: fixed beta=1 vs cross-fitted beta* (AIVAT) ===");
|
|
println!("Unbiased iff the three means agree within a CI. Narrower aivat CI = world-class upgrade.");
|
|
report("heads-up gto", &setup(2, Opponent::Reader(Style::Gto), 3000, ReadMode::Oracle));
|
|
report("heads-up gto-small", &setup(2, Opponent::Reader(Style::GtoSmall), 3000, ReadMode::Oracle));
|
|
report("heads-up fish", &setup(2, Opponent::Reader(Style::Fish), 1000, ReadMode::Oracle));
|
|
report("heads-up calling station", &setup(2, Opponent::CallingStation, 1000, ReadMode::Oracle));
|
|
report("heads-up reg", &setup(2, Opponent::Reader(Style::Reg), 1000, ReadMode::Oracle));
|
|
}
|