AgentStack
SKILL verified MIT Self-run

Fuel Distribution

skill-kishorkukreja-awesome-supply-chain-fuel-distribution · by kishorkukreja

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 e…

No reviews yet
0 installs
6 views
0.0% view→install

Install

$ agentstack add skill-kishorkukreja-awesome-supply-chain-fuel-distribution

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Fuel Distribution? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

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:

  1. Network Structure
  • How many retail locations? (gas stations, fleet facilities)
  • Terminal locations and capacities?
  • Geographic coverage area?
  • Branded vs. unbranded stations?
  1. Demand Characteristics
  • Daily sales volumes by location?
  • Seasonal patterns? (summer driving, holidays)
  • Product mix? (regular, midgrade, premium, diesel)
  • Demand variability and trends?
  1. Delivery Operations
  • Fleet size and tank truck capacities?
  • Delivery hours and restrictions?
  • Compartmented trucks (multi-product)?
  • Driver availability and regulations?
  1. 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  # list of {product, capacity_gallons, current_level}
        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

        # Get historical sales for this product
        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)

        # Safety stock calculation
        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 capacity constraint
        tank = next((t for t in self.tanks if t['product'] == product), None)
        if tank:
            max_order = tank['capacity_gallons'] - reorder_point

            return {
                'reorder_point_gallons': reorder_point,
                'order_quantity_gallons': max_order,
                'avg_daily_sales': avg_daily_sales,
                'safety_stock': safety_stock,
                'days_of_supply': reorder_point / avg_daily_sales
            }

    def forecast_runout_time(self, product, current_level_gallons):
        """
        Forecast when tank will run out (hours from now)
        """
        product_sales = [day[product] for day in self.forecast
                        if product in day]

        avg_hourly_sales = np.mean(product_sales) / 24

        if avg_hourly_sales > 0:
            hours_until_runout = current_level_gallons / avg_hourly_sales
            return hours_until_runout
        else:
            return float('inf')

    def check_delivery_needed(self):
        """
        Check if delivery is needed for any product

        Returns list of products needing delivery
        """
        delivery_needed = []

        for tank in self.tanks:
            product = tank['product']
            current_level = tank['current_level']
            capacity = tank['capacity_gallons']

            reorder_params = self.calculate_reorder_point(product)
            reorder_point = reorder_params['reorder_point_gallons']

            if current_level = required

    # Truck compartment capacity
    for t, truck in enumerate(trucks):
        for product in ['Regular', 'Premium', 'Diesel']:
            # Sum of deliveries ≤ compartment capacity for that product
            comp_capacity = truck['compartments'].get(product, 0)
            prob += lpSum([y[t, s, product] for s in range(len(stations))])  0, truck must visit
            visits = lpSum([x[t, i, s+1] for i in range(len(stations) + 1) if i != s+1])

            prob += total_delivery  0.5:
                        if j != 0:  # Not terminal
                            route.append(j)
                        current = j
                        break

        if len(route) > 1:
            route.append(0)  # Return to terminal
            routes.append({
                'truck': truck['id'],
                'route': route,
                'stations_visited': len(route) - 2,
                'deliveries': {
                    (s, p): y[t, s, p].varValue
                    for s in range(len(stations))
                    for p in ['Regular', 'Premium', 'Diesel']
                    if (t, s, p) in y and y[t, s, p].varValue > 10
                }
            })

    return {
        'status': LpStatus[prob.status],
        'total_distance': value(prob.objective),
        'routes': routes
    }

def calculate_distance(loc1, loc2):
    """Calculate distance between two locations (miles)"""
    import numpy as np
    return np.sqrt((loc1[0] - loc2[0])**2 + (loc1[1] - loc2[1])**2) * 69

# Example usage
stations = [
    {
        'id': 'Station_A',
        'location': (30.0, -95.0),
        'delivery_needs': {'Regular': 4000, 'Premium': 0, 'Diesel': 2000}
    },
    {
        'id': 'Station_B',
        'location': (30.1, -95.1),
        'delivery_needs': {'Regular': 3000, 'Premium': 1000, 'Diesel': 0}
    },
    {
        'id': 'Station_C',
        'location': (30.05, -95.15),
        'delivery_needs': {'Regular': 5000, 'Premium': 0, 'Diesel': 3000}
    },
]

terminal = (30.0, -95.2)

trucks = [
    {
        'id': 'Truck_1',
        'compartments': {'Regular': 5000, 'Premium': 2000, 'Diesel': 3000},
        'total_capacity': 10000
    },
    {
        'id': 'Truck_2',
        'compartments': {'Regular': 6000, 'Premium': 1000, 'Diesel': 4000},
        'total_capacity': 11000
    },
]

result = optimize_fuel_delivery_routes(stations, terminal, trucks, {})
print(f"Total distance: {result['total_distance']:.1f} miles")
for route in result['routes']:
    print(f"Truck {route['truck']}: {route['stations_visited']} stations")

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)

    # Variables: assign delivery d to bay b in time slot t
    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')

    # Objective: minimize waiting time and tardiness
    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):
                # Penalty for deviation from desired time
                delay = max(0, t - desired_slot)
                waiting_penalty.append(delay * x[d, b, t])

    prob += lpSum(waiting_penalty)

    # Constraints

    # Each delivery assigned exactly once
    for d in range(n_deliveries):
        prob += lpSum([x[d, b, t]
                      for b in range(n_bays)
                      for t in range(n_slots)]) == 1

    # Bay can handle one truck per time slot
    for b in range(n_bays):
        for t in range(n_slots):
            prob += lpSum([x[d, b, t] for d in range(n_deliveries)])  0.5:
                    schedule.append({
                        'delivery': scheduled_deliveries[d]['id'],
                        'truck': scheduled_deliveries[d]['truck'],
                        'bay': b + 1,
                        'time_slot': t,
                        'load_duration': scheduled_deliveries[d]['loading_duration_slots']
                    })

    return {
        'status': LpStatus[prob.status],
        'total_waiting': value(prob.objective),
        'schedule': pd.DataFrame(schedule).sort_values('time_slot')
    }

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

    # Prepare features
    df = historical_sales.copy()

    # Time-based features
    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)

    # Lag features (previous sales)
    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()

    # Weather features
    df = df.merge(weather_data, on='date', how='left')

    # Special events
    df = df.merge(events_calendar, on='date', how='left')
    df['is_holiday'] = df['is_holiday'].fillna(0)

    # Drop rows with NaN from lag features
    df = df.dropna()

    # Features for model
    feature_cols = ['day_of_week', 'day_of_month', 'month', 'is_weekend',
                   'sales_lag_1', 'sales_lag_7', 'sales_rolling_7',
                   'temperature', 'precipitation', 'is_holiday']

    X = df[feature_cols]
    y = df['sales_gallons']

    # Scale features
    scaler = StandardScaler()
    X_scaled = scaler.fit_transform(X)

    # Train model
    model = GradientBoostingRegressor(
        n_estimators=100,
        learning_rate=0.1,
        max_depth=5,
        random_state=42
    )
    model.fit(X_scaled, y)

    # Feature importance
    importance = pd.DataFrame({
        'feature': feature_cols,
        'importance': model.feature_importances_
    }).sort_values('importance', ascending=False)

    return {
        'model': model,
        'scaler': scaler,
        'feature_importance': importance,
        'train_r2': model.score(X_scaled, y)
    }

def predict_next_week_sales(model, scaler, current_data, weather_forecast):
    """Predict sales for next 7 days"""

    predictions = []

    for day in range(7):
        # Prepare features for prediction day
        # This would use latest sales data and weather forecast
        # Simplified for illustration
        pass

    return 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']

    # Variables: price for each product at each station
    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,  # Min margin
                upBound=competitor_prices[product]['max'] + 0.20
            )

            volume[s, product] = LpVariable(
                f"Volume_{s}_{product}",
                lowBound=0
            )

    # Objective: maximize total profit
    profit = []

    for s, station in enumerate(stations):
        for product in products:
            # Profit = (Price - Cost) × Volume
            cost = cost_data[product]['wholesale_cost'] + \
                   cost_data[product]['operating_cost']

            profit.append((price[s, product] - cost) * volume[s, product])

    prob += lpSum(profit)

    # Constraints

    # Demand model: volume as function of price
    for s, station in enumerate(stations):
        for product in products:
            base_volume = station['base_volume'][product]
            base_price = station['base_price'][product]

            # Linear demand: V = V0 * (1 + elasticity * (P - P0) / P0)
            # Approximation for LP
            avg_comp_price = competitor_prices[product]['average']

            # Volume decreases if price above competitors
            prob += volume[s, product] = min_comp - 0.05  # Max 5 cents below minimum

    # Solve
    prob.solve(PULP_CBC_CMD(msg=0))

    # Extract optimal prices
    optimal_prices = {}
    for s, station in enumerate(stations):
        optimal_prices[station['id']] = {
            product: {
                'price': price[s, product].varValue,
                'volume': volume[s, product].varValue
            }
            for product in products
        }

    return {
        'status': LpStatus[prob.status],
        'max_profit': value(prob.objective),
        'optimal_prices': 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 Eff

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.