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

[How to change the CVRTW environment so that it can be trained and tested on the Solomon dataset] #148

Closed
lihaoya5 opened this issue Mar 29, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@lihaoya5
Copy link

Motivation

I used the python run.py experiment=routing/am-cvrptw env.num_loc=10 command to run the results under the default generated dataset, as follows:
image
I looked at you at rl4co/envs/routing
Regarding the specific implementation of the CVRTW environment in /cvrptw.py, I want to modify the code in it to train the cases in the Solomon dataset, so as to make a comparison with the experiments in other papers.
I tried to modify the solomon=true in the load_data, is the dataset generated at this time the solomon dataset or the dataset generated by default?
image
Because there is no intermediate process results and visualization means to generate the dataset, I don't know how to tell the difference.

@lihaoya5 lihaoya5 added the enhancement New feature or request label Mar 29, 2024
@fedebotu
Copy link
Member

Hi there, thanks for pointing this out, it is one of our priorities we would like to solve.

In the current version:
In the base RL4COLitModule here (the class controlling how training is done) you can see that the dataset is collected from the environment itself. This can be achieved by setting the train file to a file containing instances of the Solomon dataset, which will override the default data generation under the generate_data function.

We are in the process of making a separate DataGenerator function and we will prioritize this since we agree it is a very useful feature to have!

CC: @ngastzepeda

PS: Note that the training is done via batches for the VRPs (e.g. [512, 100] where batch_size is 512 and num_loc is 100) so if you want different instance size in the same batch you would need to do some padding.

@lihaoya5
Copy link
Author

Ok, thanks for the answer, looking forward to the version after rl4co. I have another question, I noticed that the setting in the CVRTW environment is max_loc=150, max_time=480, and does not scale to [0,1] random sampling node coordinates, and the paper mentions that RL4CO is consistent with the 2019 Kool et al. generated dataset.
image
I tried to set scale:bool=true and then the training result is as follows:
image
I would like to do more experiments with python run.py experiment=routing/am-cvrptw env.num_loc=20,30 to compare with other papers.

@fedebotu
Copy link
Member

In Kool et al. 2019 they did not do CVRP-TW, so we are using custom settings.
We noticed that several papers have different ways to generate instances, and that can cause confusion (for this reason, we should standardize this soon!).
We recommend you to override the generate_data function in CVRP-TW such that the generated instances are similar to the papers you are comparing to for fairness of comparison. Feel free to suggest / contribute to RL4CO if you find better settings :)

@lihaoya5
Copy link
Author

Ok, thanks for the answer, I also downloaded some olomon dataset examples offline, but I don't know how. There are no good ideas on how to override the generate_data function in CVRTW, thank you again for your answer, and I'll take a look at the other papers.

@fedebotu
Copy link
Member

How to override:

You can create your custom CustomCVRPTWEnv(CVRPTWEnv) and modify that generate_data method:

class CustomCVRPTWEnv(CVRPTWEnv):
  name = "cvrptw"
  [...]
  def generate_data(...):
     [your functions here!]

And then call that environment instead!

@lihaoya5
Copy link
Author

Okay, I'll give it a try

@fedebotu
Copy link
Member

fedebotu commented Jun 8, 2024

We made quite a few API changes. Now, you may pass a generator to the environments which may include data from the Solomon dataset!

For example:

from rl4co.envs.routing import CVRPTWEnv, CVRPTWGenerator

generator = CVRPTWGenerator(num_loc=50)
env = CVRPTWEnv()

You may create a new Generator class following this example


Feel free to re-open or file a new issue if something is still not working!

@fedebotu fedebotu closed this as completed Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants