yining043 / tsp-improve Goto Github PK
View Code? Open in Web Editor NEWAn improvement-based Deep Reinforcement Learning Algorithm presented in paper https://arxiv.org/abs/1912.05784v2 for solving the TSP problem.
License: MIT License
An improvement-based Deep Reinforcement Learning Algorithm presented in paper https://arxiv.org/abs/1912.05784v2 for solving the TSP problem.
License: MIT License
In the problem_tsp.py file, from line 32 to line 35, I suppose it to perform a 2-opt operation but I find that you use a swap oepration for some reason?
I encounter some problems making use of the CUDA to run the code while the code runs normally on the CPU. The following are the specific problems and solutions which resolve the issue for me:
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
plots.py
:# Change the following:
ave_grads.append(p.grad.abs().mean())
# To:
ave_grads.append(p.grad.abs().mean().cpu())
README.md
and solved it successfully by referring to the issue #27.RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
plots.py
:# Change the following:
plt.plot(initial_value.mean() - np.cumsum(reward.cpu().mean(0)))
# To:
plt.plot(initial_value.cpu().mean() - np.cumsum(reward.cpu().mean(0)))
Hope these can do some help.
PS: By the way, do you implement the VRP version mentioned in the paper?
It say that
assert (
48 torch.arange(rec.size(1), out=rec.data.new()).view(1, -1).expand_as(rec) ==
49 rec.data.sort(1)[0]
50 ).all(), "Invalid tour"
52 # Gather dataset in order of tour
---> 53 d = dataset.gather(1, rec.long().unsqueeze(-1).expand_as(dataset))
54 length = (d[:, 1:] - d[:, :-1]).norm(p=2, dim=2).sum(1) + (d[:, 0] - d[:, -1]).norm(p=2, dim=1)
56 return length
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_gather)
So how can fix this problem many thanks !
Hello, would it be possible to access the code for tsplib?
I'm also wondering how you dealed with data that are not represented with xy-coordinate like brazil58.tsp?
Hi how i deal with not fully connected data?
For example ( x1,y1) and (x3,y3) are zero ( In reality they can't go from (1) to (3) ). Many thanks !
First, thanks your code. However, when I run the "Solving TSP with Improvement-base DRL".
Here "cost = problem.get_costs(instance, solution)", I saw the error information:
File "E:\TSP-improve-master\TSP-improve-master\problems\problem_tsp.py", line 53, in get_costs
d = dataset.gather(1, rec.long().unsqueeze(-1).expand_as(dataset))
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
I found the issues closed have the same problem:
"#2"
But I checked the answers, they were have modfiied in my "plots.py" :
Afterwards, I got the error:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Modify line 54 of plots.py:
plt.plot(initial_value.mean() - np.cumsum(reward.cpu().mean(0)))
plt.plot(initial_value.cpu().mean() - np.cumsum(reward.cpu().mean(0)))
what can I do? Thanks you very much!
could you provide the pretrain model for tsp-50 and tsp100๏ผ thanks!
Dear Yining,
I hope this message finds you well. I was using your TSP-improve project on GitHub and noticed a bug that I wanted to bring to your attention.
The issue I encountered is to reset 'exchange' parameter back to 'None' after each full episode whose length is 4.
I believe this issue can be solved by moving Line: 226 'exchange = None' to the following line after Line 238: while t < T in train.py file.
Please let me know if I made any mistakes. Thank you for your time and effort in maintaining this project.
Best regards,
Chen
How i can add time window in this code?
hi there, thanks for your contribution on this work, but the results of table 4 can't be reproduced, especially on AM(N=1280), AM(N=5000) and ours(T=3000), are you an co-author or a member of the institution mentioned in the original paper?
i want to ask how to evaluate the tsplib dataset
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.