-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from hyeok9855/main
[Feat] add GFACS and replace PyVRP with HGS for CVRP local search
- Loading branch information
Showing
25 changed files
with
1,380 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,4 +178,7 @@ local_nbrun* | |
|
||
# osx meta files | ||
.DS_Store | ||
outputs/ | ||
outputs/ | ||
|
||
# HGS-CVRP for cvrp local search | ||
HGS-CVRP/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# @package _global_ | ||
|
||
defaults: | ||
- override /model: gfacs.yaml | ||
- override /env: tsp.yaml | ||
- override /callbacks: default.yaml | ||
- override /trainer: default.yaml | ||
- override /logger: wandb.yaml | ||
|
||
env: | ||
generator_params: | ||
num_loc: 50 | ||
|
||
logger: | ||
wandb: | ||
project: "rl4co" | ||
tags: ["gfacs", "${env.name}"] | ||
group: ${env.name}${env.generator_params.num_loc} | ||
name: gfacs-${env.name}${env.generator_params.num_loc} | ||
|
||
model: | ||
batch_size: 20 | ||
val_batch_size: 20 | ||
test_batch_size: 20 | ||
train_data_size: 400 | ||
val_data_size: 20 | ||
test_data_size: 100 | ||
optimizer: "AdamW" | ||
optimizer_kwargs: | ||
lr: 5e-4 | ||
weight_decay: 0 | ||
lr_scheduler: | ||
"CosineAnnealingLR" | ||
lr_scheduler_kwargs: | ||
T_max: 50 | ||
eta_min: 1e-5 | ||
metrics: | ||
test: | ||
- reward_000 | ||
- reward_002 | ||
- reward_009 # since n_iterations["text"] = 10 | ||
train_with_local_search: True | ||
alpha_min: 0.5 | ||
alpha_max: 1.0 | ||
alpha_flat_epochs: 5 | ||
beta_min: 100 | ||
beta_max: 500 | ||
beta_flat_epochs: 5 | ||
|
||
policy_kwargs: | ||
n_ants: | ||
train: 30 | ||
val: 30 | ||
test: 100 | ||
n_iterations: | ||
train: 1 # unused value | ||
val: 5 | ||
test: 10 | ||
temperature: 1.0 | ||
top_p: 0.0 | ||
top_k: 0 | ||
multistart: False | ||
k_sparse: 5 # this should be adjusted based on the `num_loc` value | ||
|
||
aco_kwargs: | ||
alpha: 1.0 # This alpha is different from the alpha in the model | ||
beta: 1.0 # This beta is different from the beta in the model | ||
decay: 0.95 | ||
use_local_search: True | ||
use_nls: True | ||
n_perturbations: 5 | ||
local_search_params: | ||
max_iterations: 1000 | ||
perturbation_params: | ||
max_iterations: 20 | ||
|
||
trainer: | ||
max_epochs: 50 | ||
gradient_clip_val: 3.0 | ||
precision: "bf16-mixed" | ||
devices: | ||
- 0 | ||
|
||
seed: 1234 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
_target_: rl4co.models.DeepACO | ||
|
||
baseline: "exponential" | ||
baseline: "no" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_target_: rl4co.models.GFACS | ||
|
||
baseline: "no" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
As local search in CVRP, we adopted the SWAP* algorithm by Vidal et al. [1, 2] ([repo](https://github.com/vidalt/HGS-CVRP)). Specifically, we use the modified version of code provided by [DeepACO](https://github.com/henry-yeh/DeepACO/tree/main/cvrp_nls/HGS-CVRP-main), which we uploaded to [https://github.com/ai4co/HGS-CVRP](https://github.com/ai4co/HGS-CVRP) for convenience. | ||
|
||
|
||
### Installation | ||
|
||
```bash | ||
cd rl4co/envs/routing/cvrp | ||
git clone [email protected]:ai4co/HGS-CVRP.git | ||
cd HGS-CVRP | ||
bash build.sh | ||
``` | ||
|
||
### References | ||
|
||
[1] Vidal, T., Crainic, T. G., Gendreau, M., Lahrichi, N., Rei, W. (2012). A hybrid genetic algorithm for multidepot and periodic vehicle routing problems. Operations Research, 60(3), 611-624. | ||
|
||
[2] Vidal, T. (2022). Hybrid genetic search for the CVRP: Open-source implementation and SWAP* neighborhood. Computers & Operations Research, 140, 105643. | ||
|
||
[3] Ye, H., Wang J., Cao, Z., Liang, H., Li, Y. (2023). | ||
DeepACO: Neural-enhanced ant systems for combinatorial optimization. Advances in neural information processing systems (NeurIPS) 36 (2023): 43706-43728. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.