A modular C implementation of the Vehicle Routing Problem (VRP). The project compares constructive heuristics, local search, iterated local search, and an exact solver for small instances. Every generated route is checked by an independent validation layer before it is reported.
- Naive sequential baseline
- Nearest Neighbor with 2-opt improvement
- Time-limited Iterated Local Search (ILS) with 2-opt
- Exact backtracking for small, single-vehicle inputs
The validator checks that:
- every route begins and ends at the depot;
- every client is visited exactly once;
- vehicle capacity limits are respected;
- the stored distance matches an independent recalculation.
Requires a C11-compatible compiler.
gcc -Wall -Wextra -std=c11 \
main.c input.c distance.c validation.c heuristic.c exact.c \
-o task3 -lmPlain mode prints the total distance followed by the vehicle routes:
./task3 --plain < input/in.txtDetailed mode compares the algorithms, execution times, validation results, and known reference gaps:
./task3 < input/in.txtclientCount vehicleCount maxClientsPerVehicle
client1_x client1_y
client2_x client2_y
...
clientN_x clientN_y
depot_x depot_y
The depot is represented as 0; clients are represented as 1..clientCount.
main.c: program flow and output modesinput.*: input parsingdistance.*: distance matrix and route calculationsvalidation.*: independent solution checksheuristic.*: baseline, Nearest Neighbor, 2-opt, and ILSexact.*: exact backtracking for small instancesinput/: sample and test inputsoutput/: example plain and detailed outputsdocs/: implementation notes and reference results
The reference values in docs/optimal_solutions.pdf are used only to report
the percentage gap; they do not influence route construction.