An implementation of Multiple Ant Colony System for solving the Capacitated Vehicle Routing Problem (CVRP).
- Python 3.10+
- Dependencies:
- numpy
- matplotlib
- tqdm
- requests_toolbelt
# Clone the repository
git clone [https://github.com/Patatouxe/AI50_Project.git]
# Install dependencies
pip install numpy matplotlib tqdm requests_toolbelt
.
├── data/
│ └── tai/ # CVRP benchmark instances
├── src/
│ ├── ACO/
│ │ └── aco_colony.py # MACS-CVRP implementation
│ └── CVRP.py # CVRP problem definition
└── main.py # Main execution script
Run the main script to execute the CVRP whole system:
python main.py
The script will:
- Load a CVRP instance from the data directory
- Initialize the MACS-CVRP solver
- Run the optimization for 100 iterations
- Display the best solution found, including:
- Route assignments
- Total distance
- Number of vehicles used
We can find below a formal description for the CVRP:
-
Objective: The objective is to minimize the vehicle fleet and the sum of distance, and the total demand of commodities for each route may not exceed the capacity of the vehicle which serves that route.
-
Feasibility: A solution is feasible if the total quantity assigned to each route does not exceed the capacity of the vehicle which services the route.
-
Formulation: Let Q denote the capacity of a vehicle. Mathematically, a solution for the CVRP is the same that VRP's one, but with the additional restriction that the total demand of all customers supplied on a route
$R_{i}$ does not exceed the vehicle capacity$$Q: \sum_{i=1}^{m} q_{i} \leq Q$$
-
$n_{customer}$ : number of customers to be served n a unique depot -
$q_{i}$ : Quantity of goods demanded by the customer (i = 1, ..,n) -
$Q_{vehicle}$ : Capacity of vehicle available to deliver the good. Vehicle has to return to reload. -
$R_{i}$ : Route used by a vehicle to supply customer -
$d_{ij}$ : Distance from customer i to customer j
Our solution of CVRP will be represented by a collection(array) of tours on the routes where all customers are served, and the total tour demand is Q
Objectif function :
$$S_{x} = [[(R_{i}, T_{i}), \sum_{i=1} q_{i}]; [(R_{n}, T_{n}), \sum_{n=1} q_{n}]]
where Q = max(total q)$$
Graphical theoritical formulation,
For a graph G = (C, L),
we have
Each arc
The implementation uses Multiple Ant Colony System (MACS) with two colonies:
- ACS-VEI: Minimizes the number of vehicles
- ACS-DIST: Minimizes the total travel distance
Key parameters:
rho
: Global pheromone evaporation rate (default: 0.1)local_rho
: Local pheromone update rate (default: 0.1)
The project uses Taillard's CVRP benchmark instances. Solutions can be compared against:
- Rochat and Taillard, 1995
- Potvin and Bengio, 1996 (PB)
Add unit tests in a tests/
directory (to be implemented).
- Fork the repository
- Create a feature branch
- Commit changes
- Submit a pull request