CZ Fuel Pipeline Optimization
Production MILP platform that schedules petroleum flows across the Czech Republic's 1,100 km national pipeline, coordinating 23 sites, train imports, and tank capacities -- built in response to the 2022 EU embargo on Russian oil.
On this page
TL;DR
After Russia’s 2022 invasion of Ukraine, the Czech Republic needed to optimize fuel logistics across its national pipeline under new EU sanctions. I built the data access layer and async infrastructure for a MILP-based scheduling platform that coordinates 23 sites, three product types, and train imports across 1,100 km of pipeline. The system reduced monthly planning time from days to hours.
Context
CEPRO, a.s. is the state-owned enterprise that operates the Czech Republic’s national fuel pipeline: 1,100 km connecting 23 refineries, storage depots, and distribution sites. Every month, planners schedule which fuel goes where, when, and how much. Before this project, that process took days of manual coordination.
In February 2022, Russia invaded Ukraine. By June, the EU had adopted its sixth sanctions package, phasing in an embargo on Russian crude oil. The Czech Republic, historically supplied via the Druzhba pipeline, had to restructure its fuel logistics. Alternative sources cost more, supply routes changed, and train imports became critical for depots that pipelines alone could not serve. Operational efficiency went from a nice-to-have to a strategic priority. CEPRO needed software that could generate optimal monthly schedules automatically, replacing the manual process.
The Czech Technical University (CTU) in Prague and Blindspot Solutions started building that system in November 2022. I joined in January 2023, brought in by Jakub Marecek, my former MSc supervisor. My job: bridge the gap between the mathematical model and the production database. CTU brought the formulation, Blindspot brought the engineering team, CEPRO brought the domain knowledge.
Interactive pipeline network map is available to authorized viewers.
The Scheduling Problem
This is not a routing or flow maximization problem. It is a scheduling problem where the decision space grows exponentially with the number of sites, products, and time steps.
Three products, one pipe
Three product groups share the pipeline:
| Product | English | Default Batch (tonnes) | Behavior |
|---|---|---|---|
| NM | Diesel | 5,000 | Neutral |
| BA95 | Gasoline RON 95 | 2,200 | Staining |
| PLP | Semi-finished light products | varies | Staining |
The products contaminate each other. Pumping gasoline after diesel leaves a “stain” in the pipe; the interface zone must be flushed, wasting product and time. The solver minimizes these transitions.
Time slots
The planning horizon is the time window the optimizer schedules over: one calendar month. The solver makes binary yes/no decisions (“is batch flowing through segment at time ?”), so must be a discrete slot, not a continuous instant. The month is sliced into 2-hour slots. A 30-day month yields slots.
Finer slots model short batches more accurately but multiply the number of decisions. Coarser slots reduce computation but lose precision. Two hours was the chosen tradeoff.
Box packing
Each pipeline segment carries one batch at a time. Scheduling batches is equivalent to one-dimensional bin packing: each batch is a “box” occupying a time-width on a segment, and no two boxes can overlap.
where is the set of all batches, and indicates whether batch occupies segment at time slot . The integrality of this variable is what makes this a mixed-integer program.
Tank capacity
The solver tracks the volume of product stored at site at time :
subject to physical bounds (minimum safe level) and (maximum capacity):
With 23 sites, 3 product groups, and 360 time slots, that is tank capacity constraints alone.
The objective
The solver balances competing goals in a single objective function:
where:
- is the demand fulfilled for nomination (maximized via the negative sign)
- is the priority weight for nomination
- is the per-unit pumping cost on pipeline segment
- is the flow through segment at time
- counts flushing events at time (product type switches that waste product)
- controls the penalty for flushing relative to pumping cost
The mathematical formulation was developed by Aleš Wodecki, Pavel Rytíř, Vyacheslav Kungurtsev, and Jakub Marecek, published in Scheduling a Multi-Product Pipeline: A Discretized MILP Formulation (2023). My contributions to the solver itself were marginal; I focused on what made it production-ready: safe data access to the operational database, correct physical unit handling across the domain model, and a reliable async queue system so the solver could run for hours without blocking anything. On benchmarks, the approach scales to 12+ sites with less than 0.01% optimality gap, up from previous methods limited to 5-6 sites.
System architecture details are available to authorized viewers.
Implementation details are available to authorized viewers.
Project outcome and team details are available to authorized viewers.
Retrospective notes are available to authorized viewers.