This is the C++ implementation for the Trigger Arc TSP competition hosted by the Metaheuristics Summer School organizers.
In this technical report we detail the approach we took to solve the problem.
This implementation uses C++20.
instances/: Contains the instances for the competition. They are not pushed, but they can be downloaded from the competition website.solutions/: A file for each instance with the list of solutions found.src/: Contains the C++ source code.report/: Contains the LaTeX source code for the report.output/: Contains the outputs of the experiments.notebooks/: Contains the notebooks used to generate the figures for the report and for the dataset generation and exploration. To run them, you can use the python environment defined inpyproject.toml.benchmark/: Contains scripts to reproduce experimental results. The filecompetition_solutions.csvcontains the best solutions for each instance that we submitted to the competition.
This project requires:
- A C++ compiler that supports C++20 (e.g., GCC 10+, Clang 11+).
- CMake (version 3.10 to 3.27).
- Boost libraries.
- Gurobi solver.
The paths for Boost and Gurobi might need to be adjusted in src/CMakeLists.txt depending on your system.
The instances can be downloaded from the release page. They should be unzipped and placed in the instances/ directory at the root of the repository.
The cpp_src directory contains several useful scripts:
build.sh: Compiles the project. Run this from thecpp_srcdirectory.test.sh: Runs the tests. Run this from thecpp_srcdirectory after building the project.fmt.sh: Formats the C++ code usingclang-format.benchmark.sh: A script to run benchmarks. You might need to adapt it to your needs.
- Place the problem instances in the
instances/directory at the root of the repository. - Navigate to the
cpp_srcdirectory:cd cpp_src - Run the build script:
./build.sh - (Optional) Run the test script:
./test.sh - The executable
trigger_arc_tspwill be created incpp_src/build/.
You can then run the solver from the cpp_src/build directory, for example:
./cpp_src/build/trigger_arc_tsp --method grasp --instance-file instances/instances_release_1/grf1.txt --n-trials 10 --local-searches TwoOpt SwapTwo Relocate --constructive-heuristic SimpleRandomized --logs --alpha 0.1 --beta 3.0 --save-solutionsRun ./cpp_src/build/trigger_arc_tsp --help to see all available options.
Our solver includes an implementation of the Greedy Randomized Adaptive Search Procedure (GRASP) metaheuristic. GRASP is an iterative process where each iteration consists of two phases: a construction phase and a local search phase.
In the construction phase, a feasible solution is built using a randomized approach. We support the following constructive heuristics:
RandomizedGreedy: A simple randomized greedy construction.MIPRandomizedGreedyBias: A more advanced construction that uses a MIP model on a restricted set of edges with a bias towards promising edges.MIPRandomizedGreedyRandom: Similar to the above, but with a more random selection of edges.SimpleRandomized: A very simple construction heuristic that randomly selects the next node from the neighbors of the current node. It's very fast but not very effective.
You can specify the constructive heuristic using the --constructive-heuristic flag.
Once a solution is constructed, a local search is applied to improve it until a local optimum is found. We support the following local search neighborhoods:
TwoOpt: The classic 2-opt neighborhood, which involves reversing a segment of the tour.SwapTwo: Swaps two nodes in the tour.Relocate: Moves a node to a different position in the tour.
You can specify one or more local searches to be applied using the --local-searches flag. They will be applied in the order they are provided.
To reproduce the results from our experiments, we provide a set of benchmark scripts in the benchmark/ directory. These scripts automate the process of running the solver with different methods and configurations.
grasp.sh: Runs the solver using the GRASP metaheuristic.gurobi.sh: Runs the solver using the Gurobi MIP solver.randomized_greedy.sh: Runs the solver with the randomized greedy heuristic.simple_randomized.sh: Runs the solver with the simple randomized construction heuristic.mip_randomized_construction_bias.sh: Runs the solver with the MIP randomized construction (biased version).mip_randomized_construction_random.sh: Runs the solver with the MIP randomized construction (random version).
- Make sure you have built the project as described above.
- Place your problem instances in the
instances/directory. - From the project root, run any of the scripts in the
benchmark/directory. For example:./benchmark/grasp.sh
Each script is pre-configured with recommended parameters, but you can edit them to suit your needs.
If you use this implementation in your research, please cite our paper:
@misc{soler2025fast,
title={A Fast GRASP Metaheuristic for the Trigger Arc TSP with MIP-Based Construction and Multi-Neighborhood Local Search},
author={Joan Salvà Soler and Grégoire de Lambertye},
year={2025},
eprint={2508.08477},
archivePrefix={arXiv},
primaryClass={cs.AI}
}This project is licensed under the MIT License - see the LICENSE.txt file for details.