[How to change the CVRTW environment so that it can be trained and tested on the Solomon dataset]
lihaoya5 opened this issue · comments
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:
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?
Because there is no intermediate process results and visualization means to generate the dataset, I don't know how to tell the difference.
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.
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.
I tried to set scale:bool=true and then the training result is as follows:
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.
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 :)
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.
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!
Okay, I'll give it a try
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!