Start typing to search this publication.
techcirkle
Open menu

Subscribe to techcirkle

Get new posts delivered straight to your inbox.

Modelling Fuel Delivery Routing: Compartments, Windows and Re-Planning

A developer's guide to fuel delivery routing: compartment capacity, time windows, night-only sites, reloads, hours of service and AI re-planning.

techcirkle
4 min read
Cover image for Modelling Fuel Delivery Routing: Compartments, Windows and Re-Planning
Hands holding a smartphone with colourful app icons floating out of the screen
Hands holding a smartphone with colourful app icons floating out of the screen

In fuel delivery, profit per truck depends heavily on how much fuel it dispenses per hour on the road. That makes routing one of the highest-leverage pieces of code in the whole platform. This post walks through how we model the problem. The wider product context is in our guide to choosing a fuel delivery app development company.

Start from the classic problem

At its core this is a capacitated vehicle routing problem with time windows (CVRPTW): a fleet of trucks, a set of stops with demands and windows, and the goal of minimising time or distance while serving everyone. Fuel adds several twists.

Twist 1: compartments by product

Trucks often carry multiple products in separate compartments. Capacity is not one number:

type Truck = {
  id: string;
  compartments: { product: Product; capacity: number; loaded: number }[];
  depotId: string;
  shiftStart: string;
  shiftEnd: string;
  maxDriveMinutes: number;
};

type Stop = {
  id: string;
  location: LatLng;
  demands: { product: Product; volume: number; flexible: boolean }[];
  window: { from: string; to: string };
  nightOnly: boolean;
  serviceMinutes: number;
  priority: "normal" | "urgent";
};

flexible matters for fill-to-full orders where the exact volume is unknown until the meter stops. We plan with an estimate (from asset capacity and consumption history) plus a safety margin.

Twist 2: access rules

Some yards only allow fueling at night when vehicles are parked. Some sites close at weekends. Encode these as hard windows, not soft penalties, or the optimiser will happily schedule impossible visits.

Twist 3: reloads

A truck may empty a compartment mid-route and return to a depot. Model depots as optional stops that reset compartment levels, with their own service time. Allowing reloads often increases total volume per shift considerably on dense routes.

Twist 4: driver hours

Hours-of-service rules cap driving and on-duty time. Treat these as hard constraints per driver, not per truck, because drivers can swap vehicles.

Objective function

We usually optimise for a weighted mix:

Term

Why

Total drive time

Fuel and labour cost

Volume dispensed per route hour

The real profit metric

Window violations

Customer promise

Overtime

Labour cost and compliance

Pure distance minimisation can produce routes that look efficient but leave trucks half full.

Real-time re-planning

Nightly plans break by mid-morning. Urgent generator top-ups, cancellations and traffic all arrive during the day. We use incremental insertion: for each urgent order, evaluate the cost of inserting it into each active route, respecting remaining compartment volume, windows and hours, and propose the cheapest option.

function bestInsertion(order: Stop, routes: ActiveRoute[]) {
  return routes
    .flatMap(r => candidatePositions(r, order))
    .filter(isFeasible)
    .sort((a, b) => a.deltaCost - b.deltaCost)[0];
}

The dispatcher approves the suggestion. With agentic workflows, the system can then update ETAs and notify affected customers automatically.

Where AI improves routing

Two AI inputs make routing noticeably better. Demand forecasts predict when tanks will need filling, so recurring orders can be scheduled to create dense clusters rather than scattered one-offs. Learned service-time estimates replace fixed guesses with realistic durations per site and driver. Both come from historical dispense and GPS data, which is why capturing that data cleanly from day one matters.

Build or buy the solver?

Open-source solvers and commercial routing APIs handle much of CVRPTW well. We usually wrap one behind our own routing service and add the fuel-specific constraints and objective on top, which keeps the option to switch later. More on our approach to building these platforms in our mobile app development work.

Measuring route quality

You cannot improve routing without measuring it. We log every plan alongside what actually happened, then compare planned versus actual service time per stop, planned versus actual drive time, volume dispensed per route hour, and the share of urgent orders absorbed without breaking committed windows. Those comparisons show which constraints are wrong (often service times at specific sites) and feed the learned estimates mentioned above.

A simple weekly report of the ten worst-performing routes, with their main deviation, usually surfaces more improvement than any solver tuning.

Data you need from day one

Even if routing starts simple, log the inputs that future optimisation will need: actual arrival and departure times per stop, actual volumes per product, reasons for failed or partial deliveries, and the reason codes dispatchers choose when they override a plan. That dataset is what turns a generic solver into one tuned for your operation.

Keep the solver swappable

Wrap whichever solver you choose behind a narrow interface that accepts a snapshot and returns a plan with per-stop ETAs and reasons. That lets you benchmark alternatives on recorded days without touching the rest of the platform.

Frequently Asked Questions

What type of routing problem is fuel delivery?

A capacitated vehicle routing problem with time windows, extended with product compartments, reloads, access rules and driver hours.

How do you plan fill-to-full orders with unknown volume?

Estimate volume from asset capacity and consumption history, add a safety margin, and correct after the meter reports.

Should urgent orders trigger a full re-plan?

Usually not. Incremental insertion into existing routes is faster and less disruptive, with dispatcher approval.

What metric should fuel delivery routing optimise?

Volume dispensed per route hour, balanced against drive time, window violations and overtime.

Can AI improve fuel delivery routes?

Yes. Demand forecasts create denser scheduled routes and learned service times make plans more realistic.

Subscribe to techcirkle