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.
Glossary
Online Algorithm

What is an Online Algorithm?
A fundamental algorithmic paradigm for processing data streams and making real-time decisions without future knowledge.
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.
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.
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.
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.
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 σ.
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.
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.
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.
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.
| Feature | Online Algorithm | Offline 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. |
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.
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.
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.
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.
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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Online algorithms operate within a broader ecosystem of computational techniques essential for real-time decision-making. These related concepts define the constraints, performance metrics, and alternative approaches used in dynamic systems like priority-based routing.
Offline Algorithm
An offline algorithm has complete knowledge of the entire input sequence from the start, allowing it to compute an optimal solution with full foresight. This contrasts with online algorithms, which must make irrevocable decisions without future knowledge.
- Key Difference: Possesses the entire problem instance upfront.
- Performance Benchmark: The optimal offline solution is used to measure the competitive ratio of an online algorithm.
- Example: Computing the absolute shortest path for a day's deliveries after all orders are known, versus routing vehicles as orders arrive.
Competitive Ratio
The competitive ratio is the primary theoretical performance measure for an online algorithm. It quantifies the worst-case ratio between the cost (or value) of the online algorithm's solution and the cost of the optimal offline solution that knows the future.
- Formula: For a minimization problem, if ALG(I) is the online algorithm's cost and OPT(I) is the optimal offline cost on input sequence I, the competitive ratio is sup over all I of [ALG(I) / OPT(I)].
- Interpretation: A ratio of 2 means the online algorithm is never worse than twice the optimal offline solution, even in an adversarial scenario.
- Significance: Provides a rigorous, data-independent guarantee for dynamic systems where future inputs are unknown.
Dynamic Replanning
Dynamic replanning is the practical capability of a system to modify or generate a new plan in real-time as the environment changes. It is the engineering implementation of online algorithmic principles.
- Core Mechanism: Continuously monitors the world state (e.g., new high-priority tasks, agent breakdowns, blocked paths) and triggers a re-optimization.
- Algorithms: Often uses incremental search algorithms like D Lite* or Lifelong Planning A (LPA)** to update paths efficiently without recomputing from scratch.
- Use Case: In fleet orchestration, a robot's route is dynamically replanned when a human-operated forklift unexpectedly blocks its planned corridor.
Greedy Algorithm
A greedy algorithm makes a series of choices, each of which looks best at the moment (locally optimal), without regard for the overall future consequences. Many effective online algorithms employ greedy heuristics due to their low computational overhead.
- Online Nature: By definition, a greedy algorithm processes input sequentially and makes irrevocable decisions, fitting the online paradigm.
- Trade-off: Often simple and fast but may not provide strong competitive guarantees. Example: Always assigning the nearest available robot to a new task.
- Analysis: Competitive analysis is frequently used to evaluate the worst-case performance of greedy online strategies.
Real-Time System
A real-time system is one where the correctness of the system depends not only on the logical result of computation but also on the time at which the results are produced. Online algorithms are a critical component of the decision-making layer in such systems.
- Hard vs. Soft Deadlines: Must meet absolute deadlines (hard) or strive to meet them (soft). Online algorithms for routing often incorporate Earliest Deadline First (EDF) principles.
- Determinism: Requires predictable, bounded execution times for algorithms, influencing the design of online solvers.
- Context: In heterogeneous fleets, the orchestration platform is a real-time system that uses online algorithms to make scheduling decisions within strict latency bounds.
Adversarial Analysis
Adversarial analysis is a framework for evaluating online algorithms under the assumption that future inputs are chosen by an opponent to maximize the algorithm's cost relative to the optimal solution. It underpins competitive analysis.
- Philosophy: "Prepare for the worst." It provides robust guarantees that hold even under unexpected or malicious input sequences.
- Design Impact: Leads to the creation of conservative, randomized, or memory-enhanced algorithms that perform well against an adversary.
- Example: An online task assignment algorithm is analyzed against an adversary that generates new high-priority tasks precisely when all critical agents are occupied.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us