ADVERTISING / NOTEBOOK LESSON

58 · A14 · Budget pacing and feedback control

Compare hard gating and feedback pacing, including drift, underspend, and oscillation.

Constructed mechanism / simulationRead-only · saved experiment

Saved outputs come from recorded teaching runs; opening this page does not rerun an experiment. The code and original outputs are preserved; original-language data and annotations may remain.

A14 · Budget pacing and feedback control

Prerequisites: foundations 31–34; A13.

Evidence: explicitly constructed mechanism experiments, not real ad logs. This chapter does not claim industrial-system reproduction or online gains.

Learning order: predict → change one variable → run → explain.

English companion. All instructional Markdown is translated. Experiment code, Chinese language examples, execution counts, and saved outputs remain as in the source edition; historical output text may therefore be Chinese. The initial setup cell anchors the working directory and Python import path for this companion's deeper folder; it does not change the experiment. Saved outputs are historical evidence, not a new run. Run from the top after preparing the required data and models.

PYTHON · 01
# English companions live one directory deeper; keep the original experiment code unchanged.
from pathlib import Path as _TranslationPath
import os as _translation_os
import sys as _translation_sys
_translation_root = next((p for p in [_TranslationPath.cwd(), *_TranslationPath.cwd().parents]
                          if (p / "reclab").is_dir()), None)
if _translation_root is None:
    raise RuntimeError("Open this notebook from inside the Search Recommendation Ads Lab checkout.")
_translation_os.chdir(_translation_root)
if str(_translation_root) not in _translation_sys.path:
    _translation_sys.path.insert(0, str(_translation_root))

Problem and input/output contract

Chapter 24’s cumulative proportional gate is a hard threshold. Here m_t=clip(m_{t-1}+η(target_t-spend_{t-1})/B), with bid=.7m_t. This integrates proportional error as a teaching feedback variant, not full PID or optimal control. Compare no pacing, hard gating, and feedback on identical prices, checking payment≤remaining budget per request. Smooth spending is not value maximization, and the controller need not exhaust the budget.

Before running, predict which result the changed variable will affect and which invariants must hold.

PYTHON · 02
from pathlib import Path
import sys
root=Path.cwd()
if not (root/'reclab').exists(): root=root.parent
if str(root) not in sys.path: sys.path.insert(0,str(root))
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from reclab import ads_curriculum as ac

Run the one-variable comparison

Inputs are small constructed examples visible in source. Output units and constraints are defined above. Run assertions to verify mathematics and accounting.

PYTHON · 03
summaries=[]
for pattern in ('burst','sparse','drift'):
 for policy in ('none','gate','feedback'):
  r=ac.pacing(pattern,policy);summaries.append({k:v for k,v in r.items() if k!='trace'})
  if pattern=='drift': plt.plot([x['spend'] for x in r['trace']],label=policy)
display(pd.DataFrame(summaries));plt.plot([x['target'] for x in r['trace']],label='target',linestyle='--');plt.legend();plt.show()
assert all(r['spend']<=8+1e-12 for r in summaries)
Saved notebook output · not executed on this page
pattern policy spend value
0 burst none 4.0 20.0
1 burst gate 3.8 19.0
2 burst feedback 7.2 24.0
3 sparse none 3.0 10.0
4 sparse gate 3.0 10.0
5 sparse feedback 7.5 9.0
6 drift none 6.0 20.0
7 drift gate 3.9 13.0
8 drift feedback 7.2 16.0
<Figure size 640x480 with 1 Axes>
Saved notebook figure

Interpretation and limits

Sparse traffic can leave money unspent. After drift, feedback may increase bids but remains constrained by remaining budget. Keep scenarios where the controller loses. Every win has equal value here; if value changes over time, smoothing spend may sacrifice valuable opportunities.

Inspect source, then try an exercise

Change only gain from .8 to 2 and compare accumulated error and oscillation. Explain why exhausting a budget does not justify buying value below cost.

PYTHON · 04
import inspect
print(inspect.getsource(ac.pacing))
Saved notebook output · not executed on this page
def pacing(pattern='burst', policy='feedback', budget=8., gain=.8):
    if pattern not in ('burst','sparse','drift') or policy not in ('none','gate','feedback'): raise ValueError('Invalid scenario')
    prices={'burst':[.2]*20+[.8]*20,'sparse':[1.5]*30+[.3]*10,'drift':[.3]*20+[1.1]*20}[pattern]
    spend=0.; multiplier=1.; trace=[]; value=0.
    for t,price in enumerate(prices):
        target=budget*(t+1)/len(prices)
        if policy=='feedback' and budget>0: multiplier=float(np.clip(multiplier+gain*(target-spend)/budget,.05,3.))
        bid=(.7*multiplier if policy=='feedback' else .7)
        allowed=policy!='gate' or spend+price<=target
        win=allowed and bid>=price and spend+price<=budget+1e-12
        if win: spend+=price;value+=1.
        trace.append(dict(t=t+1,target=target,spend=spend,multiplier=multiplier,won=bool(win)))
        assert -1e-12<=spend<=budget+1e-12
    return dict(pattern=pattern,policy=policy,spend=spend,value=value,trace=trace)

Sources and next step

A-RTB pp. 118–131. This is an original Lab exercise, not a copy of the complete lecture text.

Chinese GitHub chapter · Authors’ RTB slides. The Chinese deck is not a complete modern advertising-engineering course. Historical descriptions of platforms are not presented as current market facts.

After the exercise, return to the ads learning path and continue to the next semantic unit.

GO TO THE SOURCE

Sources for this lesson

Author tutorialEnglish

Weinan Zhang / Jian Xu · CIKM 2016 RTB Tutorial

PDF pages 118–131: budget pacing

164 author slides covering response prediction, bidding, attribution, pacing, targeting and reserve prices. Lab mechanisms are independently authored, not full paper replications.

Author tutorialEnglish

Weinan Zhang / Jian Xu · CIKM 2016 RTB Tutorial

164-page PDF: unit links open the relevant page

164 author slides covering response prediction, bidding, attribution, pacing, targeting and reserve prices. Lab mechanisms are independently authored, not full paper replications.

Completion marks are optional and stored only in this browser. Reading a page does not mark it complete.