| name | fuel-distribution |
| description | When the user wants to optimize retail fuel distribution, manage gasoline and diesel delivery, or plan petroleum product logistics. Also use when the user mentions "gas station supply," "fuel delivery routing," "petroleum retail," "tank truck scheduling," "fuel terminal operations," "wholesale fuel distribution," or "retail fuel network." For upstream, see drilling-logistics. For midstream, see energy-logistics. |
Fuel Distribution
You are an expert in retail fuel distribution and petroleum product logistics. Your goal is to help optimize the distribution of gasoline, diesel, and other petroleum products from terminals to retail stations, managing delivery scheduling, inventory levels, and transportation efficiency while ensuring no stockouts.
Initial Assessment
Before optimizing fuel distribution, understand:
-
Network Structure
- How many retail locations? (gas stations, fleet facilities)
- Terminal locations and capacities?
- Geographic coverage area?
- Branded vs. unbranded stations?
-
Demand Characteristics
- Daily sales volumes by location?
- Seasonal patterns? (summer driving, holidays)
- Product mix? (regular, midgrade, premium, diesel)
- Demand variability and trends?
-
Delivery Operations
- Fleet size and tank truck capacities?
- Delivery hours and restrictions?
- Compartmented trucks (multi-product)?
- Driver availability and regulations?
-
Objectives & Constraints
- Primary goals? (minimize cost, prevent stockouts, improve service)
- Budget constraints?
- Service level requirements? (fill frequency, emergency deliveries)
- Environmental and safety regulations?
Fuel Distribution Framework
Supply Chain Structure
Upstream (Supply):
- Refineries
- Pipeline terminals
- Marine import terminals
- Bulk storage facilities
Distribution (Logistics):
- Primary terminals (bulk receiving)
- Secondary terminals (local distribution)
- Tank truck fleet
- Delivery scheduling and routing
Downstream (Retail):
- Gas stations (C-stores)
- Fleet fueling facilities
- Cardlock locations
- Commercial accounts
Retail Station Inventory Management
Tank Inventory Optimization
import numpy as np
import pandas as pd
from datetime import datetime, timedelta
class FuelStationInventory:
"""
Manage inventory for retail fuel station with multiple tanks
"""
def __init__(self, station_id, tanks, daily_sales_forecast):
self.station_id = station_id
self.tanks = tanks
self.forecast = daily_sales_forecast
def calculate_reorder_point(self, product, lead_time_days=1,
service_level=0.95):
"""
Calculate reorder point for fuel tank
Reorder Point = (Avg Daily Sales × Lead Time) + Safety Stock
"""
from scipy.stats import norm
product_sales = [day[product] for day in self.forecast
if product in day]
avg_daily_sales = np.mean(product_sales)
std_daily_sales = np.std(product_sales)
z_score = norm.ppf(service_level)
safety_stock = z_score * std_daily_sales * np.sqrt(lead_time_days)
reorder_point = (avg_daily_sales * lead_time_days) + safety_stock
tank = next((t for t in self.tanks if t['product'] == product), )
tank:
max_order = tank[] - reorder_point
{
: reorder_point,
: max_order,
: avg_daily_sales,
: safety_stock,
: reorder_point / avg_daily_sales
}
():
product_sales = [day[product] day .forecast
product day]
avg_hourly_sales = np.mean(product_sales) /
avg_hourly_sales > :
hours_until_runout = current_level_gallons / avg_hourly_sales
hours_until_runout
:
()
():
delivery_needed = []
tank .tanks:
product = tank[]
current_level = tank[]
capacity = tank[]
reorder_params = .calculate_reorder_point(product)
reorder_point = reorder_params[]
current_level <= reorder_point:
hours_to_runout = .forecast_runout_time(product, current_level)
delivery_needed.append({
: .station_id,
: product,
: current_level,
: capacity,
: capacity * ,
: (capacity * ) - current_level,
: hours_to_runout,
: hours_to_runout <
})
delivery_needed
tanks = [
{: , : , : },
{: , : , : },
{: , : , : },
]
forecast = [
{: , : , : },
{: , : , : },
]
station = FuelStationInventory(, tanks, forecast)
deliveries = station.check_delivery_needed()
delivery deliveries:
(
)
Delivery Routing & Scheduling
Multi-Compartment Tank Truck Routing
def optimize_fuel_delivery_routes(stations, terminal_location, trucks,
time_windows):
"""
Optimize fuel delivery routes for multi-compartment tank trucks
Vehicle Routing Problem with:
- Time windows
- Multiple products
- Compartment constraints
- Split deliveries allowed
Parameters:
- stations: list of stations with delivery requirements
- terminal_location: depot coordinates
- trucks: list of available trucks with compartment configurations
- time_windows: delivery time windows by station
"""
from pulp import *
import numpy as np
prob = LpProblem("Fuel_Delivery_Routing", LpMinimize)
x = {}
for t, truck in enumerate(trucks):
for i in range(len(stations) + 1):
for j in range(len(stations) + 1):
if i != j:
x[t, i, j] = LpVariable(f"x_{t}_{i}_{j}", cat='Binary')
y = {}
for t, truck in enumerate(trucks):
for s, station in enumerate(stations):
for product in ['Regular', , ]:
y[t, s, product] = LpVariable(,
lowBound=)
arrival_time = {}
t, truck (trucks):
s ((stations)):
arrival_time[t, s] = LpVariable(,
lowBound=)
total_distance = []
t, truck (trucks):
i ((stations) + ):
j ((stations) + ):
i != j:
loc_i = terminal_location i == stations[i-][]
loc_j = terminal_location j == stations[j-][]
distance = calculate_distance(loc_i, loc_j)
total_distance.append(distance * x[t, i, j])
prob += lpSum(total_distance)
s, station (stations):
product station[]:
required = station[][product]
prob += lpSum([y[t, s, product] t ((trucks))]) >= required
t, truck (trucks):
product [, , ]:
comp_capacity = truck[].get(product, )
prob += lpSum([y[t, s, product] s ((stations))]) <= \
comp_capacity
t, truck (trucks):
s, station (stations):
total_delivery = lpSum([y[t, s, p] p [, , ]])
visits = lpSum([x[t, i, s+] i ((stations) + ) i != s+])
prob += total_delivery <= truck[] * visits
t, truck (trucks):
j (, (stations) + ):
inflow = lpSum([x[t, i, j] i ((stations) + ) i != j])
outflow = lpSum([x[t, j, i] i ((stations) + ) i != j])
prob += inflow == outflow
t, truck (trucks):
prob += lpSum([x[t, , j] j (, (stations) + )]) ==
prob += lpSum([x[t, i, ] i (, (stations) + )]) ==
solver = PULP_CBC_CMD(msg=, timeLimit=)
prob.solve(solver)
routes = []
t, truck (trucks):
route = []
current =
_ ((stations)):
j ((stations) + ):
j != current (t, current, j) x:
x[t, current, j].varValue > :
j != :
route.append(j)
current = j
(route) > :
route.append()
routes.append({
: truck[],
: route,
: (route) - ,
: {
(s, p): y[t, s, p].varValue
s ((stations))
p [, , ]
(t, s, p) y y[t, s, p].varValue >
}
})
{
: LpStatus[prob.status],
: value(prob.objective),
: routes
}
():
numpy np
np.sqrt((loc1[] - loc2[])** + (loc1[] - loc2[])**) *
stations = [
{
: ,
: (, -),
: {: , : , : }
},
{
: ,
: (, -),
: {: , : , : }
},
{
: ,
: (, -),
: {: , : , : }
},
]
terminal = (, -)
trucks = [
{
: ,
: {: , : , : },
:
},
{
: ,
: {: , : , : },
:
},
]
result = optimize_fuel_delivery_routes(stations, terminal, trucks, {})
()
route result[]:
()
Terminal Operations Optimization
Terminal Loading Dock Scheduling
def optimize_terminal_loading(scheduled_deliveries, loading_bays, time_slots):
"""
Optimize assignment of trucks to loading bays and time slots
Parameters:
- scheduled_deliveries: list of planned deliveries with truck arrival times
- loading_bays: number of available loading bays
- time_slots: list of available time slots (e.g., hourly)
"""
from pulp import *
prob = LpProblem("Terminal_Loading", LpMinimize)
n_deliveries = len(scheduled_deliveries)
n_bays = loading_bays
n_slots = len(time_slots)
x = {}
for d in range(n_deliveries):
for b in range(n_bays):
for t in range(n_slots):
x[d, b, t] = LpVariable(f"x_{d}_{b}_{t}", cat='Binary')
waiting_penalty = []
for d, delivery in enumerate(scheduled_deliveries):
desired_slot = delivery['desired_time_slot']
for b in range(n_bays):
for t in range(n_slots):
delay = max(0, t - desired_slot)
waiting_penalty.append(delay * x[d, b, t])
prob += lpSum(waiting_penalty)
d (n_deliveries):
prob += lpSum([x[d, b, t]
b (n_bays)
t (n_slots)]) ==
b (n_bays):
t (n_slots):
prob += lpSum([x[d, b, t] d (n_deliveries)]) <=
d, delivery (scheduled_deliveries):
earliest_slot = delivery[]
b (n_bays):
t (earliest_slot):
prob += x[d, b, t] ==
d, delivery (scheduled_deliveries):
load_duration = delivery[]
b (n_bays):
t (n_slots):
x[d, b, t] prob.variables():
dt (, load_duration):
t + dt < n_slots:
prob += lpSum([x[d2, b, t+dt]
d2 (n_deliveries)
d2 != d]) <= \
- x[d, b, t]
prob.solve(PULP_CBC_CMD(msg=))
schedule = []
d (n_deliveries):
b (n_bays):
t (n_slots):
x[d, b, t].varValue > :
schedule.append({
: scheduled_deliveries[d][],
: scheduled_deliveries[d][],
: b + ,
: t,
: scheduled_deliveries[d][]
})
{
: LpStatus[prob.status],
: value(prob.objective),
: pd.DataFrame(schedule).sort_values()
}
Demand Forecasting for Fuel
Fuel Sales Forecasting
def forecast_fuel_sales(historical_sales, weather_data, events_calendar):
"""
Forecast fuel sales considering multiple factors
Factors:
- Day of week
- Seasonality
- Weather (temperature affects driving)
- Special events
- Trends
"""
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.preprocessing import StandardScaler
import pandas as pd
df = historical_sales.copy()
df['day_of_week'] = df['date'].dt.dayofweek
df['day_of_month'] = df['date'].dt.day
df['month'] = df['date'].dt.month
df['is_weekend'] = (df['day_of_week'] >= 5).astype(int)
df['sales_lag_1'] = df['sales_gallons'].shift(1)
df['sales_lag_7'] = df['sales_gallons'].shift(7)
df['sales_rolling_7'] = df['sales_gallons'].rolling(7).mean()
df = df.merge(weather_data, on='date', how='left')
df = df.merge(events_calendar, on='date', how='left')
df['is_holiday'] = df['is_holiday'].fillna(0)
df = df.dropna()
feature_cols = [, , , ,
, , ,
, , ]
X = df[feature_cols]
y = df[]
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
model = GradientBoostingRegressor(
n_estimators=,
learning_rate=,
max_depth=,
random_state=
)
model.fit(X_scaled, y)
importance = pd.DataFrame({
: feature_cols,
: model.feature_importances_
}).sort_values(, ascending=)
{
: model,
: scaler,
: importance,
: model.score(X_scaled, y)
}
():
predictions = []
day ():
predictions
Fuel Price Optimization
Dynamic Pricing Strategy
def optimize_fuel_pricing(station_data, competitor_prices, cost_data,
demand_elasticity=-0.5):
"""
Optimize fuel pricing to maximize margin while remaining competitive
Parameters:
- station_data: station characteristics and historical data
- competitor_prices: current prices at nearby competitors
- cost_data: wholesale cost and other costs
- demand_elasticity: price elasticity of demand
"""
from pulp import *
prob = LpProblem("Fuel_Pricing", LpMaximize)
stations = station_data
products = ['Regular', 'Premium', 'Diesel']
price = {}
volume = {}
for s, station in enumerate(stations):
for product in products:
price[s, product] = LpVariable(
f"Price_{s}_{product}",
lowBound=cost_data[product]['wholesale_cost'] + 0.10,
upBound=competitor_prices[product]['max'] + 0.20
)
volume[s, product] = LpVariable(
f"Volume_{s}_{product}",
lowBound=0
)
profit = []
for s, station in enumerate(stations):
for product in products:
cost = cost_data[product]['wholesale_cost'] + \
cost_data[product][]
profit.append((price[s, product] - cost) * volume[s, product])
prob += lpSum(profit)
s, station (stations):
product products:
base_volume = station[][product]
base_price = station[][product]
avg_comp_price = competitor_prices[product][]
prob += volume[s, product] <= base_volume * \
( + demand_elasticity * (price[s, product] - avg_comp_price) / avg_comp_price)
s, station (stations):
product products:
avg_comp = competitor_prices[product][]
min_comp = competitor_prices[product][]
prob += price[s, product] <= avg_comp +
prob += price[s, product] >= min_comp -
prob.solve(PULP_CBC_CMD(msg=))
optimal_prices = {}
s, station (stations):
optimal_prices[station[]] = {
product: {
: price[s, product].varValue,
: volume[s, product].varValue
}
product products
}
{
: LpStatus[prob.status],
: value(prob.objective),
: optimal_prices
}
Tools & Libraries
Python Libraries
Optimization:
PuLP: Linear programming
OR-Tools: Vehicle routing
Pyomo: Optimization modeling
Forecasting:
scikit-learn: Machine learning
prophet: Time series forecasting
statsmodels: Statistical models
Geospatial:
geopy: Distance calculations
folium: Mapping
geopandas: Geographic data
Commercial Software
Fuel Distribution:
- Omnitracs: Fleet management and routing
- Verizon Connect: GPS fleet tracking
- Descartes: Route optimization
- TMW Systems: Transportation management
Terminal Management:
- AspenTech: Fuel scheduling and optimization
- Honeywell Experion: Process control
- Emerson DeltaV: Terminal automation
Retail Management:
- Veeder-Root: Tank monitoring systems
- PDI: Fuel pricing and wholesale management
- Gilbarco: Fuel dispensing and management
- Dover Fueling Solutions: Retail automation
Common Challenges & Solutions
Challenge: Stockout Prevention
Problem:
- Unpredictable demand spikes
- Delivery delays
- Inaccurate forecasting
Solutions:
- Real-time inventory monitoring (ATG systems)
- Safety stock optimization
- Predictive analytics for demand
- Emergency delivery protocols
- Automated reorder systems
Challenge: Delivery Efficiency
Problem:
- Rising fuel costs
- Driver shortages
- Traffic congestion
- Time windows
Solutions:
- Route optimization software
- Delivery consolidation
- Dynamic routing (real-time adjustments)
- Multi-product compartment trucks
- Night deliveries where allowed
Challenge: Product Contamination
Problem:
- Cross-contamination between products
- Quality issues
- Tank mixing errors
Solutions:
- Strict compartment procedures
- Product verification systems
- Tank cleaning protocols
- Quality testing (pre and post-delivery)
- Automated delivery systems
Challenge: Price Volatility
Problem:
- Rapid wholesale price changes
- Competitive pressure
- Margin compression
Solutions:
- Dynamic pricing systems
- Hedging strategies
- Wholesale supply contracts
- Price monitoring and automation
- Value-added services (C-store, car wash)
Output Format
Fuel Distribution Optimization Report
Executive Summary:
- Network overview (terminals, stations, trucks)
- Key optimization results
- Cost savings achieved
- Service level performance
Station Inventory Status:
| Station | Product | Current Level | Capacity | Days Supply | Reorder Point | Status |
|---|
| Station_A | Regular | 3,000 gal | 12,000 | 0.75 | 4,500 | URGENT |
| Station_A | Diesel | 6,000 gal | 10,000 | 3.0 | 3,000 | OK |
| Station_B | Regular | 8,000 gal | 15,000 | 2.0 | 5,000 | OK |
Delivery Schedule:
| Date | Truck | Route | Stations | Products | Total Gallons | Miles | Hours |
|---|
| 2026-02-01 | Truck_1 | Route_A | 4 | R, P, D | 9,500 | 85 | 6.5 |
| 2026-02-01 | Truck_2 | Route_B | 3 | R, D | 10,200 | 72 | 5.8 |
| 2026-02-02 | Truck_1 | Route_C | 5 | R, P, D | 10,800 | 95 | 7.2 |
Cost Analysis:
| Category | Daily Cost | Monthly Cost | Annual Cost |
|---|
| Fuel (diesel for trucks) | $2,500 | $75,000 | $900,000 |
| Driver wages | $3,200 | $96,000 | $1,152,000 |
| Truck maintenance | $800 | $24,000 | $288,000 |
| Insurance | $400 | $12,000 | $144,000 |
| Total Distribution Cost | $6,900 | $207,000 | $2,484,000 |
KPIs:
| Metric | Current | Target | Status |
|---|
| Stockout Rate | 0.2% | < 0.5% | ✓ Good |
| On-Time Delivery | 97% | > 95% | ✓ Good |
| Delivery Cost per Gallon | $0.025 | < $0.030 | ✓ Good |
| Truck Utilization | 88% | > 85% | ✓ Good |
| Avg Delivery Time | 5.5 hrs | < 6 hrs | ✓ Good |
Recommendations:
- Add one truck to fleet to handle peak summer demand
- Implement automated pricing system for 10% margin improvement
- Optimize Station_15 deliveries (currently underutilized route)
- Consider bulk fuel hedging for next quarter
Questions to Ask
If you need more context:
- How many retail locations do you serve?
- What's your tank truck fleet size and configuration?
- What products do you distribute? (gasoline grades, diesel, biofuels)
- What are current delivery frequencies and service levels?
- What's the primary challenge? (cost, stockouts, efficiency)
- What systems are in place? (TMS, tank monitoring, pricing)
- What's the competitive environment? (branded, independent)
Related Skills
- energy-logistics: For midstream petroleum logistics
- drilling-logistics: For upstream oil and gas operations
- route-optimization: For vehicle routing and scheduling
- inventory-optimization: For inventory management strategies
- demand-forecasting: For sales forecasting
- last-mile-delivery: For delivery operations
- fleet-management: For truck fleet management
- network-design: For terminal and station network planning