Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions DEBATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1221,3 +1221,25 @@ authorized by test success alone.
changes without traceable review; existing detailed historical prose is
silently overwritten; accepted status is inferred from completed code; or
the only drift detector is falsely represented as an atomic safety gate.


## Continuum marketing hydrodynamics and Scientific Machine Learning vs. discrete ABM vs. macroscopic Bayesian MMM (2026-11-06; PROPOSED)

**Research anchors:** DEC-011, OOTB-032, Boral et al. (ICML 2024, DySLIM), Zepeda-Núñez et al. (Nature Machine Intelligence 2026, GenFocal), Wan et al. (ICLR 2023), Li et al. (ICLR 2021, FNO), Bezgin et al. (JCP 2022, WENO3-NN), Cuturi (NeurIPS 2013, Sinkhorn), Chen et al. (NeurIPS 2018, Neural ODE), Rackauckas et al. (2020, SciML/UDE), Zeigler et al. (2000, Discrete Event Systems Specification), and Jin et al. (Google Research 2021, Bayesian MMM). Companion research monograph: [paper/sciml_marketing_hydrodynamics.md](paper/sciml_marketing_hydrodynamics.md).

**Dialectical tension:**
Simulating complex market responses to strategic marketing interventions $\mathbf{u}(t)$ currently suffers from a tri-scale dichotomy:
1. **Macroscopic Bayesian Media Mix Modeling (Option A):** Aggregate weekly channel adstock and saturation curves (`pymc-marketing`, `meridian`). Strengths: low dimensional parameter space, robust inference from coarse spend/revenue time series. Critical failure: blind to micro-funnel conversion latencies, session drop-offs, inventory stockout shocks, and liquidity constraints.
2. **Microscopic Discrete-Event Agent-Based Modeling (Option B):** Discrete agent vectors $(\alpha, \beta, \gamma, w)$ traversing finite state machines on an explicit event calendar (`FunnelScript World`). Strengths: granular modeling of cognitive traits and non-linear touchpoints. Critical failure: the 3% Conversion Paradox (infinite micro-parameter combinations produce identical aggregate conversion rates, making parameters unidentifiable without randomized lift tests), $O(N \log N)$ computational bottlenecks scaling past $N = 10^7$ agents, and autoregressive trajectory blowout over $\ge 90$-day horizons due to positive Lyapunov exponents.
3. **Meso-Scale Marketing Hydrodynamics & Scientific Machine Learning (Option C, Proposed Synthesis):** Represent audience populations as continuous density fields $\rho(x, t)$ over bounded cognitive coordinates $x \in \Omega \subset \mathbb{R}^4$ governed by an Advection-Diffusion-Reaction PDE with spend-driven velocity fields $\mathbf{v}(x, t; \mathbf{u})$, solved differentiably via JAX (`ScanOdeSolver`), stabilized over long horizons by DySLIM entropic Optimal Transport ergodic measure preservation, and bridged to macroscopic Bayesian MMM via a two-stage GenFocal downscaling pipeline (Rectified Flow debiasing + conditional diffusion).

**Trade-offs and architectural boundaries:**
- *Continuum assumption vs. discrete indivisibility:* Hydrodynamic PDEs model high-density mass audiences ($N \ge 10^5$) with sub-millisecond GPU rollouts and analytical adjoint sensitivity $\nabla_{\mathbf{u}} \text{ROAS}$, but do not represent individual B2B account journeys or small-cohort discrete transactions where Poisson shot noise dominates.
- *Calibration cost vs. runtime execution:* DySLIM Sinkhorn regularization and GenFocal diffusion bridges require offline neural pre-training on historical campaigns, trading upfront training compute for instant 60 FPS interactive simulation surrogates during strategic planning.
- *Falsification boundaries:*
- $H_{\text{ergodic}}$ is falsified if DySLIM Sinkhorn regularized 90-day simulation rollouts drift beyond Wasserstein distance $W_2 > 0.08$ from empirical customer lifetime value distributions, or fail to bound percentiles ($P_{10}, P_{50}, P_{90}$) within $\pm 10\%$.
- $H_{\text{genfocal}}$ is falsified if synthesized daily/hourly conversion cascades violate macro-revenue conservation laws ($\sum \hat{y}_{\text{daily}} \ne Y_{\text{macro}}$) outside the 95% Bayesian credible interval.
- $H_{\text{fluid}}$ is falsified if the continuum JAX adjoint gradient $\frac{\partial \text{ROAS}}{\partial \mathbf{u}}$ contradicts finite-difference numerical verification or if forward simulation exceeds 200ms on GPU for $N = 10^8$ equivalent consumers.
- $H_{\text{weno}}$ is falsified if discontinuous market shocks (e.g. abrupt stockout or ad account ban) produce negative audience densities ($\rho < 0$) or non-TVD oscillatory artifacts.

**Stop conditions:** Continuum PDEs must never be used to simulate small discrete cohorts ($N < 1,000$); discrete event engines must retain authority for transaction ledger accounting; no claim of production replacement is accepted prior to empirical validation across verified benchmarks.
85 changes: 84 additions & 1 deletion OUT_OF_THE_BOX.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ Potential future research would specify operator-controlled immutable anchors, s

Potential future work could compare semantic traces for deliberately paired legacy and World models or test explicit module package manifests. Neither a package resolver nor a single merged simulation runtime is implemented or approved by Phase 007G.


## Recovery frontier: trace bridges and bounded scale (2026-11-02; unapproved)

A future versioned World/browser trace bridge and an independent heap/stream/aggregate resource benchmark could falsify semantic equivalence and memory scalability claims under adversarial event fan-out, changed agent ordering and withheld calibration data. Neither implementation nor a claim of 100k-agent readiness follows from the present local R1/R2 remediation. The owner must first choose authority, admission and migration contracts.
Expand All @@ -563,3 +562,87 @@ A future versioned World/browser trace bridge and an independent heap/stream/agg
## R3 frontier: bounded calendar and aggregate retention (2026-11-02; not accepted)

Count-based queue admission can reject event explosions but cannot cap arbitrary Python payload bytes or a blocking user reducer. Future research could compare typed aggregate-only checkpoints and child-process RSS limits, then falsify claims of replay, restoration and memory control under real multi-agent input. No implementation, implicit event dropping or public API promise follows from the current baseline.

---

## 32. Hydrodynamic Market Fields & Invariant-Preserving Attractors: Scientific Machine Learning for FunnelScript (OOTB-032)

### The Vision: Cross-Pollinating Google Research `swirl-dynamics` into Marketing Systems Engineering

Current market simulations in FunnelScript exist at two extreme poles:
1. **Discrete Agent-Based Modeling (ABM):** Microscopic simulation of individual agent vectors ($\alpha, \beta, \gamma, w$), which faces the *Curse of Dimensionality* and computational bottlenecks when scaling to $10^7 - 10^8$ mass-market consumers, alongside severe long-horizon trajectory drift.
2. **Macroscopic Bayesian MMM:** Aggregate weekly channel adstock and saturation models (`pymc-marketing`), which lack structural insight into micro-funnel bottlenecks, session latencies, and cash flow settlement traps.

Google Research's **`swirl-dynamics`** library demonstrates that complex, multiscale, chaotic physical systems (fluid flows, atmospheric turbulence, climate extremes) can be rigorously modeled, debiased, and downscaled by synthesizing numerical differential equation solvers, neural operators, and probabilistic diffusion models.

By framing customer populations as a **continuous cognitive fluid** and campaign dynamics as **non-equilibrium thermodynamics**, FunnelScript can import six foundational paradigms from `swirl-dynamics`:

```
┌─────────────────────────────────────────────────────────────────────────────────────────┐
│ Swirl-Dynamics ────> FunnelScript Theoretical Mapping │
├───────────────────────────────────────────┬─────────────────────────────────────────────┤
│ Google Swirl-Dynamics Core Mechanism │ FunnelScript Marketing Engineering Anchor │
├───────────────────────────────────────────┼─────────────────────────────────────────────┤
│ 1. DySLIM (Ergodic Measure Preservation) │ Long-Horizon Attractor Stabilization │
│ Sinkhorn Divergence / MMD in OTT-JAX │ Prevents 90-day simulation drift & blowout │
├───────────────────────────────────────────┼─────────────────────────────────────────────┤
│ 2. GenFocal & R2-D2 (2-Stage Downscaling) │ Macro-MMM to Micro-ABM Calibration Bridge │
│ Rectified Flow Debiasing + Diffusion │ Debias macro MMM, sample micro-journeys │
├───────────────────────────────────────────┼─────────────────────────────────────────────┤
│ 3. Differentiable Solvers (ScanOdeSolver) │ End-to-End Differentiable Campaign Compiler │
│ JAX lax.scan + Adjoint Sensitivity │ Analytical gradients: d(ROAS)/d(AdSpend) │
├───────────────────────────────────────────┼─────────────────────────────────────────────┤
│ 4. Neural Operators (FNO & HyperUNet) │ Mesh-Free Infinite-Scale Funnel Surrogates │
│ Operator mapping on function spaces │ Instant 60 FPS Web Studio simulation engine │
├───────────────────────────────────────────┼─────────────────────────────────────────────┤
│ 5. WENO-NN Shock Capturing (Rational NN) │ Discontinuous Market Shock Dynamics │
│ Non-oscillatory conservation schemes │ Stockouts, price wars, ad account bans │
├───────────────────────────────────────────┼─────────────────────────────────────────────┤
│ 6. Test-Time Diffusion Guidance │ Invariant Enforcement & Catastrophe Search │
│ Score-based constraint gradients │ Enforce cash non-negativity; find ruin modes│
└───────────────────────────────────────────┴─────────────────────────────────────────────┘
```

---

### Mathematical Formulations

#### 1. The Marketing Hydrodynamic Equation (The Advection-Diffusion-Reaction Continuity Equation)
Instead of simulating $10^8$ individual agents, the audience distribution is represented as a continuous density field $\rho(x, t)$ over cognitive coordinate space $x = (\alpha, \beta, \gamma, w) \in \Omega \subset \mathbb{R}^4$:

$$\frac{\partial \rho}{\partial t} + \nabla \cdot (\rho \, \mathbf{v}(x, t; \mathbf{u})) = \nabla \cdot (\mathbf{D} \nabla \rho) + \mathcal{S}_{\text{acq}}(x, t) - \mathcal{D}_{\text{churn}}(x, t)$$

Where:
* $\mathbf{v}(x, t; \mathbf{u})$ is the **advective velocity field** generated by active marketing tactics $\mathbf{u}(t)$ (ad spend, discounts, retargeting frequency), propelling consumers towards higher purchase readiness.
* $\mathbf{D}$ is the **diffusion tensor** representing stochastic cognitive variance, word-of-mouth drift, and brand memory decay.
* $\mathcal{S}_{\text{acq}}$ is the top-of-funnel acquisition flux from paid and organic search.
* $\mathcal{D}_{\text{churn}}$ is the customer exhaustion and churn sink.

#### 2. DySLIM Ergodic Invariant Measure Regularization
To prevent long-horizon autoregressive rollouts from diverging away from reality, the calibration objective enforces that the time-average measure of the simulation matches the empirical business attractor $\mu_{\text{historical}}^*$:

$$\mathcal{L}_{\text{Ergodic}} = \mathcal{L}_{\text{step}} + \lambda_{\text{ergodic}} \cdot \mathbb{D}_{\text{Sinkhorn}}\left(\frac{1}{T}\sum_{t=1}^T \delta_{s(t)}, \mu_{\text{historical}}^*\right)$$

Where $\mathbb{D}_{\text{Sinkhorn}}$ is the entropy-regularized optimal transport divergence computed via OTT-JAX, guaranteeing that long-term simulations neither collapse to zero nor explode to infinite conversions.

#### 3. GenFocal Macro-to-Micro Downscaling Pipeline
* **Stage 1 (Debiasing Macro MMM):** Train an Optimal Transport / Rectified Flow velocity model to map coarse, weekly Bayesian MMM posteriors from `pymc-marketing` onto observed historical revenue trajectories, removing structural channel aggregation bias.
* **Stage 2 (Conditional Diffusion Downscaling):** Train a score-based diffusion model conditioned on the debiased macro trajectory to synthesize high-frequency daily transaction cascades, abandoned checkout latencies, and cash flow drawdown curves.

#### 4. WENO-NN Discontinuous Shock Capturing
When sudden exogenous market shocks occur (e.g. Black Friday inventory exhaustion, viral PR boycott, or payment gateway processor outage), conversion rates experience discontinuous jumps. Standard finite-difference methods produce Gibbs phenomenon oscillations (e.g. negative audience densities or negative cash).
Using data-driven Weighted Essentially Non-Oscillatory schemes with rational networks ensures:
$$\rho(x, t) \ge 0, \quad \int_{\Omega} \rho(x, t) \, dx = N(t), \quad \text{Total Variation Bounded (TVD)}$$

---

### Falsifiable Research Hypotheses

* **$H_{\text{ergodic}}$ (Simulation Stability):** *Under a 90-day autoregressive forward simulation with stochastic customer churn and competitor bidding, a model calibrated with DySLIM Sinkhorn invariant-measure regularization maintains bounded Wasserstein distance ($W_2 \le 0.08$) to the true empirical distribution, whereas unregularized MSE-calibrated simulations exhibit catastrophic divergence ($W_2 > 0.45$) in $> 70\%$ of trials.*
* *Falsification Boundary:* Any run where DySLIM regularized simulation diverges or fails to preserve empirical customer lifetime value (LTV) percentiles ($P_{10}, P_{50}, P_{90}$) within $\pm 10\%$.

* **$H_{\text{genfocal}}$ (Macro-to-Micro Bridging):** *A two-stage downscaling architecture (Rectified Flow macro debiasing + conditional diffusion) reproduces micro-funnel hourly conversion variance with $< 12\%$ relative error while guaranteeing exact conservation of macro weekly revenue totals ($\sum \hat{y}_{\text{daily}} = Y_{\text{macro}}$).*
* *Falsification Boundary:* Discrepancy between aggregated micro-simulated revenue and macro Bayesian MMM bounds exceeding the $95\%$ credible interval.

* **$H_{\text{fluid}}$ (Continuum Scaling Parity):** *A continuous JAX-based hydrodynamic PDE solver (`ScanOdeSolver`) evaluates campaign ROAS and cash flow dynamics for an effective population of $N = 10^8$ consumers in $< 50\text{ms}$ on a single GPU, providing exact adjoint sensitivity gradients $\frac{\partial \text{ROAS}}{\partial \text{Spend}}$ that match discrete-event simulation outcomes within a Kolmogorov-Smirnov distance $D_{\text{KS}} \le 0.03$.*
* *Falsification Boundary:* Analytical gradient direction contradicting finite-difference numerical verification or execution time exceeding $200\text{ms}$.
75 changes: 75 additions & 0 deletions paper/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,78 @@ @article{broadbent1979one
pages={139--166},
year={1979}
}

@inproceedings{boral2024dyslim,
title={DySLIM: Dynamics Stable Learning by Invariant Measure for Chaotic Systems},
author={Boral, Anudhyan and Zepeda-N{\'u}{\~n}ez, Leonardo and Wan, Zhong Yi and Sha, Fei},
booktitle={International Conference on Machine Learning (ICML)},
year={2024}
}

@article{zepedanunez2026genfocal,
title={Regional climate risk assessment from climate models using probabilistic machine learning},
author={Zepeda-N{\'u}{\~n}ez, Leonardo and Boral, Anudhyan and Wan, Zhong Yi and Norgaard, Pamela and Sha, Fei},
journal={Nature Machine Intelligence},
year={2026},
doi={10.1038/s42256-026-01308-7}
}

@inproceedings{wan2023evolve,
title={Evolve Smoothly, Fit Consistently: Learning Smooth Latent Dynamics For Advection-Dominated Systems},
author={Wan, Zhong Yi and Zepeda-N{\'u}{\~n}ez, Leonardo and Boral, Anudhyan and Sha, Fei},
booktitle={International Conference on Learning Representations (ICLR)},
year={2023}
}

@inproceedings{li2021fourier,
title={Fourier Neural Operator for Parametric Partial Differential Equations},
author={Li, Zongyi and Kovachki, Nikola and Azizzadenesheli, Kamyar and Liu, Burigede and Bhattacharya, Kaushik and Stuart, Andrew and Anandkumar, Anima},
booktitle={International Conference on Learning Representations (ICLR)},
year={2021}
}

@article{bezgin2022weno3nn,
title={WENO3-NN: A maximum-order three-point data-driven weighted essentially non-oscillatory scheme},
author={Bezgin, Dmitrii A and Schmidt, Steffen J and Adams, Nikolaus A},
journal={Journal of Computational Physics},
volume={452},
pages={110920},
year={2022}
}

@inproceedings{cuturi2013sinkhorn,
title={Sinkhorn Distances: Lightspeed Computation of Optimal Transport},
author={Cuturi, Marco},
booktitle={Advances in Neural Information Processing Systems (NeurIPS)},
volume={26},
year={2013}
}

@inproceedings{chen2018neuralode,
title={Neural Ordinary Differential Equations},
author={Chen, Ricky TQ and Rubanova, Yulia and Bettencourt, Jesse and Duvenaud, David K},
booktitle={Advances in Neural Information Processing Systems (NeurIPS)},
volume={31},
year={2018}
}

@article{rackauckas2020universal,
title={Universal Differential Equations for Scientific Machine Learning},
author={Rackauckas, Christopher and Ma, Yingbo and Martensen, Julius and Warner, Collin and Zubov, Kirill and Supekar, Rohit and Skinner, Dominic and Ramadhan, Ali and Edelman, Alan},
journal={arXiv preprint arXiv:2001.04385},
year={2020}
}

@article{zeigler2000theory,
title={Theory of Modeling and Simulation: Integrating Discrete Event and Continuous Complex Dynamic Systems},
author={Zeigler, Bernard P and Praehofer, Herbert and Kim, Tag Gon},
journal={Academic Press},
year={2000}
}

@article{jin2021bayesian,
title={Bayesian Methods for Media Mix Modeling with Carryover and Shape Effects},
author={Jin, Yuxue and Wang, Yueqing and Sun, Yunting and Chan, David and Koehler, Jim},
journal={Google Research},
year={2021}
}
Loading
Loading