Giter Site home page Giter Site logo

yining043 / tsp-improve Goto Github PK

View Code? Open in Web Editor NEW
86.0 86.0 28.0 11.87 MB

An improvement-based Deep Reinforcement Learning Algorithm presented in paper https://arxiv.org/abs/1912.05784v2 for solving the TSP problem.

License: MIT License

Jupyter Notebook 73.89% Python 26.11%
deep-reinforcement-learning heuristics machine-learning operations-research travelling-salesman-problem

tsp-improve's People

Contributors

yining043 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tsp-improve's Issues

swap or 2-opt?

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?

CUDA Device Problem

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:

  1. I ran the code on the GPU directly and got the error:
    TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
    Modify line 28 of plots.py:
# Change the following:
ave_grads.append(p.grad.abs().mean())
# To:
ave_grads.append(p.grad.abs().mean().cpu())
  1. After solving the TypeError, I met the 'scipy.misc' problem mentioned in the README.md and solved it successfully by referring to the issue #27.
  2. 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:
# 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?

I got an issues about the code

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 !

About the tsplib

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?

I have a question.

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 !

Hello,I am a new man in deep learning, please help me, 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:

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)))


what can I do? Thanks you very much!

pretrain model

could you provide the pretrain model for tsp-50 and tsp100๏ผŸ thanks!

A Potential Bug Report

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

results on tsplib

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.