The codes for POMO+PIP and GFACS+PIP will be released in a few days.
Hi there! Thanks for your attention to our work!🤝
This is the PyTorch code for the Proactive Infeasibility Prevention (PIP) framework implemented on POMO, AM and GFACS.
PIP is a generic and effective framework to advance the capabilities of neural methods towards more complex VRPs. First, it integrates the Lagrangian multiplier as a basis to enhance constraint awareness and introduces preventative infeasibility masking to proactively steer the solution construction process. Moreover, we present PIP-D, which employs an auxiliary decoder and two adaptive strategies to learn and predict these tailored masks, potentially enhancing performance while significantly reducing computational costs during training.
For more details, please see our paper Learning to Handle Complex Constraints for Vehicle Routing Problems, which has been accepted at NeurIPS 2024😊. If you find our work useful, please cite:
@inproceedings{
bi2024learning,
title={Learning to Handle Complex Constraints for Vehicle Routing Problems},
author={Bi, Jieyi and Ma, Yining and Zhou, Jianan and Song, Wen and Cao,
Zhiguang and Wu, Yaoxin and Zhang, Jie},
booktitle = {Advances in Neural Information Processing Systems},
year={2024}
}
Generate data
For evaluation, you can use our provided datasets or generate data by running the following command under the ./POMO+PIP/
directory:
# Default: --problem_size=50 --problem="ALL" --hardness="hard"
python generate_data.py --problem={PROBLEM} --problem_size={PROBLEM_SIZE} --hardness={HARDNESS}
Baseline
# Default: --problem="TSPTW" --datasets="../data/TSPTW/tsptw50_medium.pkl"
python LKH_baseline.py --problem={PROBLEM} --datasets={DATASET_PATH} -n=10000 -runs=1 -max_trials=10000
# Default: --problem="TSPTW" --datasets="../data/TSPTW/tsptw50_medium.pkl"
python OR-Tools_baseline.py --problem={PROBLEM} --datasets={DATASET_PATH} -n=10000 -timelimit=20
# Optional arguments: `--cal_gap --optimal_solution_path={OPTIMAL_SOLUTION_PATH}`
# Default: --problem="TSPTW" --datasets="../data/TSPTW/tsptw50_medium.pkl"
python greedy_parallel.py --problem={PROBLEM} --datasets={DATASET_PATH} --heuristics="length"
# Optional arguments: `--cal_gap --optimal_solution_path={OPTIMAL_SOLUTION_PATH}`
# Default: --problem="TSPTW" --datasets="../data/TSPTW/tsptw50_medium.pkl"
python greedy_parallel.py --problem={PROBLEM} --datasets={DATASET_PATH} --heuristics="constraint"
# Optional arguments: `--cal_gap --optimal_solution_path={OPTIMAL_SOLUTION_PATH}`
POMO+PIP
Code is not ready yet. It will be available soon.
AM+PIP
# Default: --graph_size=50 --hardness=hard --CUDA_VISIBLE_ID=0
# 1. AM*
python run.py --graph_size={PROBLEM_SIZE} --hardness={HARDNESS}
# 2. AM* + PIP
python run.py --graph_size={PROBLEM_SIZE} --hardness={HARDNESS} --generate_PI_mask
# 3. AM* + PIP-D
python run.py --graph_size={PROBLEM_SIZE} --hardness={HARDNESS} --generate_PI_mask --pip_decoder
# Note: If you want to resume, please add arguments: --pip_checkpoint and --resume
For evaluation, please download the data or generate datasets first.
Pretrained models are provided in the folder ./pretrained/
.
# Default: --graph_size=50 --hardness=hard --CUDA_VISIBLE_ID=0
# 1. AM*
# If you want to evaluate on your own dataset,
python eval.py --datasets={DATASET} --model={MODEL_PATH}
# Optional: add `--val_solution_path` to calculate optimality gap.
# If you want to evaluate on the provided dataset,
python eval.py --graph_size={PROBLEM_SIZE} --hardness={HARDNESS} --model={MODEL_PATH}
# 2. AM* + PIP(-D)
# If you want to evaluate on your own dataset,
python eval.py --datasets={DATASET} --model={MODEL_PATH} --generate_PI_mask
# Optional: add `--val_solution_path` to calculate optimality gap.
# If you want to evaluate on the provided dataset,
python eval.py --graph_size={PROBLEM_SIZE} --hardness={HARDNESS} --model={MODEL_PATH} --generate_PI_mask
# Please set your own `--eval_batch_size` based on your GPU memory constraint.
GFACS+PIP
Code is not ready yet. It will be available soon.
https://github.com/yd-kwon/POMO
https://github.com/wouterkool/attention-learn-to-route
https://github.com/ai4co/gfacs
https://github.com/RoyalSkye/Routing-MVMoE