
Written by:
Editorial Team
DSG.AI
Demurrage Prediction: The AI Project That Pays for Itself in One Quarter
Detention and demurrage (D&D) charges represent one of the highest-margin, lowest-visibility cost lines in container shipping. Industry estimates place global D&D losses in the tens of billions of dollars annually. For a major carrier, a single high-congestion quarter can generate D&D accruals that dwarf the cost of building a production prediction system. The return is not measured in months; at a tier-1 global container carrier, we measured it in weeks.
This is a production account, not a feasibility study. The architecture described here runs in production for a top-10 global container company. Where academic demurrage papers predict vessel-level D&D from port-call timing in AIS data, production prediction requires something different: container-level intervention 72-96 hours before the terminal gate-in window.
What Demurrage Actually Costs (and Why It Is Hard to Predict)
Demurrage accrues when a container sits at a terminal beyond its free time. Detention accrues when the container is away from the terminal (in transit, at a warehouse) beyond its free time. Both are contractually specified by lane and shipper, and both are widely underestimated because they are tracked reactively: the charge appears on the invoice, the shipper disputes it, and the carrier spends operational hours resolving disputes that a prediction system would have prevented.
The data problem is structural. Demurrage involves four distinct data environments that rarely integrate cleanly:
- Carrier systems (booking, B/L, free time terms per shipper/lane)
- Terminal operating systems (actual gate-in, gate-out, vessel discharge timestamps)
- Customs and regulatory data (release status, inspection holds, document clearance velocity)
- Shipper behavior data (historical free time utilization by shipper, lane, commodity)
Most academic papers on demurrage prediction use AIS timestamps and vessel-level port call data to estimate aggregate D&D exposure per vessel per call. This is the wrong unit of analysis for intervention. By the time you know a vessel is sitting at berth with slow customs processing, the containers are already accruing charges. The intervention window has closed.
Production prediction solves a different problem: which specific containers, on which specific bookings, from which shippers, will exceed free time at which terminals, and how much advance notice is needed to intervene?
The Feature Set That Predicts at Container Level
After building and iterating this model in production, the features that carry the highest predictive signal are not the ones that show up in academic literature.
High-signal features (production-validated):
| Feature | Why it matters |
|---|---|
| Shipper free-time utilization history | Repeat behavior is the strongest single predictor. Shippers who routinely exceed free time at a given port do so again. |
| Commodity type + HS code | Perishables, hazmat, and certain raw materials face longer customs dwell requirements. |
| Origin-destination lane customs velocity | Average days from discharge to customs release, by lane. This is port-and-lane-specific, not just port-level. |
| Terminal dwell distribution by port/terminal | P75 and P90 dwell times by terminal, updated weekly, not annually. |
| Free time contract terms per booking | Different shippers have different free time negotiated in their MSAs. The model ingests contract terms, not defaults. |
| Port congestion indicators | Vessel queue length and berth productivity at destination port at time of predicted arrival. |
| Booking lead time | Short lead-time bookings correlate with document preparation gaps and customs delays. |
Low-signal features that academic papers weight heavily:
- Vessel-level AIS data (informative for vessel delay, not container-level customs outcomes)
- General port volume statistics (too aggregated to drive container-level predictions)
- Weather data (correlation is real but marginal after including congestion indicators)
The Production Architecture
The system runs as a scheduled batch prediction, updated daily per vessel ETA for the next 14 days. The output is a per-container D&D risk score with a predicted charge amount and an estimated days-over-free-time distribution.
Data ingestion layer:
- Carrier TMS and booking system (free time terms, shipper history, commodity)
- Terminal operating system (TOS) API (discharge timestamps, gate activity, yard positions)
- Customs authority feeds where available; proprietary clearance velocity models where direct APIs are absent
- Internal shipper performance database (built from 36 months of historical D&D actuals)
Model layer:
- Classification model: will this container exceed free time? (gradient boosting, calibrated probability output)
- Regression model: if yes, by how many days and what is the expected charge? (separate model per D&D fee schedule tier)
- Confidence intervals by lane and shipper history depth: the system flags predictions with thin history as lower-confidence, routing them to manual review rather than automated action
Action layer: The prediction output feeds an automated intervention workflow:
- High-confidence, high-risk containers: automatic customer notification with customs document checklist + link to pre-clearance vendor network
- Medium-risk containers: operations team queue for manual outreach
- Systematic shipper patterns: flagged for commercial team to renegotiate free time terms in next contract cycle
This last step, systematic pattern flagging, compounds over time. The model identifies shippers whose behavior is structurally at odds with the free time terms in their MSAs, enabling commercial renegotiation before the next cycle of D&D accrues.
What Production Delivered
At a tier-1 global container carrier, deploying this system across production operations delivered verified savings in the millions of dollars per year. The exact figure is confidential, but the mechanism is straightforward: early intervention converts containers that would have exceeded free time into containers that clear within it. At a carrier processing tens of thousands of container moves per month, a 15-20% reduction in D&D events compounds quickly.
The planning horizon for intervention extended from reactive (post-charge dispute) to 72-96 hours before gate-in. This window is sufficient to complete customs pre-clearance for most commodities, contact the shipper's customs broker, and pre-position chassis if yard logistics are the bottleneck.
For the companion challenge of predicting vessel arrival times precisely enough to compress the planning window upstream, see Vessel ETA Prediction in Production: What the Academic Papers Don't Tell You. ETA prediction feeds D&D prediction: the better the ETA, the longer the intervention window.
The Gap Between Academic Papers and Production Deployment
The published literature on demurrage and detention prediction consistently describes the same class of model: logistic regression or random forest on port-call level features derived from AIS, with synthetic D&D outcomes estimated from port dwell distributions.
Three things academic papers miss:
The shipper behavior signal. Carrier data contains years of actual D&D outcomes by shipper, commodity, and lane. This is the highest-value feature set. It is also proprietary and unavailable to academic researchers. Papers that model without it are systematically underestimating the achievable accuracy on carrier-operated data.
The customs API integration problem. Customs clearance velocity drives D&D outcomes more than vessel-level factors in most origin-destination pairs. Integrating with customs APIs (or building velocity models from historical clearance data) is a significant engineering task that papers ignore entirely.
The intervention design. Prediction without an action layer does not reduce D&D. The operational workflow (who gets notified, what action they take, how that action is tracked back to the prediction) determines whether prediction converts to savings. This design work takes as long as the modeling.
The ROI Case for Demurrage Prediction
D&D prediction has one of the clearest ROI profiles of any AI project in maritime operations. The savings are direct and measurable: D&D charges before vs. after deployment, controlling for volume. There is no attribution ambiguity about whether the AI or something else caused the reduction.
For a carrier or shipping line evaluating where to invest AI development budget, D&D prediction typically meets the payback-in-one-quarter threshold that most commercial teams require for a production AI greenlight. The data is already in your systems. The intervention workflow is already in your operations team's job description. The model connects existing data to an existing workflow in a way that produces a directly measurable cost reduction.
DSG has built 15+ agentic workflows in production for a single tier-1 container enterprise, D&D prediction among them. The starting point is a data availability assessment: what TOS access exists, what customs feed options are available, and what shipper behavioral history is in the carrier system. If you are evaluating D&D prediction for your operations, see the maritime AI services overview at /maritime for how we approach production deployment.
For the broader context on what AI in container shipping actually delivers in production vs. what is still on slides, see Maritime AI vs. PowerPoint AI: What's Actually in Production in 2026.


