Inferensys

Glossary

Online Algorithm

An online algorithm processes its input piece-by-piece in a serial fashion without having the entire input available from the start, which is essential for real-time decision-making in dynamic routing and scheduling.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
COMPUTER SCIENCE

What is an Online Algorithm?

A fundamental algorithmic paradigm for processing data streams and making real-time decisions without future knowledge.

An online algorithm is a computational method that processes its input sequentially, piece-by-piece, without having access to the entire input dataset from the start, forcing irrevocable decisions at each step. This contrasts with offline algorithms, which have complete foresight. Online algorithms are defined by their competitive ratio, a worst-case performance metric comparing them to an optimal offline clairvoyant algorithm. They are essential for real-time systems, dynamic routing, and any domain where data arrives as a continuous stream.

In priority-based routing for a heterogeneous fleet, an online algorithm must assign tasks and plan paths for agents as new orders arrive and environmental conditions change, without knowledge of future requests. Common examples include the greedy algorithm for task assignment and incremental search methods like D Lite* for path replanning. The core challenge is balancing immediate optimality with long-term efficiency, often requiring robust competitive analysis to guarantee performance bounds despite the inherent uncertainty.

DEFINITION

Key Characteristics of Online Algorithms

Online algorithms process input sequentially without future knowledge, making irrevocable decisions in real-time. This contrasts with offline algorithms, which have complete input available from the start.

01

Sequential Input Processing

An online algorithm receives its input as a sequence or stream, processing each piece one at a time. It must make a decision or produce an output for each input item before seeing the next. This is fundamental to real-time systems like dynamic routing, where tasks (e.g., delivery requests) arrive continuously and must be assigned immediately.

  • Example: A food delivery app assigning each new order to a driver as it arrives, without knowing future order locations or times.
02

Irrevocable Decisions

Decisions made by an online algorithm are typically final or costly to reverse. Once an agent is assigned a route or a resource is allocated, changing that assignment incurs a switching cost or causes significant disruption. This characteristic necessitates careful, often conservative, decision-making to avoid poor long-term outcomes.

  • Contrast: An offline algorithm can backtrack and re-optimize the entire plan after seeing all data.
03

Competitive Ratio Analysis

The performance of an online algorithm is measured using competitive analysis. It compares the algorithm's solution cost to the optimal offline solution cost (calculated with full future knowledge).

If for all possible input sequences, the online algorithm's cost is at most c times the optimal offline cost plus a constant, the algorithm is c-competitive. A lower competitive ratio (c) indicates better worst-case performance.

  • Formula: Cost_online(σ) ≤ c * Cost_optimal(σ) + α for all sequences σ.
04

Lack of Future Knowledge

The defining constraint is the absence of clairvoyance. The algorithm has no information about future inputs, their timing, or their properties. This models real-world uncertainty. Performance hinges on the algorithm's strategy for handling this uncertainty, often using:

  • Conservative strategies that preserve flexibility.
  • Aggressive strategies that optimize for immediate gain.
  • Predictive models that estimate future inputs, though these are heuristic and not guaranteed.
05

Real-Time Responsiveness

Online algorithms must produce decisions within a strict time constraint, often immediately upon receiving an input item. The computational complexity per decision must be low, typically O(log n) or O(1), to ensure the system remains responsive to a high-frequency stream of events.

This excludes complex, batch-style optimization from consideration for the core decision loop.

06

Use in Dynamic Routing & Scheduling

In heterogeneous fleet orchestration, online algorithms are the core of real-time replanning engines and dynamic task allocators. They handle:

  • New task insertion: Assigning a high-priority job to the best-suited agent immediately.
  • Agent failure: Re-routing other agents to cover the failed agent's tasks.
  • Traffic delay: Recalculating paths for affected agents in real-time.

Classic theoretical models include the Online Transportation Problem and the k-Server Problem, which abstract dynamic resource allocation.

COMPARISON

Online vs. Offline Algorithms

This table contrasts the core operational characteristics of online and offline algorithms, which define their applicability in dynamic fleet orchestration and priority-based routing.

FeatureOnline AlgorithmOffline Algorithm

Input Availability

Processes input sequentially, piece-by-piece, as it arrives.

Has the entire input dataset available from the start of computation.

Knowledge of Future

Has zero or limited knowledge of future inputs.

Has complete knowledge of all future inputs.

Decision Irrevocability

Must make immediate, irrevocable decisions with partial information.

Can defer decisions, backtrack, and optimize globally with full information.

Performance Metric

Competitive Ratio: Compares performance against an optimal offline algorithm.

Optimality Gap: Measures deviation from a theoretical global optimum.

Computational Complexity

Typically requires O(1) to O(log n) time per decision for real-time operation.

Can afford polynomial or exponential time for exhaustive global optimization.

Memory Requirement

Often bounded, maintaining only a limited state (e.g., sliding window).

Unbounded in principle, can store and process the entire input dataset.

Primary Use Case

Real-time systems: dynamic task allocation, real-time replanning, live routing.

Batch processing: strategic scheduling, pre-computed route optimization, simulation.

Example in Fleet Orchestration

Dynamic replanning for an AMR when a new high-priority task is inserted.

Computing the optimal weekly delivery schedule for a static set of orders.

ONLINE ALGORITHMS

Real-World Applications

Online algorithms are essential for systems that must make irrevocable decisions with incomplete information, processing inputs sequentially as they arrive. Their applications span from real-time logistics to fundamental computer science.

01

Dynamic Fleet Routing

In heterogeneous fleet orchestration, online algorithms process new delivery requests, traffic updates, and agent status changes in real-time. They must irrevocably assign tasks and plan routes without knowing future orders. This is a canonical application of the Online Vehicle Routing Problem (OVRP), where the goal is to minimize total travel distance or maximize on-time deliveries despite an unknown stream of future pickups and drop-offs.

< 1 sec
Typical Replanning Latency
02

CPU & Task Scheduling

Operating system schedulers are classic online algorithms. They must allocate the CPU to incoming processes without knowledge of future job arrivals or runtimes. Algorithms like Shortest Remaining Time First (SRTF) or Earliest Deadline First (EDF) make immediate decisions that impact system responsiveness and throughput. The competitive ratio is a key metric, comparing the online scheduler's performance against an optimal offline clairvoyant scheduler.

03

Financial Trading & Order Matching

High-frequency trading platforms and stock exchanges use online algorithms to match buy and sell orders as they arrive. The algorithm must immediately decide whether to execute an incoming order at the current best price or place it in an order book, without knowing the composition of future orders. This directly applies the online bipartite matching problem, where the goal is to maximize total value matched in a stream of requests.

04

Online Caching (Paging)

Managing a finite cache (e.g., CPU cache, web CDN) is a foundational online problem. When a requested item is not in the cache (a miss), the algorithm must evict an existing item to make space, without knowing future requests. Well-known strategies like Least Recently Used (LRU) and First-In-First-Out (FIFO) are online heuristics. The competitive analysis of paging algorithms, like the proven performance bounds of LRU, is a cornerstone of online algorithm theory.

05

Real-Time Bidding in Ad Auctions

When a user loads a webpage, an auction for ad space occurs in milliseconds. Each advertiser's bidding algorithm receives user context and must submit a bid without knowing the bids of other participants or details of the next impression. This is an online selection problem under budget constraints. Algorithms must pace spending across a potentially unknown sequence of opportunities to maximize conversions or clicks.

06

The K-Server Problem

This abstract, theoretical problem models many real-world scenarios like request routing in a server farm or mobile agent patrol. k servers (or agents) exist in a metric space. Requests arrive online at points in the space, and an algorithm must immediately select a server to move and serve the request, minimizing total movement cost. While theoretically complex, it directly informs the design of algorithms for dynamic resource allocation and load balancing in unpredictable environments.

DEFINITION

How Online Algorithms Work

An online algorithm is a computational process that processes its input sequentially, making irrevocable decisions without knowledge of future inputs, contrasting with offline algorithms that have complete input knowledge from the start.

In heterogeneous fleet orchestration, an online algorithm makes real-time routing and task assignment decisions as new orders arrive and agent statuses change. It cannot wait for a complete daily dataset; each decision about which robot gets the next task or which path to take is made with only current and historical information. This is essential for dynamic environments like warehouses where conditions are unpredictable. The performance of such algorithms is often evaluated via competitive analysis, comparing their output to an optimal offline algorithm that foresaw the entire input sequence.

Common examples in priority-based routing include greedy algorithms for immediate task assignment and incremental replanners like D Lite*. These algorithms must balance immediate optimization with long-term efficiency, often using heuristics to anticipate future demand. Their design directly impacts key operational metrics like makespan and on-time delivery rates. Effective online decision-making is the computational core enabling responsive, real-time logistics and autonomous supply chain intelligence.

ONLINE ALGORITHMS

Frequently Asked Questions

Online algorithms are foundational to real-time decision-making in dynamic systems like heterogeneous fleet orchestration. Unlike offline algorithms, they process inputs sequentially without future knowledge, making them essential for responsive routing and scheduling.

An online algorithm is a computational method that processes its input sequentially, in a piece-by-piece manner, without having access to the entire input dataset from the start. It must make irrevocable decisions for each piece of data as it arrives, based only on past inputs and without knowledge of the future. This contrasts with an offline algorithm, which has complete foresight of the entire input sequence before any computation begins.

In the context of priority-based routing for a heterogeneous fleet, an online algorithm would assign tasks and plan paths for robots and vehicles as new orders arrive and environmental conditions change in real-time, without knowing all future delivery requests or potential obstacles in advance.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.