Fuel Stops

SALLY monitors fuel consumption across every segment of a route and automatically inserts fuel stops when the tank would drop below a safe threshold. Fuel stops are selected based on price, proximity to the route, and truck-friendliness.


How Fuel Insertion Works

During route planning, the fuel simulation runs alongside the HOS simulation:

  1. Track consumption — For each drive segment, calculate fuel used: distance_miles / vehicle_mpg
  2. Check threshold — If fuel would drop below 25% of tank capacity before reaching the next stop, a fuel stop is needed
  3. Find stations — Query for truck-friendly fuel stations within 10 miles of the route
  4. Select best station — Choose based on optimization priority (price or time)
  5. Insert segment — Add a fuel stop segment to the route plan

Fuel Stop Selection Criteria

CriterionPriorityDescription
Proximity to routeRequiredStation must be within 10 miles of the route path
Truck-friendlyHighPrefer stations with truck parking (Pilot, TA, Loves, Flying J)
Diesel priceMedium–HighSelect cheapest option among candidates (when priority is cost)
Detour timeMediumMinimize time lost leaving and rejoining the route
Operating hoursRequiredStation must be open at the estimated arrival time

Fuel Stop API (Internal)

POST /api/v1/fuel/find-stops

This endpoint is called internally by the route planner, not directly by clients.

Request

{
  "route_segment": {
    "from": { "latitude": 34.0522, "longitude": -118.2437 },
    "to": { "latitude": 36.7783, "longitude": -119.4179 },
    "distance_miles": 250
  },
  "vehicle": {
    "fuel_level_gallons": 50,
    "fuel_capacity_gallons": 200,
    "mpg": 6.0
  },
  "optimization_priority": "cost"
}

Response

{
  "fuel_stop_needed": true,
  "recommended_stop": {
    "station_name": "Pilot #4521",
    "brand": "Pilot",
    "latitude": 35.3733,
    "longitude": -119.0187,
    "diesel_price_per_gallon": 4.29,
    "distance_from_route_miles": 0.3,
    "detour_time_minutes": 5,
    "miles_into_segment": 150,
    "truck_friendly": true
  },
  "fill_recommendation": {
    "gallons_to_fill": 150,
    "estimated_cost": 643.50,
    "fuel_level_after": 200,
    "range_after_miles": 1200
  }
}

Fuel Segments in Route Plans

When a fuel stop is inserted, it appears as a segment in the route plan:

{
  "sequence": 4,
  "type": "fuel",
  "location": "Pilot Travel Center - Bakersfield",
  "station_name": "Pilot #4521",
  "fuel_price_per_gallon": 4.29,
  "gallons_to_fill": 65,
  "fuel_cost": 278.85,
  "duration_hours": 0.5,
  "fuel_state_after": {
    "fuel_level_gallons": 165,
    "range_remaining_miles": 990
  }
}

Key fields:

FieldDescription
station_nameName of the fuel station
fuel_price_per_gallonDiesel price at the station
gallons_to_fillHow many gallons will be added
fuel_costTotal cost for this fuel stop
duration_hoursEstimated time for the fuel stop (typically 0.5h)
fuel_state_afterFuel level and range after filling

Fuel Tracking Through the Route

The route plan tracks fuel state across every segment. Here’s an example of how fuel is consumed and replenished:

SegmentDistanceFuel UsedFuel RemainingRangeAction
Origin → Stop A100 mi17 gal83 gal498 mi
Stop A → Stop B250 mi42 gal41 gal246 mi
Stop B → (check)41 gal246 miFuel stop needed (next segment is 300 mi)
Stop B → Pilot #4521120 mi20 gal21 gal126 miFuel stop inserted
Pilot #4521 (fill)200 gal1200 miFilled to capacity
Pilot #4521 → Stop C180 mi30 gal170 gal1020 mi

Optimization Priorities

How the optimization_priority in the route plan request affects fuel stop selection:

PriorityFuel Stop Behavior
timeSelects the closest station to minimize detour time, even if price is slightly higher
costSelects the cheapest station among candidates, accepting a longer detour if savings are significant
balancedWeighs price and detour time equally

Configuration

Default fuel parameters (configured per vehicle):

ParameterDefaultDescription
Tank capacity200 gallonsTotal fuel tank capacity
MPG6.0Miles per gallon
Low fuel threshold25% of capacityWhen to trigger fuel stop insertion
Search radius10 milesMaximum distance from route to search for stations
Fill strategyFill to capacityAlways fills tank completely at fuel stops

Data Source

In the current POC, fuel prices come from a mock fuel price API:

GET /api/v1/external/fuel-prices?latitude=35.37&longitude=-119.02&radius_miles=10

This returns realistic mock data with artificial latency (100–150ms). Responses include a data_source: "Fuel Finder (Mock)" field to clearly indicate mock data.

In production (Phase 3), this will be replaced with live data from GasBuddy or a similar fuel price API.