mveres01 / pytorch-drl4vrp Goto Github PK
View Code? Open in Web Editor NEWImplementation of: Nazari, Mohammadreza, et al. "Deep Reinforcement Learning for Solving the Vehicle Routing Problem." arXiv preprint arXiv:1802.04240 (2018).
Implementation of: Nazari, Mohammadreza, et al. "Deep Reinforcement Learning for Solving the Vehicle Routing Problem." arXiv preprint arXiv:1802.04240 (2018).
Hi, many thanks for the excellent code. I got one little question (please feel free to correct me):
In the paper, the authors compute context vector with attention vector * embedded inputs (static and dynamic hidden)
But in your code, you applied context vector computation with static hidden only and then cat it with static hidden:
I'm a little confused about this. May I ask if there is any particular reasons? Thank you!
Hello,
I try to train the model but it took a very long time to finish. I wonder what is the final result after the training process. Will it give me a trained model? How can I use this model to calculate my case? For example 100 cities with given demands and their longitude and latitude.
Thank you very much!
So I ran your code without making any modifications for vrp and 10 nodes (as well as 20)...and the graph looks as if there is only two nodes: depot and one more node...what is wrong?
Hi,
When I try to run trainer.py with the task = 'vrp', the error message as below comes up. is it a version issue? (device= 'cpu')
Traceback (most recent call last):
File "D:/LG_RL/pytorch-drl4vrp-master/trainer.py", line 390, in
train_vrp(args)
File "D:/LG_RL/pytorch-drl4vrp-master/trainer.py", line 348, in train_vrp
train(actor, critic, **kwargs)
File "D:/LG_RL/pytorch-drl4vrp-master/trainer.py", line 164, in train
tour_indices, tour_logp = actor(static, dynamic, x0)
File "C:\Users\hsko0\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "D:\LG_RL\pytorch-drl4vrp-master\model.py", line 224, in forward
dynamic = self.update_fn(dynamic, ptr.data)
File "D:\LG_RL\pytorch-drl4vrp-master\tasks\vrp.py", line 135, in update_dynamic
return torch.Tensor(tensor.data, device=dynamic.device)
TypeError: new(): data must be a sequence (got Tensor)
Process finished with exit code 1
Best,
Hyeseon
Hi,
Could you please explain more about how to apply the checkpoint into a real example?
Thanks a lot!
Hi,
Sorry to raise an issue again.
I ran this code with checkpoint for vrp20 with load 30 and max demand 9 however the best result is 827(unit) for case A-N33-K5(optimal result is 661) most heuristic algorithm can get that result.
A-N33-K5 is a standard instance which has 33 nodes and vehicle capacity is 100.
you can download the case from this website. http://www.bernabe.dorronsoro.es/vrp/ I scaled down the coordinates to 0,1 range to avoid large numbers.
I tried a trained vrp37 weight with load 44 however the result is even worse.
In the application part I used 1 for the train-size and valid-size. I also tried A-N60-K9 but the result is 1943 and it is also far away from the optimal result( 1354)(I used the trained weight for VRP50)
I wonder how I can improve the result? Change the weight?Retrain the model? Is it due to the batch-size or learning rate? Or the model is not robust enough? ( I got a pretty good result when using the vrp20 weight on a vrp37 real case problem. I used to think the model is quite robust.)
Thank you so much for your time and help.
Hello,
I have updated my pytorch to the latest 1.0 version but still use python 3.6
when I run the code I got the following tracebacks , I wonder if I can run the code with the latest pytorch 1.0? Thank you so much for your time and help!
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\pytorch-drl4vrp-master\trainer.py", line 390, in
train_vrp(args)
File "C:\Users\Administrator\Desktop\pytorch-drl4vrp-master\trainer.py", line 348, in train_vrp
train(actor, critic, **kwargs)
File "C:\Users\Administrator\Desktop\pytorch-drl4vrp-master\trainer.py", line 164, in train
tour_indices, tour_logp = actor(static, dynamic, x0)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "C:\Users\Administrator\Desktop\pytorch-drl4vrp-master\model.py", line 192, in forward
dynamic_hidden = self.dynamic_encoder(dynamic)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "C:\Users\Administrator\Desktop\pytorch-drl4vrp-master\model.py", line 17, in forward
output = self.conv(input)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\modules\conv.py", line 187, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #2 'weight'
Line 127 in 5b9b86e
Hi,
In the paper, the author mentioned if the whole delivery constraint is relaxed the result will get better.
However if I omit the constraint( demands.lt(load) the result is always worse. even if I try to retrain the model.
In the paper even for the greedy, split delivery is better than whole delivery.
Do you know what may cause the difference here?
Thank you very much for your help!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.