This repository contains four classical formulations for the Vehicle Routing Problem, along with Gurobi + Python (NetworkX) examples. Each formulation includes:
- Mathematical Models in LaTeX (ready to copy-paste).
- Python Code to demonstrate how to:
- Build and solve the MIP model in Gurobi.
- Plot resulting routes using NetworkX and Matplotlib.
- File:
VRP (MTZ Formulation).ipynb
- Description: Uses the Miller–Tucker–Zemlin (MTZ) constraints to eliminate subtours.
- Key Variables:
x[i,j]
(binary) indicating route arcs.u[i]
(continuous) for subtour elimination.
- Pros: Simpler to implement.
- Cons: Weaker LP bounds for large instances.
- File:
VRP Flow-Based Formulation.ipynb
- Description: Uses a single flow variable
f[i,j]
to ensure connectivity and capacity constraints. - Key Variables:
x[i,j]
(binary) for arcs,f[i,j]
(continuous) representing the flow on each arc.
- Pros: Stronger LP relaxation.
- Cons: Larger model (more variables).
- File:
VRP Set Partitioning Formulation.ipynb
- Description: Each variable
y_r
represents an entire feasible route. The model partitions the set of customers among a chosen subset of routes. - Key Variables:
y_r
(binary) indicates whether router
is used.
- Usage: Often used with branch-and-price or column generation, especially for large-scale VRPs.
- File:
VRP Multi-Commodity Flow Formulation.ipynb
- Description: One flow variable per commodity (often one commodity per customer) to model capacity in more granular detail.
- Key Variables:
x[i,j]
(binary),f[i,j,k]
(continuous) for commodity k on edge (i,j).
- Pros: Very flexible, can handle multiple demand types.
- Cons: Potentially huge model.
- Make sure you have Gurobi installed and licensed.
- Install networkx and matplotlib.
pip install networkx matplotlib
- G. B. Dantzig and J. H. Ramser. The truck dispatching problem. Management Science, 6(1): 80–91, 1959.
- P. Toth and D. Vigo. Vehicle Routing: Problems, Methods, and Applications, 2nd ed. SIAM, 2014.
- G. Laporte. Fifty Years of Vehicle Routing. Transportation Science, 43(4): 408–416, 2009.
- R. Baldacci, A. Mingozzi, and R. Roberti. Recent exact algorithms for solving the vehicle routing problem under capacity and time window constraints. EJOR, 218(1): 1–6, 2012.