Solve a variant of the Orienteering Problem (OP) called the Team Orienteering Problem (TOP) with a cooperative multi-agent system based on Transformer Networks, called TOP-Former. For more details, please see our paper. If this repository is useful for your work, please cite our paper:
@ARTICLE{fuertes2025,
author={Fuertes, Daniel and del-Blanco, Carlos R. and Jaureguizar, Fernando and García, Narciso},
title={TOP-Former: A Multi-Agent Transformer Approach for the Team Orienteering Problem},
journal={IEEE Transactions on Intelligent Transportation Systems},
volume={26},
number={9},
pages={13799-13810},
year={2025},
doi={10.1109/TITS.2025.3566157}
}
- Python >= 3.8
- NumPy
- SciPy
- Numba
- PyTorch >= 1.7
- tqdm
- tensorboard_logger
- Matplotlib
First, it is necessary to create test and validation sets:
python generate_data.py --name test --seed 1234 --graph_sizes 20 20 20 35 35 35 50 50 50 75 75 75 100 100 100 --max_length 1.5 2 2.5 1.5 2 2.5 1.5 2 2.5 1.5 2 2.5 1.5 2 2.5
python generate_data.py --name val --seed 4321 --graph_sizes 20 20 20 35 35 35 50 50 50 75 75 75 100 100 100 --max_length 1.5 2 2.5 1.5 2 2.5 1.5 2 2.5 1.5 2 2.5 1.5 2 2.5To train a Transformer model (attention) use:
python run.py --problem top --model attention --val_dataset data/1depots/const/20/val_seed4321_L2.0.pkl --graph_size 20 --data_distribution const --num_agents 2 --max_length 2.0 --baseline rolloutand change the environment conditions (number of agents, graph size, max length, reward distribution...) at your convenience.
Pretrained weights are available
here. You can unzip the file
with unzip (sudo apt-get install unzip):
unzip pretrained.zipPointer Network (pointer),
Graph Pointer Network (gpn) and
GAMMA
(gamma) can also be trained with the --model option. To resume training, load your last saved model with the
--resume option. Additionally, pretrained models are provided inside the folder pretrained.
Evaluate your trained models with:
python eval.py data/1depots/const/20/test_seed1234_L2.0.pkl --model outputs/top_const20/attention_... --num_agents 2If the epoch is not specified, by default the last one in the folder will be used.
Baselines algorithms like Ant Colony Optimization (aco), Particle Swarm Optimization (pso), or Genetic Algorithm
(opga) can be executed as follows:
python -m problems.top.eval_baselines --method aco --multiprocessing True --datasets data/1depots/const/20/test_seed1234_L2.0.pklFinally, you can visualize an example using:
python visualize.py --graph_size 20 --num_agents 2 --max_length 2 --data_distribution const --model outputs/top_const20/attention_...
python visualize.py --graph_size 20 --num_agents 2 --max_length 2 --data_distribution const --model acopython run.py -h
python eval.py -h
python -m problems.op.eval_baselines -h
python visualize.py -hThis repository is an adaptation of wouterkool/attention-learn-to-route for the TOP. The baseline algorithms (ACO, PSO, and GA) were implemented following the next repositories: robin-shaun/Multi-UAV-Task-Assignment-Benchmark and dietmarwo/Multi-UAV-Task-Assignment-Benchmark