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.