All projects

N9/09ResearchAI & agentsComplexity: Complex

FlexDrop

Customers trade a little delivery flexibility for a small reward; FlexDrop uses it to batch orders onto fewer, shorter routes.

Status
Working system (simulation)
Year
2026
Built for
Swiggy Food for Thought 2.0 · Team Nexara9
Languages
Python, JavaScript, CSS
Team
Sujal Negi, Made Navya
FlexDrop operations dashboard with a 3D campus world, live routes and KPIs
01

Overview

FlexDrop is an adaptive delivery coordination engine. At checkout, a student can choose “deliver 10 minutes later and get ₹8 back”. FlexDrop prices that offer from the savings it expects, then uses only as much of each customer’s approved flexibility as it needs to combine compatible Food and Instamart orders onto fewer, shorter rider routes.

Every approved window, food-safety limit and rider earnings floor is still respected.

02

Problem and aim

Problem

Delivery apps dispatch most orders independently and as fast as possible, even when the customer would happily wait a few minutes. That means more trips, longer distances and higher cost per order.

Aim

Turn customer-approved flexibility into an explicit, bounded optimisation variable that lowers cost without hurting on-time delivery or food quality.

03

How it works

01 / 06

Offer

An acceptance model predicts how likely a customer is to accept each wait-for-reward option, and only explicit consent counts.

02 / 06

Price the reward

The incentive optimiser picks the reward that maximises expected savings minus what it pays out, within viability caps.

03 / 06

Check compatibility

Hard rules for temperature, contamination, leaks, fragility, capacity and timing decide which orders may ride together.

04 / 06

Optimise routes

Rolling-horizon column generation, exact branch-and-bound sequencing and CP-SAT set packing choose the batches and routes.

05 / 06

Spend flexibility carefully

Each order’s used flexibility stays between zero and what the customer approved, and the least needed is used.

06 / 06

Re-optimise

Plans adapt to prep delays, cancellations and rider drop-outs, without ever extending a window the customer did not approve.

04

Architecture

A decision service that sits next to dispatch

ACallers

  • CheckoutAsks for a quote; records consent.
  • Dispatch engineAsks for a plan every epoch.
  • FlexDrop StudioBrowser UI: 3D campus (three.js), map (Leaflet).

BFastAPI service

  • API + servicesOrders, preferences, optimise, plan events.
  • EnginesIncentive, compatibility, optimiser, routing, re-optimiser.
  • ML registryPrep, travel, acceptance, coordination models.

CData

  • SQLAlchemySQLite in development, PostgreSQL in production.
  • AlembicDatabase migrations.
  • PrometheusMetrics and an audit log.

Request flow

  1. Checkout sends an order; FlexDrop predicts prep and travel time and quotes wait-for-reward offers.
  2. The customer accepts or declines; consent and the approved window are stored.
  3. Each dispatch epoch, the optimiser batches compatible orders and sequences routes.
  4. Dispatch executes the plan and reports events; the re-optimiser adapts to delays.
  5. If FlexDrop is off or slow, dispatch simply continues on its normal path.
05

Languages and code

  • Python62.5%
  • JavaScript33.2%
  • CSS2.6%
  • HTML1.2%
  • Shell0.5%

Repository

131 files19,386 linesTap any file to read its code

  • .github/1 file
    • workflows/1 file
      • 36 lines
  • data/2 files
    • sample/Sample campus and city data.
      • 37 lines
      • 37 lines
  • deploy/Production config (nginx, systemd) and database migrations.
    • nginx/1 file
      • 43 lines
    • systemd/2 files
      • 10 lines
      • 31 lines
    • 14 lines
  • docs/Architecture, maths model, algorithms, API, security, deployment.
    • 143 lines
    • 175 lines
    • 143 lines
    • 76 lines
    • 83 lines
    • 147 lines
    • 185 lines
    • 193 lines
    • 27 lines
    • 184 lines
    • 161 lines
  • migrations/Production config (nginx, systemd) and database migrations.
    • versions/1 file
      • 355 lines
    • 42 lines
    • 27 lines
  • reports/Simulation results, comparisons and robustness runs.
    • 35 lines
    • 237 lines
    • 35 lines
    • 237 lines
    • 102 lines
    • 20 lines
    • 75 lines
  • scripts/5 files
    • 50 lines
    • 60 lines
    • 50 lines
    • 22 lines
    • 113 lines
  • src/75 files
    • flexdrop/The Python package.
      • api/FastAPI app, routers, API-key roles, rate limits, idempotency, errors.
        • routers/7 files
          • 1 line
          • 67 lines
          • 58 lines
          • 53 lines
          • 28 lines
          • 102 lines
          • 147 lines
        • 1 line
        • 98 lines
        • 39 lines
        • 52 lines
        • 92 lines
        • 100 lines
      • db/Database layer and core domain types.
        • 1 line
        • 46 lines
        • 240 lines
        • 67 lines
      • domain/Database layer and core domain types.
        • 1 line
        • 269 lines
      • engines/incentive, compatibility, optimizer, routing, flexibility, reoptimizer, promise, cost, travel.
        • 1 line
        • 140 lines
        • 68 lines
        • 85 lines
        • 149 lines
        • 461 lines
        • 43 lines
        • 130 lines
        • 304 lines
        • 66 lines
      • ml/Features, models, training and the model registry.
        • 1 line
        • 78 lines
        • 227 lines
        • 154 lines
        • 244 lines
      • services/Use-cases between the API and the engines: orders, dispatch, metrics, privacy.
        • 1 line
        • 99 lines
        • 265 lines
        • 29 lines
        • 461 lines
        • 68 lines
        • 80 lines
        • 299 lines
        • 74 lines
      • simulation/Scenarios, the five dispatch policies, the event simulator and metrics.
        • 1 line
        • 117 lines
        • 85 lines
        • 99 lines
        • 87 lines
        • 245 lines
        • 406 lines
        • 632 lines
      • web/FlexDrop Studio: checkout, operations dashboard, 3D campus and results.
        • css/1 file
          • 267 lines
        • js/10 files
          • 43 lines
          • 2966 lines
          • 343 lines
          • 358 lines
          • 276 lines
          • 142 lines
          • 99 lines
          • 120 lines
          • 736 lines
          • 114 lines
        • 153 lines
      • 8 lines
      • 6 lines
      • 300 lines
      • 36 lines
      • 57 lines
      • 219 lines
      • 227 lines
      • 50 lines
      • 53 lines
      • 51 lines
      • 245 lines
      • 421 lines
  • tests/Unit, optimisation and integration tests.
    • integration/4 files
      • 1 line
      • 450 lines
      • 173 lines
      • 178 lines
    • optimization/4 files
      • 1 line
      • 191 lines
      • 58 lines
      • 116 lines
    • unit/5 files
      • 1 line
      • 106 lines
      • 97 lines
      • 182 lines
      • 157 lines
    • 1 line
    • 143 lines
  • 10 lines
  • 14 lines
  • 39 lines
  • 20 lines
  • 48 lines
  • 65 lines
  • 185 lines
  • 14 lines
  • models/Trained model files and their metadata. on GitHub
06

Methodology

  1. Model the problem mathematically, then build each engine as its own tested module.
  2. Compare five dispatch policies in a discrete-event simulation of a campus and a city.
  3. Run an ablation (no flexibility) to separate the gain from flexibility from the gain from the optimiser.
  4. Repeat over five random seeds and report the spread, not just one good run.
07

Technology

OptimisationCP-SAT (OR-Tools)Set packing of compatible batches.
Column generationBuilds candidate routes efficiently.
Branch and boundExact stop sequencing per route.
MLLogistic regressionAcceptance, prep-time and travel-time predictions.
ServicePython + FastAPIAPI with roles, idempotency, audit log and a kill switch.
PrometheusOperational metrics.
08

Demo

09

Results

ScenarioPolicyCost per orderDistance per orderOn-time
Campus (470 orders)Independent dispatch₹78.564.56 km90.2%
Conventional batching₹73.784.16 km92.1%
FlexDrop₹66.21 (−15.7%)3.30 km92.8%
City (404 orders)Independent dispatch₹83.145.00 km95.8%
Conventional batching₹79.764.67 km95.3%
FlexDrop₹72.84 (−12.4%)3.92 km95.0%
Simulation, synthetic data, 4 hours of evening demand. FlexDrop costs include the rewards paid to customers.
Over five seeds FlexDrop cut cost by 15.5% ± 1.5 (campus) and 10.8% ± 1.3 (city), with on-time rate unchanged within noise, zero food-quality violations and about 50 ms optimisation latency (P95).
10

Concepts

01What is the vehicle routing problem?

Choosing which vehicle serves which stops, and in what order, to minimise cost under constraints like time windows and capacity. It gets hard very quickly as orders grow.

02What is column generation?

Instead of listing every possible route (far too many), the solver starts with a few and keeps adding only the routes that could improve the answer.

03What is a rolling horizon?

Plan for the next short window with the orders you know, commit only what must leave now, and re-plan as new orders arrive.

04What is an ablation study?

Remove one part of the system and measure again. The difference shows how much that part contributes.

11

Team