← ~/visualizations

online-algorithms

Visualizes the online decision model using a streaming-day scenario (ski rental): input arrives day by day, the online algorithm must commit (rent vs BUY) without future knowledge, while OPT is a clairvoyant offline benchmark that knows the stopping day T. The animation alternates adversarial stopping times to show worst-case behavior and displays the competitive inequality and the resulting cost/OPT ratio against a highlighted competitive bound c.

canvasclick to interact
t=0s

practical uses

  • 01.Designing caching/paging strategies (LRU/FIFO) under unknown future requests
  • 02.Ski-rental style buy-vs-rent decisions (cloud reservations, equipment leasing)
  • 03.Analyzing scheduling/queueing policies with adversarial or worst-case arrivals

technical notes

Implements a deterministic ski-rental instance with buy cost B and online threshold k=B. Each animation cycle reveals the input stream up to an adversarially chosen stop day T, then compares ONLINE cost vs OPT with animated bars and a ratio dial. Uses grid snapping for a blocky aesthetic, green-on-black palette, and time-based easing for smooth transitions.