---
title: Competitive Online Algorithms
url: https://www.emergentmind.com/topics/competitive-online-algorithms
type: topic
---

# Competitive Online Algorithms

A competitive online algorithm is an algorithm that makes irrevocable decisions on a sequence of inputs arriving over time, without knowledge of future inputs, and whose performance is measured against an offline optimum with full foresight. The standard metric is the competitive ratio, defined as the supremum over all input sequences of the ratio (for minimization problems) or inverse ratio (for maximization problems) between the algorithm’s cost and the cost of the optimal offline solution. Competitive analysis has emerged as the foundational framework for online decision-making across a wide variety of domains, including online matching, packing, scheduling, finance, metrical task systems, resource allocation, submodular optimization, and optimization under switching costs, as well as models incorporating stochasticity, noisy prediction, and recourse.

## 1. Definition and General Principles

Let $\text{ALG}(I)$ denote the (expected) cost or reward of an online algorithm ALG on input sequence $I$, and $\text{OPT}(I)$ the optimal offline cost or reward. For a minimization problem, ALG is called $c$-competitive if there exists a constant $a$ such that
\[
\text{ALG}(I) \leq c\,\text{OPT}(I) + a \quad \forall\,I,
\]
yielding a competitive ratio $c$. For maximization problems, the direction of the inequality is reversed. This ratio captures the worst-case performance loss due to lack of future information. The adversary may be oblivious (adversarially selecting the input in advance) or adaptive (choosing future inputs based on the algorithm’s past actions).

Competitive analysis is universally applicable to causal, non-anticipatory rules in domains such as online bipartite matching [1810.07903, 2005.01929, 2111.01718], inventory allocation [1905.04770], secretary problems [0807.1139], online knapsack [2004.10358], online set cover [2012.05361], metrical task systems [1905.07145], dynamic queues [0802.1685], submodular maximization [1907.00312], energy harvesting communications [1112.5557], and online switching and memory-dependent control [2002.05318].

## 2. Competitive Ratios in Canonical Online Models

**Matching and Assignment:**  
The celebrated online bipartite matching problem, where vertices arrive one at a time and must be irrevocably matched to available offline vertices, admits a tight randomized competitive ratio of $1-1/e$ via the Ranking algorithm in the unweighted case [1810.07903, 2111.01718, 1606.06395]. Generalizations yield lower bounds in more demanding models: $2-\sqrt{2}\approx 0.585$ in the fully online fractional model, and approximately $0.567$ for integral matching in the all-vertices-online setting [1810.07903]. For online edge-weighted bipartite matching, the best known guarantee is a $0.5086$-competitive algorithm using negatively correlated online choices (OCS subroutine) [2005.01929]. In adversarial secretary variants under random arrival order, sample-and-price schemes are 8-competitive for edge-weighted matchings [0807.1139].

**Packing and Trading:**  
In one-way trading (fractional packing under unknown prices), the optimal competitive ratio is $\ln(\theta) + 1$, where $\theta=U/L$ is the ratio of maximal to minimal price, achieved by a threshold rule that posts a time-dependent price reservation [2004.10358, 1209.6489]. Under an infinitesimal assumption, the same ratio is tight for online knapsack [2004.10358].

**Resource-Allocation and Submodular Maximization:**  
Online resource allocation with monotone continuous DR-submodular objectives under linear packing constraints yields tight competitive ratios of $1/(1-\alpha_{H_1}+\ln(U_1/L_1))$ (single constraint), extending classical LP bounds [1907.00312]. For online positive semidefinite (PSD) cone maximization (e.g., experiment design), primal-dual greedy algorithms can be systematically tuned using Loewner's theorem to match optimal competitive ratios for objectives such as D-optimality or A-optimality [1802.01312].

**Switching and Energy:**  
Scheduling in metrical task systems with state-dependent switching costs (e.g., online energy plan selection, microgrid unit-commitment, or general convex hitting with memory) yields exact optimal competitive ratios: deterministic algorithms cannot beat 3, randomized algorithms cannot beat 2 in two-state systems [1905.07145]. Energy harvesting communication systems allow a trivial 2-competitive “lazy” policy, with lower bounds currently at $1.38$ [1112.5557]. 

**Stochastic Models:**  
In stochastic online matching (known IID or with random edge presence), non-adaptive algorithms attain a tight $1-1/e$ as the best possible [1606.06395]; in certain settings (unweighted, uniform success), strengthened LP-guides yield improved ratios above $1-1/e$.

**Dynamic/Adaptive and Bounded Adversary Models:**  
When algorithms are permitted bounded recourse (rewinding previous assignments at a limited cost), as in online matching or orientation, the competitive ratio can be improved from $\Theta(\log n)$ to $O(1)$ using $O(n)$ to $O(n\log n)$ recourse [2001.03015, 2001.03107]. In online-bounded analysis, an adversary restricted to keep up with the online algorithm on all prefixes yields strictly better bounds for locally greedy rules across scheduling and packing problems [1602.06708].

## 3. Primal-Dual and Multilinear Methods

Competitive-ratio optimality is often established by primal-dual analysis, in which dual potentials or Lagrange multipliers are constructed in parallel

Source: https://www.emergentmind.com/topics/competitive-online-algorithms