{
 "credit": "Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved: the solved policy, replica, Gaussian filter, fee rule, qm tables and exact-arithmetic arb/retail tell that this head was trained on are his. Replica tool: fastlean (artifact a88ff982eba7e078bc6ccb1555b90a211c00c9fd76ec90a62ab13a4074f2c3d0), a port of his replica2.run with our LEANBASE policy.",
 "item": "lin-wide (batch e05-head-train): linear fee-correction head, all 20 features but pi_last",
 "shape": "linear, fastlean 42-weight layout: z_own = w[0] + sum_i w[1+i]*x_i, z_other = w[21] + sum_i w[22+i]*x_i, x_i = clip((feat_i-MU_i)/SD_i,-3,3); own side fee += 8e-4*tanh(z_own), other side fee += 8e-4*tanh(z_other). 40 free weights (2 biases + 19 features x 2 sides); w[3] and w[24] (pi_last, feature 2) held at exactly 0 throughout.",
 "features_used": [
  {
   "index": 0,
   "name": "g_m_minus_lnsprev_bps"
  },
  {
   "index": 1,
   "name": "sd_bps"
  },
  {
   "index": 3,
   "name": "g_lns_minus_m_bps"
  },
  {
   "index": 4,
   "name": "g_lns2h_minus_m_bps"
  },
  {
   "index": 5,
   "name": "phase"
  },
  {
   "index": 6,
   "name": "log1p_abs_move_bps"
  },
  {
   "index": 7,
   "name": "log1p_silent_steps"
  },
  {
   "index": 8,
   "name": "log1p_router_age"
  },
  {
   "index": 9,
   "name": "log1p_dt"
  },
  {
   "index": 10,
   "name": "log1p_size_bps"
  },
  {
   "index": 11,
   "name": "side"
  },
  {
   "index": 12,
   "name": "lean_bid_bps"
  },
  {
   "index": 13,
   "name": "lean_ask_bps"
  },
  {
   "index": 14,
   "name": "is_arb"
  },
  {
   "index": 15,
   "name": "tell_hit"
  },
  {
   "index": 16,
   "name": "lean_own_bps"
  },
  {
   "index": 17,
   "name": "lean_other_bps"
  },
  {
   "index": 18,
   "name": "synced"
  },
  {
   "index": 19,
   "name": "log1p_cnt"
  }
 ],
 "features_held_at_zero": [
  {
   "index": 2,
   "name": "pi_last",
   "weights": [
    3,
    24
   ]
  }
 ],
 "generations": 141,
 "curve": [
  {
   "gen": 5,
   "block": "64000..64511",
   "best": -0.431349,
   "mean": -0.691433
  },
  {
   "gen": 10,
   "block": "64512..65023",
   "best": -0.294995,
   "mean": -0.419842
  },
  {
   "gen": 15,
   "block": "64000..64511",
   "best": -0.272315,
   "mean": -0.416869
  },
  {
   "gen": 20,
   "block": "64512..65023",
   "best": -0.224663,
   "mean": -0.267968
  },
  {
   "gen": 25,
   "block": "64000..64511",
   "best": -0.201732,
   "mean": -0.294651
  },
  {
   "gen": 30,
   "block": "64512..65023",
   "best": -0.201988,
   "mean": -0.224089
  },
  {
   "gen": 35,
   "block": "64000..64511",
   "best": -0.134848,
   "mean": -0.24939
  },
  {
   "gen": 40,
   "block": "64512..65023",
   "best": -0.125859,
   "mean": -0.222031
  },
  {
   "gen": 45,
   "block": "64000..64511",
   "best": -0.098151,
   "mean": -0.160018
  },
  {
   "gen": 50,
   "block": "64512..65023",
   "best": -0.120528,
   "mean": -0.224137
  },
  {
   "gen": 55,
   "block": "64000..64511",
   "best": -0.070334,
   "mean": -0.114951
  },
  {
   "gen": 60,
   "block": "64512..65023",
   "best": -0.078675,
   "mean": -0.118007
  },
  {
   "gen": 65,
   "block": "64000..64511",
   "best": -0.131891,
   "mean": -0.173484
  },
  {
   "gen": 70,
   "block": "64512..65023",
   "best": -0.064987,
   "mean": -0.078473
  },
  {
   "gen": 75,
   "block": "64000..64511",
   "best": -0.065732,
   "mean": -0.082155
  },
  {
   "gen": 80,
   "block": "64512..65023",
   "best": -0.040045,
   "mean": -0.06128
  },
  {
   "gen": 85,
   "block": "64000..64511",
   "best": -0.038618,
   "mean": -0.059765
  },
  {
   "gen": 90,
   "block": "64512..65023",
   "best": -0.030135,
   "mean": -0.066852
  },
  {
   "gen": 95,
   "block": "64000..64511",
   "best": -0.053036,
   "mean": -0.067713
  },
  {
   "gen": 100,
   "block": "64512..65023",
   "best": -0.029804,
   "mean": -0.072786
  },
  {
   "gen": 105,
   "block": "64000..64511",
   "best": -0.03232,
   "mean": -0.048037
  },
  {
   "gen": 110,
   "block": "64512..65023",
   "best": -0.018328,
   "mean": -0.035863
  },
  {
   "gen": 115,
   "block": "64000..64511",
   "best": -0.039533,
   "mean": -0.044152
  },
  {
   "gen": 120,
   "block": "64512..65023",
   "best": -0.039767,
   "mean": -0.053573
  },
  {
   "gen": 125,
   "block": "64000..64511",
   "best": -0.036595,
   "mean": -0.040672
  },
  {
   "gen": 130,
   "block": "64512..65023",
   "best": -0.041282,
   "mean": -0.054148
  },
  {
   "gen": 135,
   "block": "64000..64511",
   "best": -0.035263,
   "mean": -0.038272
  },
  {
   "gen": 140,
   "block": "64512..65023",
   "best": -0.031469,
   "mean": -0.038749
  }
 ],
 "choose": {
  "mean_diff": -0.025757558460796193,
  "se": 0.007657102625724052,
  "n": 1024
 },
 "holdout": {
  "mean_diff": -0.020431947446298587,
  "se": 0.005510097174671282,
  "n": 2048
 },
 "advance": false,
 "weights": [
  -0.014721030634841394,
  0.11232183980683125,
  0.05567698855973509,
  0.0,
  0.044085500557506443,
  0.038258548556331415,
  -0.006474923266397412,
  0.07414785738895,
  0.02283077510961095,
  -0.037684773746131876,
  -0.053161032756419424,
  -0.057503289686420295,
  0.015010267833840112,
  -0.007903203986387785,
  -0.005666869940778008,
  -0.02582660470218012,
  -0.03747616917693982,
  0.08581901545616168,
  -0.03956060882523904,
  -0.06581816967482002,
  -0.03551495424298472,
  -0.07617763902606296,
  0.05601781962927843,
  0.01965346464775287,
  0.0,
  -0.16401019280024495,
  0.02986781468894797,
  -0.01678115728185348,
  -0.04318434922561058,
  -0.028856466526503203,
  -0.012898439410497111,
  0.018389820061152747,
  0.055452239963109724,
  0.00560945858087098,
  0.028801542695033846,
  0.02631949664850739,
  0.0824320298812785,
  -0.17417064113631678,
  -0.11870910307757132,
  -0.16026705185629023,
  -0.037023951286504,
  -0.0672006269879317
 ],
 "solidity_notes": {
  "needs_ln": {
   "0 g_m_minus_lnsprev_bps": "ln(s_prev); it is the previous callback's ln(s), so one stored word rather than a second ln",
   "3 g_lns_minus_m_bps": "ln(s) of the post-trade spot reserveY/reserveX",
   "4 g_lns2h_minus_m_bps": "ln(s2h) of the rival spot estimate",
   "6 log1p_abs_move_bps": "ln(1+u) with u = |ln s - ln s_prev|*1e4 (reuses the two logs above, one more ln)",
   "10 log1p_size_bps": "ln(1+u) with u = 1e4*paid/reserve (continuous argument, one ln)"
  },
  "ln_of_small_integers_table_is_enough": {
   "7 log1p_silent_steps": "argument min(dt-1,12): 13 values; after the +3 SD clip (MU 0.150, SD 0.372 -> log1p <= 1.266) only 0,1,2 differ, >=3 saturates",
   "8 log1p_router_age": "integer age; clip (MU 0.445, SD 0.609 -> log1p <= 2.272) saturates from age 9",
   "9 log1p_dt": "integer dt; clip (MU 0.543, SD 0.462 -> log1p <= 1.929) saturates from dt 6",
   "19 log1p_cnt": "argument min(cnt,12); clip (MU 0.540, SD 0.437 -> log1p <= 1.851) saturates from cnt 6"
  },
  "needs_sqrt_not_ln": {
   "1 sd_bps": "sqrt(v)*1e4 of the filter variance"
  },
  "no_new_ln_or_exp": {
   "5 phase, 11 side, 14 is_arb, 15 tell_hit, 18 synced": "integers/flags the policy already has",
   "12 lean_bid_bps, 13 lean_ask_bps, 16 lean_own_bps, 17 lean_other_bps": "the policy's own two fees before rounding, times 1e4; whatever exp the base fee rule (1-exp(-(a-w)*1e-4) in the Python reference) already costs, nothing added. 16/17 are 12/13 swapped by side."
  },
  "output": "8e-4*tanh(z) needs exp (or a rational/polynomial tanh) twice per callback. For these weights |z_own| <= |w0| + 3*sum|w_i| = 2.48 and |z_other| <= 3.51 at the clip bounds, so tanh is not in its linear range everywhere.",
  "moot": "advance is false: these weights lower the edge on both sets, so nothing here should be ported."
 },
 "reference_zb64": "eNq1WQtv20YS/it7DoIjG4nh+6Gci3Nctwka20Gc4gJIAkuRK4kRRaokZdkN3N9+3+ySFKXYaYvDKYgszs7Mzntml19O6jJKc21zfzJiJ8/YecmTt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wpHi+BTDUdcHehAmbeLMdE6YJXAv+90wRmuQOPbARWL7ue3rgS3l9n+xrugE2g1OlKUwQBnbguohB3bNkwPqmbVEo+Ej/1scGos9DXBqGBRJoKaEGbUDJAaN5hmU2BqPQ0R2YACZG52wdj58BOpkPfVtfeqQShPK9wDK86cPJw38BZrFrGw==",
 "reference_encoding": "base64(zlib(json {name: text})), names train.py and weights.json",
 "seeds_used": {
  "train_and_choose": "64000..65023 only: generation g (1-based) used 64000..64511 when g is odd and 64512..65023 when g is even; edge(0) on both blocks computed once and reused",
  "holdout": "10000..12047, run once after training stopped, with the final distribution mean and with the bare policy (weights=None)",
  "holdout_touched_before_report": false,
  "other": "a discarded smoke run (population 16, one generation on 64000..64511, plus edge(0) on 64000..65023) and a speed check on 64000..64063; neither fed the reported run",
  "cma_rng_seed": 20261110
 },
 "notes": {
  "result": "The head does not help. Final mean weights: holdout -0.0204 (se 0.0055, n 2048, 46.2% of seeds up), choose -0.0258 (se 0.0077, n 1024); by block 64000..64511 -0.0170 (se 0.0110), 64512..65023 -0.0346 (se 0.0107).",
  "mean_edge": {
   "holdout_w": 536.5829590087317,
   "holdout_0": 536.603390956178,
   "choose_w": 538.9925701100265,
   "choose_0": 539.0183276684872
  },
  "curve_definition": "best = highest, mean = average over the generation's 6 candidates of [mean over the block of edge(w) - edge(0)]; the distribution mean itself was not evaluated during training",
  "training": "pycma 4.5.0 CMAEvolutionStrategy, x0 = 0 (40 dims), sigma0 0.04, population 6 (not pycma's default 15 for 40 dims), all stopping tolerances off, no restarts; sigma went 0.04 -> 0.0037. Every one of the 846 candidates scored below 0 (highest -0.0161, generation 137).",
  "training_seconds": 2404.7,
  "why_population_6": "this shared machine gave 41 (hook on) to 55 (hook off) runs per core-second on one process against the tool's stated 128.2, and about 150 runs a second over 8 processes, so a 512-seed block cost ~3.4 s for most of the run (about half that in the last 35 generations); 6 candidates a generation was chosen before the run started so that 100 generations fit in the 40 minutes",
  "tool_parity_check": "edge(0) mean over 64000..64063 and 10000..10063 measured here = 527.8724874784; the tool artifact's parity.mean_edge_fast = 527.8724874783702",
  "environment": "CPython 3.12.3, numpy 2.2.6, llvmlite 0.44.0, numba 0.61.2 (cp312 manylinux x86_64 wheels from PyPI, sha256 checked, unpacked: no pip on this machine), cma 4.5.0; tables pol_mid.json and qm_k1e-5.json from gtmcknight/amm-sim@66604b34 research/solved, sha256 equal to its SHA256SUMS"
 },
 "not_done": [
  "No improvement found: advance is false. Whether a smaller sigma0, a larger population, more generations or a non-zero start would find a positive linear head is not tested; the search was still contracting (sigma 0.0037 and falling) when the 40 minutes ended, so this is a stopped run, not a converged one.",
  "Training ran 2,404.7 s, 4.7 s past the 40-minute cap: the last (141st) generation started at 2,394 s.",
  "Population 6 instead of pycma's default; the brief names no population size. 141 generations = 846 block evaluations.",
  "Final weights were run on fastlean only; not re-run on the CPython oracle. The tool's own non-zero-weight parity (4 seeds) was not repeated here.",
  "The tool's setup lines were not run as written: fetch.sh was read but not executed (only the two table files load() opens were fetched, hash-checked), and pip is absent so wheels were unpacked by hand.",
  "No per-feature ablation, no hidden-unit head, no pi_last weights (out of this item's scope).",
  "No Solidity port, no gate P/Q/T/F/G/E, no engine run, no qt1 comparison, no submission."
 ]
}