Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] add GFACS and replace PyVRP with HGS for CVRP local search #236

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

hyeok9855
Copy link
Contributor

@hyeok9855 hyeok9855 commented Jan 12, 2025

Description

This PR includes:

  1. Implementation of GFACS
  2. Replace PyVRP with HGS for CVRP local search (because HGS is way better)
  3. Minor refactorings in DeepACO

Regarding documentation and tests: I added/updated docstrings, but not very carefully. I didn't update tests. If you think more work is needed in these areas, please ping me.

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • New feature (non-breaking change which adds core functionality)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

@hyeok9855 hyeok9855 self-assigned this Jan 12, 2025
@fedebotu fedebotu mentioned this pull request Jan 14, 2025
Copy link
Member

@fedebotu fedebotu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

About Python tests, please check out #237

Only comment is about the location of the nice HGS-CVRP dependency :)

@@ -58,7 +58,7 @@ def forward(

def pre_decoder_hook(
self, td: TensorDict, env: RL4COEnvBase, hidden: Any = None, num_starts: int = 0
) -> Tuple[TensorDict, Any, RL4COEnvBase]:
) -> Tuple[TensorDict, RL4COEnvBase, Any]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good eye for this 👀 !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About HGS-CVRP: I think the best way for us would be to provide instructions for the user on how to download this repo and install it? If the code was modified (as it seems to be) I think we can upload it as a separate repo that can be downloaded as optional - this is for us not to maintain in a single repo RL-based solvers and pure heuristics 👀
For example, we could provide instructions like this:

cd rl4co/envs/routing/cvrp
git clone [email protected]:vidalt/HGS-CVRP.git # can be modified, e.g. git clone [email protected]:ai4co/HGS-CVRP.git  if we upload it as separate code
cd HGS-CVRP/
bash build.sh 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Yes, it's modified by DeepACO.
But I'm wondering if it is worth uploading it as a separate repo because it is almost the same as the original HGS but has a function for local_search.
@henry-yeh, @Furffico Do you guys have any idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both options seem fine to me, but I lean slightly towards optional downloading. It would make RL4CO more purely RL-based and lighter to use.

Copy link
Member

@Furffico Furffico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! 🎉
There's just two minor issue.

Params params(x_coords,y_coords,distance_matrix,service_time,demands,vehicleCapacity,durationLimit,max_nbVeh,isDurationConstraint,verbose,*ap);

char buff[100] = {};
snprintf(buff, sizeof(buff), "/tmp/route-%i", callid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Windows compatibility is taken into consideration, some modifications might be necessary here and in local_search.py.
For instance, in Python, using tempfile.TemporaryDirectory() to obtain a cross-platform temporary directory path and then passing it to this function.
However, considering Windows compatibility might bring additional complications (build scripts, documentations, etc.). It's up to you.

@@ -257,7 +256,7 @@ def replace_selected_actions(
def local_search(td: TensorDict, actions: torch.Tensor, **kwargs) -> torch.Tensor:
assert (
local_search is not None
), "Cannot import local_search module. Check if `pyvrp` is installed."
), "Cannot import local_search module. Check if HGS is built."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps some instructions required here to tell users on how to build HGS, e.g. "Please check ... for more information."

@fedebotu
Copy link
Member

If it's not an issue, I think GFACS can be released in the next 0.5.3 since now it is a busy time?

This would allow us to release 0.5.2 now with some hotfixes. 0.5.3 can be for GFACS + some additional stuff!

@hyeok9855
Copy link
Contributor Author

Yeap sure. I think I can also add my current ICML project.

@fedebotu
Copy link
Member

Yeap sure. I think I can also add my current ICML project.

This would be awesome 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants