Efficient Contextual Bandits with Knapsacks via Regression

Aleksandrs Slivkins, Dylan J. Foster · OpenReview

Abstract

Contextual bandits with linear constraints (CBwLC) generalize the classic "Bandits with Knapsacks" (BwK) framework by allowing for both packing and covering constraints, as well as positive and negative resource consumption. We present the first computationally efficient algorithm for CBwLC based on regression oracles. By framing the problem as a modular primal-dual game, our approach achieves statistically optimal regret in stochastic settings and provides the first vanishing-regret guarantees for non-stationary environments.

Introduction

In standard contextual bandit problems, an agent aims to maximize cumulative rewards by selecting actions based on observed contexts. However, real-world applications—such as ad placement with budget limits or clinical trials with resource quotas—are often governed by linear constraints. These scenarios fall under Contextual Bandits with Linear Constraints (CBwLC), a framework that encompasses packing constraints (budgets), covering constraints (minimum requirements), and resource replenishment.

Historically, algorithms for these problems relied on "classification oracles," which are often computationally intractable (NP-hard). This paper introduces LagrangeCBwLC, a framework that leverages regression oracles (e.g., neural networks or linear models), making it compatible with modern machine learning libraries while maintaining strong theoretical guarantees.

The LagrangeCBwLC Framework

The core of our approach is a reduction of the constrained optimization problem to a repeated zero-sum game between two players: a Primal Player and a Dual Player.

1. The Primal Player (AlgPrim)

The Primal Player is responsible for action selection. We utilize SquareCB, a regression-based technique that predicts rewards and resource costs for each action. It employs "inverse gap weighting" to balance exploration and exploitation, ensuring the agent explores potentially high-reward actions while favoring those with high predicted payoffs.

2. The Dual Player (AlgDual)

The Dual Player manages the constraints by treating each resource as an "action" in its own bandit sub-problem. Using the Hedge algorithm, the Dual Player adjusts the "prices" (Lagrange multipliers) of resources. If a resource is being consumed too quickly or a requirement is not being met, the Dual Player increases the associated price, signaling the Primal Player to adjust its strategy.

3. Lagrangian Relaxation

The interaction between these players is mediated by a Lagrangian relaxation. This mathematical formulation incorporates constraints directly into the reward function. The Primal Player seeks to maximize the Lagrangian (reward minus penalized cost), while the Dual Player seeks to minimize it by adjusting penalties.

Addressing Non-Stationarity: The Pacing Benchmark

A significant contribution of this work is the extension of CBwLC to non-stationary or "switching" environments, where the underlying distribution of contexts, rewards, and costs changes $S$ times.

In such environments, comparing performance against a single fixed policy is often an insufficient or impossible benchmark. We introduce the Pacing Benchmark, which allows for the best distribution of actions in each round but requires the agent to "pace" its resource consumption uniformly over time. This benchmark allows us to bypass previous impossibility results and provide meaningful guarantees in adversarial settings.

Key Results and Analysis

Our modular analysis demonstrates that the performance of LagrangeCBwLC scales gracefully with the complexity of the environment:

  • Stochastic Optimality: Under Slater’s Condition (a feasibility assumption), the algorithm achieves $O(\sqrt{T})$ outcome-regret, which is statistically optimal.
  • General Robustness: Without strict assumptions, the algorithm guarantees $O(T^{3/4})$ regret for any CBwLC instance.
  • Adaptability: In switching environments, the regret scales with $O(\sqrt{S \cdot T})$, proving the algorithm can adapt to changing rules.
  • Efficiency: By utilizing regression oracles, the algorithm avoids the computational bottlenecks of prior classification-based methods.

Conclusion

LagrangeCBwLC provides a simple, modular, and efficient solution for constrained contextual bandits. By bridging the gap between regression-based learning and Lagrangian optimization, it offers a practical framework for real-world decision-making under resource constraints. Future work includes removing the requirement for prior knowledge of the constraint feasibility margin ($\zeta$) and refining performance in regimes with very small budgets.

Summary updated

BibTeX
@inproceedings{slivkins2023efficient,
  author = {Aleksandrs Slivkins and Dylan J. Foster},
  title = {{Efficient Contextual Bandits with Knapsacks via Regression}},
  booktitle = {Conference on Learning Theory},
  year = {2023},
  url = {https://openreview.net/forum?id=bgQr8Vx8HY},
}
Figure