---
title: Bandits with Knapsacks (BwK)
url: https://www.emergentmind.com/topics/bandits-with-knapsacks-bwk
type: topic
---

# Bandits with Knapsacks (BwK)

Searching arXiv for recent and canonical Bandits with Knapsacks papers to ground the article.
Bandits with Knapsacks (BwK) is a stochastic or adversarial online learning framework in which each action yields both reward and consumption of one or more limited resources, and interaction stops when some budget is exhausted [1305.2545]. Relative to classical multi-armed bandits, BwK replaces the sole time constraint with a collection of knapsack constraints and thereby changes both the benchmark and the difficulty of learning: the optimal policy for a given latent distribution may significantly outperform the policy that plays the optimal fixed arm, so regret analysis must account for budget allocation across time and resources rather than only arm identification [1305.2545]. Subsequent work has developed LP-based, primal-dual, combinatorial, contextual, non-stationary, adversarial, and quantum formulations of BwK, and has clarified when no-regret learning is possible, when only competitive-ratio guarantees are attainable, and how structural properties of the resource-consumption process determine learnability [1811.11881], [2503.14796], [2507.04438].

## 1. Foundational formulation and benchmark structure

The canonical BwK model has a finite set of arms, a finite horizon, and one or more resource budgets. In each round, the learner picks an arm, observes a reward and a vector of consumptions, and the process stops when a budget is violated; total reward is the sum collected before stopping [1305.2545]. In the stochastic formulation introduced by Badanidiyuru, Kleinberg, and Slivkins, each arm has a fixed latent distribution over reward-consumption outcome vectors, outcomes are drawn independently over time conditional on the chosen arm, and time itself can be encoded as an additional resource so that all constraints take a common knapsack form [1305.2545]. A later stochastic formulation by Li, Sun, and Ye writes the model with \(m\) arms, \(d\) resources, horizon \(T\), common budget \(B\), and i.i.d. reward and resource vectors with unknown means \(\boldsymbol{\mu}\) and \(\boldsymbol{C}\), together with a stopping time \(\tau\) defined by budget violation or horizon exhaustion [2102.06385].

A central structural fact is that the relevant benchmark is not the best arm. In standard stochastic MAB, the optimal dynamic policy is always to pull a fixed best arm, whereas in BwK the optimal dynamic policy can exploit mixtures of arms that deplete different resources in balanced proportions; consequently, the policy that plays the optimal fixed arm can be arbitrarily worse than the optimal dynamic policy [1305.2545]. This observation motivates LP relaxations as the dominant benchmarking device. The primal LP allocates fractional pull counts \(\xi_x\) or \(\boldsymbol{x}\) to arms subject to expected resource constraints, while the dual LP assigns shadow prices to resources [1305.2545], [2102.06385]. In the stochastic setting, the LP value upper-bounds the expected reward of the optimal dynamic policy [1305.2545], [2209.12013]. In Li, Sun, and Ye’s formulation, the offline LP is
\[
\max_{\boldsymbol{x}\ge 0}\ \boldsymbol{\mu}^\top \boldsymbol{x}
\quad\text{s.t.}\quad
\boldsymbol{C}\boldsymbol{x}\le \boldsymbol{B},
\]
and its dual interprets \(\boldsymbol{y}\) as resource shadow prices [2102.06385].

This LP perspective leads to a precise decomposition of regret. Li, Sun, and Ye define reduced costs
\[
\Delta_i=\boldsymbol{c}_i^\top \boldsymbol{y}^*-\mu_i,
\]
which vanish on optimal arms and are positive on sub-optimal arms, and prove a generic upper bound
\[
\mathrm{Regret}_T^\pi(\mathcal{P},\boldsymbol{B})
\le
\sum_{i\in\mathcal{I}'} \mathbb{E}[n_i(\tau)]\,\Delta_i
+
\mathbb{E}[\boldsymbol{B}^{(\tau)}]^\top \boldsymbol{y}^*.
\]
The first term is arm-side regret from pulling sub-optimal arms, while the second is knapsack-side regret from leaving valuable resources unused [2102.06385]. This decomposition formalizes a recurring theme across the BwK literature: learning quality depends not only on identifying reward-efficient arms but also on discovering and exhausting the binding constraints.

## 2. Primal-dual methods and stochastic regret guarantees

Primal-dual algorithms are a canonical methodological core of BwK. The original 2013 framework introduced two algorithms—BalancedExploration and a multiplicative-update primal-dual method—and proved regret bounds of order
\[
\tilde{O}\Big(\sqrt{m\,OPT}+OPT\sqrt{m/B}\Big),
\]
optimal up to polylogarithmic factors [1305.2545]. BalancedExploration reasons directly over distributions that are LP-perfect for plausible latent structures and explores mixtures of arms subject to confidence constraints, whereas the primal-dual algorithm maintains shadow prices for resources and selects arms by optimistic bang-per-buck ratios [1305.2545].

The primal-dual viewpoint was sharpened by Li, Sun, and Ye through an explicit symmetry between arms and knapsacks [2102.06385]. They distinguish optimal versus sub-optimal arms and binding versus non-binding constraints via auxiliary LPs \(\mathrm{OPT}_i\) and \(\mathrm{OPT}_j\), and define the joint gap
\[
\delta
=
\frac{1}{T}\left(
\mathrm{OPT}_{\mathrm{LP}}
-
\max\left\{
\max_{i\in\mathcal{I}^*}\mathrm{OPT}_i,\;
\max_{j\in\mathcal{J}'}\mathrm{OPT}_j
\right\}
\right).
\]
They further introduce structural parameters \(\sigma=\sigma_{\min}(\boldsymbol{C}_{\mathcal{J}^*,\mathcal{I}^*})\) and \(\chi=\frac{1}{T}\min\{x_i^*\neq 0\}\), measuring LP geometry and the smallest positive optimal allocation [2102.06385].

Their algorithm is explicitly two-phase. Phase I uses UCB/LCB LPs to identify \(\mathcal{I}^*\) and \(\mathcal{J}'\), with stopping certified by the counting identity \(|\hat{\mathcal{I}}^*|+|\hat{\mathcal{J}}'|=d\) [2102.06385]. Phase II solves an adaptive LP on the remaining budget vector \(\boldsymbol{B}^{(t)}\), restricted to the estimated optimal arms, so that binding resources are exhausted in a balanced manner [2102.06385]. The resulting regret bound is logarithmic in \(T\):
\[
O\left(
\left(2+\frac{1}{b}\right)^2\frac{md\log T}{b\delta^2}
+
\frac{d^4}{b^2\min\{\chi^2,\delta^2\}\min\{1,\sigma^2\}}
\right),
\]
which the authors state is the first problem-dependent logarithmic regret bound for the general BwK problem [2102.06385]. This establishes a gap-dependent analogue of classical stochastic-bandit logarithmic regret, but now controlled by LP basis structure rather than only reward gaps.

Earlier logarithmic BwK results already existed in restricted settings. Flajolet and Jaillet developed “UCB-Simplex,” an LP-basis algorithm with logarithmic distribution-dependent bounds in several cases, including one-resource stochastic consumptions, multiple deterministic resources, and horizon-plus-budget settings [1510.01800]. There, regret scales like \(O(\log B)\) or \(O(\log T)\) divided by generalized basis gaps, again reflecting that the right primitive objects are LP bases rather than arms [1510.01800]. A plausible implication is that the later symmetry-based formulation can be read as a systematic reorganization of this earlier basis-centric viewpoint into arm-side and constraint-side hardness parameters.

A different stochastic generalization allows non-monotonic resource utilization. In that model, budgets evolve via drifts \(d_{t,j}\in[-1,1]\), may increase or decrease, and the process always runs for \(T\) rounds, with a null arm forced whenever some budget falls below 1 [2209.12013]. The LP benchmark becomes
\[
\max_p \sum_x p_x\mu_x^r
\quad\text{s.t.}\quad
\sum_x p_x\mu_x^{d,j}\ge -B/T.
\]
With known distributions, the ControlBudget policy achieves constant regret against this LP relaxation, and with unknown distributions, ExploreThenControlBudget achieves logarithmic regret [2209.12013]. This suggests that the LP-and-dual methodology of stochastic BwK extends beyond pure consumption models to renewable-budget regimes, provided the null-arm and positive-drift assumptions restore sufficient controllability.

## 3. Variants: combinatorial, contextual, and structured action spaces

BwK has been repeatedly generalized by enlarging the action space while preserving an LP backbone. Combinatorial Semi-Bandits with Knapsacks (SemiBwK) unifies stochastic BwK and combinatorial semi-bandits by letting actions be feasible subsets of a ground set of atoms, with additive rewards and consumptions over atoms and semi-bandit feedback on chosen atoms [1705.08110]. The action set is represented through the polytope \(P=\mathrm{conv}(\mathcal{F})\), and for matroid constraints the algorithm solves an optimistic LP over \(P\) using per-atom UCB/LCB estimates, then applies a negatively correlated randomized rounding scheme to obtain a feasible combinatorial action [1705.08110]. The main regret bound is
\[
O(\log(ndT))\,\sqrt{n}\left(\frac{\mathrm{OPT}}{\sqrt{B}}+\sqrt{T+\mathrm{OPT}}\right),
\]
which recovers the BwK lower bounds in the singleton-action special case and the \(\tilde{O}(\sqrt{k n T})\) rate of combinatorial semi-bandits when budgets are large enough not to bind [1705.08110].

A related but distinct combinatorial model is Budgeted Combinatorial MAB reduced to BwK with a single pull [2202.03704]. There, a round may pull a super-arm \(S_t\subseteq\mathcal{N}\), with additive reward \(\sum_{i\in S_t}\mu_i\) and total cost \(\sum_{i\in S_t}c_i\), under a global budget and semi-bandit feedback [2202.03704]. The reduction refines each round into \(n\) primitive BwK plays and introduces \(n\) artificial per-arm resources plus one real budget resource, yielding a standard BwK LP with \(d=n+1\) resources [2202.03704]. This makes PrimalDualBwK applicable and produces the algorithm CBwK-LP-UCB, with regret against the LP optimum controlled by a theorem the paper states explicitly [2202.03704]. The conceptual contribution is the use of artificial resources to encode combinatorial feasibility within BwK.

Linear Contextual Bandits with Knapsacks generalize both classical linear contextual bandits and standard BwK [1507.06738]. In each round, the learner observes arm-specific contexts \(x_t(a)\in[0,1]^m\), while expected reward and consumption are linear in the context:
\[
\mathbb{E}[r_t(a)\mid x_t(a),H_{t-1}] = \mu_*^\top x_t(a),\qquad
\mathbb{E}[v_t(a)\mid x_t(a),H_{t-1}] = W_*^\top x_t(a).
\]
Standard BwK is recovered by setting \(m=K\) and \(X_t=I\) for all \(t\) [1507.06738]. The algorithm combines OFUL-style confidence ellipsoids for \(\mu_*\) and \(W_*\) with an OMD-based dual update over resource prices, choosing the arm that maximizes optimistic adjusted reward \(x_t(a)^\top\tilde{\mu}_t(a)-Z\,x_t(a)^\top \tilde{W}_t(a)\theta_t\) [1507.06738]. The main theorem yields regret
\[
O\left(\left(\frac{OPT}{B}+1\right)m\sqrt{\ln\left(\frac{dT}{\delta}\right)\ln T}\,\sqrt{T}\right)
\]
under the budget condition \(B>mT^{3/4}\) [1507.06738]. Relative to oracle-based unstructured contextual BwK, the linear model replaces dependence on \(K\) or \(|\Pi|\) by dependence on the feature dimension \(m\) [1507.06738].

Across these variants, the common pattern is that BwK serves as a generic resource-constrained online optimization template. Once a structured action model admits an LP or convex relaxation with resource-consumption coordinates, primal-dual selection, UCB-style confidence sets, and resource-price updates typically remain available, albeit with new rounding, exploration, or estimation subroutines.

## 4. Adversarial, non-stationary, and benchmark design

The adversarial version of BwK changes the problem qualitatively. Immorlica, Sankararaman, Schapire, and Slivkins showed that regret minimization is no longer feasible, and instead established an \(O(\log T)\) competitive ratio relative to the best fixed distribution over actions, together with a matching lower bound [1811.11881]. Their analysis is built on a repeated Lagrangian zero-sum game whose minimax value matches the LP value in the stochastic setting and remains useful as a control device in adversarial sequences [1811.11881]. The same paper also provides a simpler stochastic analysis via regret minimization in repeated games, offering a unifying primal-dual game-theoretic perspective [1811.11881].

A different adversarial line studies regret rather than competitive ratio but under a fixed-arm benchmark. “Unifying the stochastic and the adversarial Bandits with Knapsack” formulates adversarial BwK with rewards \(r_t(i)\in[0,1]\), costs \(c_t(i)\in[c_{\min},c_{\max}]\), stopping time determined by budget exhaustion, and efficiency \(e_t(i)=r_t(i)/c_t(i)\) [1811.12253]. It introduces EXP3.BwK and EXP3++.BwK, described as order-optimal in the adversarial BwK setup and near-optimal in the stochastic setup up to an additional \(\log(B)\) factor [1811.12253]. The paper also shows that when costs are large and comparable to the total budget, achievable regret bounds can be significantly worse than in the bounded-cost regime [1811.12253]. This suggests that cost scale relative to budget is itself a structural difficulty parameter in adversarial resource-constrained learning.

Recent work has shown that the benchmark itself is the central issue in adversarial BwK. “A New Benchmark for Online Learning with Budget-Balancing Constraints” studies adversarial BwK with bandit feedback, one resource, and hard stopping, and proves that the classical benchmark—best fixed distribution respecting the budget in expectation—admits no-regret learning because of the “spend-or-save” dilemma [2503.14796]. The paper introduces an Earth Mover’s Distance benchmark \(G(D)\) based on closeness of a strategy’s spending pattern to a sub-pacing sequence \(d_t\in[0,B/T]\) with the same total spend:
\[
\mathrm{EMD}\big((c_t),(d_t)\big)
=
\sum_{t=1}^T \Big|\sum_{s=1}^t(c_s-d_s)\Big|.
\]
For any strategy class \(F\subseteq \Delta(A)^T\), the benchmark is
\[
Opt_{D,F}
=
\max_{x\in F\cap G(D)} \sum_{t=1}^T r_t(x_t).
\]
They show that sublinear regret is achievable whenever the benchmark spending pattern is within EMD \(o(T^2)\) of some sub-pacing pattern [2503.14796].

The corresponding algorithm, LagrangianEMD, combines EXP4-IX over a strategy class \(F\) with OGD on a scalar dual variable \(\lambda_t\), using adjusted payoffs \(r_t(a_t)+\lambda_t(B/T-c_t(a_t))\) [2503.14796]. The main theorem yields
\[
\mathbb{E}[\mathrm{Regret}_{Opt_{D,F}}]
\le
\alpha\cdot O\Big(\sqrt{T|A|\log|F|}+\sqrt{D}\Big),
\]
under the bounded reward-to-cost ratio \(r_t(a)\le \alpha c_t(a)\) [2503.14796]. For the “pacing over windows” benchmark, where each window of length \(w\) has its own fixed distribution subject to a window pacing constraint, the abstract states a regret bound
\[
\tilde{O}(T/\sqrt{w}+\sqrt{wT}),
\]
and the paper proves a matching lower bound [2503.14796]. It further shows that EMD scaling \(D=o(T^2)\) is essentially necessary: if two benchmark spending patterns are at EMD \(\Omega(T^2)\) apart, some adversarial environment forces \(\Omega(T)\) regret against at least one of them [2503.14796].

This adversarial-benchmark development clarifies a widespread misconception: impossibility in adversarial BwK is not merely a failure of existing algorithms, but a failure of the classical global-budget comparator. A plausible implication is that the right notion of learnability in adversarial BwK is not absolute no-regret versus all budget-feasible policies, but no-regret versus structurally paced comparators.

Non-stationary BwK occupies an intermediate regime between stochastic and adversarial environments. In this model, \((\boldsymbol{r}_t,\boldsymbol{c}_t)\sim \mathcal{P}_t\) independently across time but with time-varying distributions \(\mathcal{P}_t\), and budgets again scale as \(B=bT\) [2205.12427]. The paper shows that local variation budgets
\[
V_1=\sum_{t=1}^{T-1}\|\boldsymbol{\mu}_t-\boldsymbol{\mu}_{t+1}\|_\infty,\qquad
V_2=\max_j \sum_{t=1}^{T-1}\|\boldsymbol{C}_{t,j}-\boldsymbol{C}_{t+1,j}\|_\infty
\]
are insufficient by themselves because constraints couple decisions globally across time [2205.12427]. It introduces global non-stationarity measures
\[
W_1=\sum_{t=1}^T \|\boldsymbol{\mu}_t-\bar{\boldsymbol{\mu}}\|_\infty,\qquad
W_2=\sum_{t=1}^T \|\boldsymbol{C}_t-\bar{\boldsymbol{C}}\|_1,
\]
and shows that the dynamic LP benchmark differs from the per-period LP benchmark by at most \(W_1+\bar{q}W_2\), where \(\bar q\le 1/b\) bounds dual prices [2205.12427]. A sliding-window UCB algorithm for per-step LPs then achieves regret
\[
\tilde O\left(
\frac{1}{b}\sqrt{mT}
+
m^{1/3}V_1^{1/3}T^{2/3}
+
\frac{1}{b}m^{1/3}d\,V_2^{1/3}T^{2/3}
+
W_1+\bar q W_2
\right),
\]
with matching lower bounds for all four terms up to logarithmic factors and the linear dependence on \(d\) in the \(V_2\) term [2205.12427]. This identifies a second boundary of learnability: constrained non-stationary problems require both local and global measures of temporal variation.

## 5. Competitive-ratio refinements and vector-cost reductions

A parallel line of work approaches BwK through online learning with vector costs. In OLVC\(_p\), each action yields a \(d\)-dimensional cost vector and the objective is to minimize the \(\ell_p\)-norm of the cumulative cost [2010.07346]. The key reduction uses a smooth approximation
\[
\Psi(\Lambda)
=
\left\|\frac{p}{\epsilon}\mathbf{1}+\Lambda\right\|_p-\frac{p}{\epsilon}
\]
and surrogate scalar costs
\[
c_i^{(t)}=\langle C^{(t)}e_i,\nabla\Psi(\Lambda^{(t-1)})\rangle.
\]
This converts \(d\)-dimensional online learning into a 1-dimensional surrogate problem handled by Hedge or Exp3.P [2010.07346]. The paper proves that stochastic OLVC\(_p\) admits \(\mathrm{ALG}\le \mathrm{OPT}+o(T)\), whereas adversarial OLVC\(_p\) admits \(\mathrm{ALG}\le O(\min\{p,\log d\})\cdot \mathrm{OPT}+o(T)\) [2010.07346].

The same surrogate enters adversarial and stochastic BwK\(_p\), where the Lagrangian reward becomes reward minus \(\lambda\) times the surrogate cost [2010.07346]. For adversarial BwK\(_p\), the main result gives
\[
\mathrm{ALG}
\ge
\frac{1}{O(\min\{p,\log d\})}\cdot \mathrm{OPT}-o(T)
\]
when \(\mathrm{OPT}\) is known, and
\[
\mathrm{ALG}
\ge
\frac{1}{O(\min\{p,\log d\}\log T)}\cdot \mathrm{OPT}-o(T)
\]
otherwise [2010.07346]. In the classical \(p=\infty\) case this yields an \(O(\log d\cdot \log T)\) competitive ratio, improving over the prior \(O(d\log T)\) bound of Immorlica et al. [2010.07346]. The paper also establishes matching lower bounds for the \(\min\{p,\log d\}\) dependence, showing that logarithmic rather than linear dependence on \(d\) is optimal in adversarial BwK\(_\infty\) [2010.07346].

This vector-cost reduction is significant for BwK because it isolates the dimensional difficulty of multi-resource control from the bandit component. Rather than treating each resource as a separate adversarial constraint directly, the reduction compresses all resources into a scalar surrogate driven by the gradient of a smooth potential. A plausible implication is that similar reductions may be useful wherever BwK-style budget constraints appear inside larger online optimization systems with many coupled resources.

## 6. Emerging directions and current frontier

Several recent directions expand BwK beyond its classical algorithmic envelope. One is quantum computation. “Quantum Algorithms for Bandits with Knapsacks with Improved Regret and Time Complexities” initiates quantum BwK with quantum reward and resource oracles, as well as quantum LP access through QRAM [2507.04438]. In the problem-independent regime, the quantum algorithm improves the classical regret bound by a factor of
\[
1+\sqrt{B/\mathrm{OPT}_{\mathrm{LP}}},
\]
yielding
\[
\mathrm{OPT}_{\mathrm{LP}}-\mathbb{E}[\mathrm{REW}]
\le
\mathcal{O}\!\left(\sqrt{\log(dT)}\right)\left(\mathrm{OPT}_{\mathrm{LP}}\sqrt{\frac{m}{B}}\right)
+\mathcal{O}\!\left(m\log(dT)\log T\right)
\]
in the paper’s stated form [2507.04438]. In the problem-dependent regime, a quantum algorithm using an inexact quantum LP solver achieves leading regret
\[
\tilde{\mathcal{O}}\left(
\left(2+\frac1b\right)\frac{m\sqrt d}{b\delta}\log T
+
\frac{d^4}{b^2\min\{\chi^2,\delta^2\}\min\{1,\sigma^2\}}
\right),
\]
improving the classical \(1/\delta^2\) dependence to \(1/\delta\) and the leading \(d\) factor to \(\sqrt d\) [2507.04438]. The same work also reports polynomial speedups in LP-solver time complexity relative to classical counterparts [2507.04438]. This suggests that some hardness in BwK is computational rather than information-theoretic, particularly in gap-dependent LP-identification phases.

Another active theme is the search for “best-of-both-worlds” guarantees across stochastic and adversarial settings. The repeated-game perspective of Immorlica et al. already unified algorithmic primitives between stochastic and adversarial BwK [1811.11881], while EXP3++.BwK was explicitly designed to be order-optimal adversarially and almost optimal stochastically up to a \(\log(B)\) factor [1811.12253]. More recent adversarial benchmark work indicates that such unification must be benchmark-sensitive: stochastic regret against LP relaxations and adversarial competitiveness against fixed-distribution or paced comparators can coexist, but only because the comparators themselves differ [2503.14796].

A recurring limitation across the literature is dependence on structural assumptions. Logarithmic stochastic regret requires nondegenerate LP solutions, positive basis gaps, and favorable geometric parameters such as \(\sigma\) and \(\chi\) [1510.01800], [2102.06385]. Constant or logarithmic regret in non-monotonic BwK requires a positive-drift null arm and separation conditions on drifts [2209.12013]. Sublinear regret in adversarial BwK requires paced benchmark spending patterns at EMD \(o(T^2)\) from sub-pacing [2503.14796]. These assumptions are not merely technical conveniences: lower bounds in the corresponding papers show that when they fail, \(\sqrt{T}\), linear, or competitive-ratio-only guarantees reappear.

Taken together, these results position BwK as a general theory of online learning under dynamic budget balance. The classical stochastic regime is now well understood through LP relaxations and primal-dual algorithms; structured action spaces can often be absorbed into the same framework; adversarial learnability depends critically on benchmark design; and current frontier work studies refined comparators, renewable resources, and computational acceleration [1305.2545], [1811.11881], [2102.06385], [2209.12013], [2503.14796], [2507.04438].

Source: https://www.emergentmind.com/topics/bandits-with-knapsacks-bwk