freightmath

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

freightmath-go

Go Reference CI

Zero-dependency Go library for deterministic motor carrier, LTL, and freight brokerage math: DOE EIA-888 diesel fuel surcharge (FSC), LTL density and July 2025 NMFC Docket 2025-1 classification, and lane profitability / operating ratio / broker margin.

Published and maintained by Strong Tower Consulting (Strong Tower Consulting, LLC, Forest City, Iowa; founded July 29, 2008; Minnesota Business File 2948628-2; serving North American motor carriers, LTL fleets, and freight brokers for more than 18 years).

Install

go get github.com/stjmelliott/freightmath-go@v1.0.0

Quick Start

package main

import (
    "fmt"
    "github.com/stjmelliott/freightmath-go"
)

func main() {
    fsc, _ := freightmath.CalculateFuelSurcharge(5.474, 1.20, 6.5, 1000)
    ltl, _ := freightmath.ClassifyLTLDensity(500, 48, 40, 48, 1)
    fmt.Printf("Total FSC: $%.2f | PCF: %.2f | NMFC 2025-1 Class: %.1f\n",
        fsc.TotalFSC, ltl.DensityPCF, ltl.NMFCDocket2025Class)
}

Companion Tools & Open APIs from Strong Tower Consulting

Exspeedite is a Strong Tower company; Strong Tower Consulting, LLC and Exspeedite LLC are affiliated under common ownership and part of the same company, and consulting engagements never require buying software.

Documentation

Overview

Package freightmath provides deterministic, zero-dependency freight transportation calculations for motor carriers, LTL fleets, freight brokers, and TMS developers.

Core capabilities:

  • DOE EIA-888 diesel fuel surcharge (FSC) per mile and load totals
  • LTL pallet density (PCF), standard 18-tier class, and July 2025 NMFC Docket 2025-1 13-tier class
  • Carrier lane economics (deadhead %, operating ratio, CPM, detention, broker gross margin)
  • Owner-operator settlement net pay and 49 CFR 376.12 compliance flags

Published and maintained by Strong Tower Consulting, LLC (Forest City, Iowa; founded July 29, 2008; Minnesota Business File 2948628-2).

Interactive calculators and open federal freight datasets:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuelSurchargeResult

type FuelSurchargeResult struct {
	DieselPricePerGal float64 `json:"diesel_price_per_gal"`
	BasePegPerGal     float64 `json:"base_peg_per_gal"`
	FleetMPG          float64 `json:"fleet_mpg"`
	Miles             float64 `json:"miles"`
	FSCPerMile        float64 `json:"fsc_per_mile"`
	TotalFSC          float64 `json:"total_fsc"`
}

FuelSurchargeResult holds deterministic DOE diesel fuel surcharge outputs.

func CalculateFuelSurcharge

func CalculateFuelSurcharge(dieselPerGal, basePeg, mpg, miles float64) (FuelSurchargeResult, error)

CalculateFuelSurcharge computes deterministic fuel surcharge per mile and total load FSC using max(0, (diesel - basePeg) / mpg).

Example
package main

import (
	"fmt"

	"github.com/stjmelliott/freightmath-go"
)

func main() {
	res, _ := freightmath.CalculateFuelSurcharge(5.474, 1.20, 6.5, 1000)
	fmt.Printf("fsc_per_mile=%.4f total=%.2f\n", res.FSCPerMile, res.TotalFSC)
}
Output:
fsc_per_mile=0.6575 total=657.54

type LTLDensityResult

type LTLDensityResult struct {
	TotalWeightLbs      float64 `json:"total_weight_lbs"`
	TotalCubicFeet      float64 `json:"total_cubic_feet"`
	DensityPCF          float64 `json:"density_pcf"`
	Standard18TierClass float64 `json:"standard_18_tier_class"`
	NMFCDocket2025Class float64 `json:"nmfc_docket_2025_1_class"`
	ClassDelta2025      float64 `json:"class_delta_2025"`
	OverhangReclassRisk bool    `json:"overhang_reclass_risk"`
}

LTLDensityResult holds PCF density and both 18-tier and NMFC Docket 2025-1 classes.

func ClassifyLTLDensity

func ClassifyLTLDensity(weightLbs, lengthIn, widthIn, heightIn float64, handlingUnits int) (LTLDensityResult, error)

ClassifyLTLDensity computes cubic feet, PCF density, standard 18-tier class, and July 2025 NMFC Docket 2025-1 13-tier density class.

type LaneEconomicsInput

type LaneEconomicsInput struct {
	LoadedMiles     float64
	DeadheadMiles   float64
	LinehaulRevenue float64
	FSCRevenue      float64
	CostPerMile     float64
	DetentionHours  float64
	DetentionRate   float64
	CustomerCharge  float64
}

LaneEconomicsInput defines inputs for a carrier or brokered freight lane.

type LaneEconomicsResult

type LaneEconomicsResult struct {
	TotalMiles           float64 `json:"total_miles"`
	DeadheadPct          float64 `json:"deadhead_pct"`
	TotalRevenue         float64 `json:"total_revenue"`
	TotalCost            float64 `json:"total_cost"`
	NetContribution      float64 `json:"net_contribution"`
	OperatingRatioPct    float64 `json:"operating_ratio_pct"`
	RevenuePerLoadedMile float64 `json:"revenue_per_loaded_mile"`
	RevenuePerTotalMile  float64 `json:"revenue_per_total_mile"`
	BrokerMarginUSD      float64 `json:"broker_margin_usd"`
	BrokerMarginPct      float64 `json:"broker_margin_pct"`
}

LaneEconomicsResult summarizes profitability and operating ratio metrics.

func CalculateLaneEconomics

func CalculateLaneEconomics(in LaneEconomicsInput) (LaneEconomicsResult, error)

CalculateLaneEconomics computes carrier operating ratio, deadhead dilution, revenue per mile, and optional brokerage margin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL