Replies: 14 comments 1 reply
-
Hi @WYF99111 ! |
Beta Was this translation helpful? Give feedback.
-
I want to use the CVRP benchmark on CVRPLIB, how can I do it? |
Beta Was this translation helpful? Give feedback.
-
I want to use the CVRP benchmark on CVRPLIB, how can I do it? |
Beta Was this translation helpful? Give feedback.
-
Hi @WYF99111, You can test your dataset by overriding some input policy = AttentionModelPolicy() # Assume the trained parameters are loaded.
td = policy.env.reset(batchsize=[n]) # assuming you are evaluating "n" instances.
td[‘loc’] = your_loc
td[‘depot’] = your_depot_loc
td[‘demand’] = your_demand
out = policy(td)
print(out[‘reward’]) Note that code can break when |
Beta Was this translation helpful? Give feedback.
-
Hello, can you give me an example about td['loc'], td['depot'], td['demand'], I don't know much about its data types |
Beta Was this translation helpful? Give feedback.
-
Same as the answer on Slack from @cbhua , reporting it here: You can run this minimalistic example and print the td to check the shape of each feature: from rl4co.envs import TSPEnv
# Environment, Model, and Lightning Module
env = TSPEnv(num_loc=20)
# Get an example random tensordict
td = env.reset(batch_size=[64])
print(td) Next time, please try to answer the question in only one place, as it would make it easier for us to track issues :) |
Beta Was this translation helpful? Give feedback.
-
I have the similar issue. I want to train the model for CVRPenv on my own dataset and I wrote my own data_parser and generator like this: ` def __init__(self, td_test):
self.max_loc = max_coord(td_test["locs"][0, :,:])
self.min_loc = min_coord(td_test["locs"][0, :,:])
self.num_loc = td_test["demand"].shape[1] #depot counts as location here
self.depot = td_test["depot"][0,:]
self.max_dem = max_demand(td_test["demand"][0, :])
self.min_demand = min_demand(td_test["demand"][0,:])
self.capacity = td_test["capacity"][0].item() ` env2 = CVRPEnv(num_loc=vrp_size,
max_demand=max_demand,
min_demand=min_demand,
max_loc=max_loc,
min_loc=min_loc,
capacity=capacity,
vehicle_capacity=capacity` What I am facing, is that CAPACITIES dict from Kool in the CVRPenv is linked somehow deep in the models, so even when you set the "capacity" and "demand" (e.g. between 10 and 100) variables in CVRPEnv, you get the output like this: Output tensors are then :
Obviously, the demand is divided by the capacity taken from the CAPACITIES dict in ' state = env1.reset(batch_size = [6])
-> vehicle_capacity:tensor([[150],
[150],
...)
locs:tensor([[101.7827, 611.7601],
...])
demand:tensor([0.6286, 0.6429, 0.7286, 0.6571, 0.4714, 0.1714, 0.4143, 0.6000, 0.2571,
0.3286]) So, what is the best way to train the model on your own dataset? Thx |
Beta Was this translation helpful? Give feedback.
-
Hi, In short, in my opinion, you might want to consider overriding the
I'm assuming you are referring to the behavior of the code in Line 249 of cvrp.py. During the development of However, we realize that the use of the @fedebotu, could you also review this? |
Beta Was this translation helpful? Give feedback.
-
Hi @Junyoungpark, thank you for your reply. Yes, I meant exactly this line. If you set the vehicle capacity in CVRPEnv to an arbitrary value, the demand will be normalized by "/CAPACITIES[num_loc]" , but the vehicle capacity will not. This lead to the output, like |
Beta Was this translation helpful? Give feedback.
-
Hi @ElijaDei! Thanks for pointing out this part. This problem comes from some redundant code. The But the |
Beta Was this translation helpful? Give feedback.
-
We will keep this issue open since we want to implement native loading for TSP/CVRP Libs soon! |
Beta Was this translation helpful? Give feedback.
-
Hi there! Now we have two tutorial notebooks about how to test your trained model on the TSP/CVRP libs ( In these notebooks we cleaned up the pipeline to test the model, including guidance to download and prepare the dataset, load your trained model, and test with greedy, augmentation, and sampling ways. Have fun! |
Beta Was this translation helpful? Give feedback.
-
The current code for testing on the TSPLib and CVRPLib contains massive data loading, tensor converting and testing loop. In the next step we could wrap these to utilize functions for more clear and convenient usage. Also we could support more baseline libs for better diversity. |
Beta Was this translation helpful? Give feedback.
-
Converted to discussion as this issue was very old - recently support for VRPLib has been added officially by @ngastzepeda and coming out in |
Beta Was this translation helpful? Give feedback.
-
After training I want to test performance with my own test set how can I achieve this
Beta Was this translation helpful? Give feedback.
All reactions