Giter VIP home page Giter VIP logo

vrp-rl's Introduction

Reinforcement Learning for Solving the Vehicle Routing Problem

We use Reinforcement for solving Travelling Salesman Problem (TSP) and Vehicle Routing Problem (VRP).

Paper

Implementation of our paper: Reinforcement Learning for Solving the Vehicle Routing Problem.

Dependencies

How to Run

Train

By default, the code is running in the training mode on a single gpu. For running the code, one can use the following command:

python main.py --task=vrp10

It is possible to add other config parameters like:

python main.py --task=vrp10 --gpu=0 --n_glimpses=1 --use_tanh=False 

There is a full list of all configs in the config.py file. Also, task specific parameters are available in task_specific_params.py

Inference

For running the trained model for inference, it is possible to turn off the training mode. For this, you need to specify the directory of the trained model, otherwise random model will be used for decoding:

python main.py --task=vrp10 --is_train=False --model_dir=./path_to_your_saved_checkpoint

The default inference is run in batch mode, meaning that all testing instances are fed simultanously. It is also possible to do inference in single mode, which means that we decode instances one-by-one. The latter case is used for reporting the runtimes and it will display detailed reports. For running the inference with single mode, you can try:

python main.py --task=vrp10 --is_train=False --infer_type=single --model_dir=./path_to_your_saved_checkpoint

Logs

All logs are stored in result.txt file stored in ./logs/task_date_time directory.

Sample CVRP solution

enter image description here

Acknowledgements

Thanks to pemami4911/neural-combinatorial-rl-pytorch for getting the idea of restructuring the code.

vrp-rl's People

Contributors

rezanazari 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

vrp-rl's Issues

module 'tensorflow.python.layers.layers' has no attribute 'Conv1D'

Hello,

I have troubles when running your program.

I have installed tensorflow 1.2 as required, but also with newer tensor flow versions it fails.
The module has only the interface "conv1d", which expects some other parameters, so this also does not lead to a solution.

Do you have any idea?

Thanks in advance

Traceback (most recent call last):
  File "main.py", line 103, in <module>
    main(args, prt)
  File "main.py", line 58, in main
    is_train=args['is_train'])
  File "/Projects/vrp/model/attention_agent.py", line 42, in __init__
    _scope=_scope+'Actor/')
  File "/Projects/vrp/shared/embeddings.py", line 28, in __init__
    self.project_emb = tf.layers.Conv1D(embedding_dim,1,
AttributeError: module 'tensorflow.python.layers.layers' has no attribute 'Conv1D'

Issue regarding vrp result

I have run your program for around 82k epochs for VRP10. After each 200 epoch your program validated by 1000 test samples and according to the result ,which is average tour length of those 1000 test data, it is very clear that over the epochs result is improving. Its start with a value of 8.309866905212402 and the final validation result is 4.853826522827148 (in greedy method). But the problem is that after 82k epochs I have load the saved weight and only perform test on those 1000 data it produce a result with the value 7.8747758865356445. I have performed the test operation for several time but each and every time I got the same kind of result.
I am attaching the text files for your reference. Waiting for your answer.
Thank you
results.txt
results.txt

dimension of the problem to solve "real world" TSP/VRP

Hello,

First, thank you for the code, it's very interesting and usefull, i've also read your paper and i'm interested in TSP and VRP problem.

I want to use this model but with a "real" dataset. The point is that if I want to respect all distances between my "n" cities, I have to project them into dimensions "n-1".

I've seen the next parameter in your Env class (both TSP and VRP) :

  • args['input_dim']: dimension of the problem which is 2

I want to change it (it's set into task_specific_params.py) to solve "real world" problem.

Have you tried change this into "n-1" dimension (9 for TSP 10) to maintain all distances you have between each pair of the 10 nodes ?

I'm triing to use your code, to adapt it to "real" problems, in which you can not consider distances as the crow flies. The real agent need to follow roads.

I'm triing to work on such an issue, by generating new structure of datas to train and test in some new dimensions.

Maybe you also did ?

I've work on a paper and I know that it's dificult to adapt some code made to illustrate progress in a field to an industrial real world big problem.

I'll appreciate if you could tell me if you have been considering my type of approach.

Thanks again !

issues about the Valid data

Hello,

problem is about the valid data set. I found that some instance in the valid set is similar to some instance in the training set. Because there coordination are the same, and only the demand is different. Do you think it will have influence on the reliability of the result?

thank you very much!!!

Has stochastic VRP been implemented?

Hi, thanks for your work!
I wonder if stochastic VRP mentioned in your paper is implemented in this project. I'm working on pickup-and-delivery with dynamic orders!
Thanks!

Trying to run on CPU machine

I am trying to run this on windows machine with just CPUs available, but it gives error
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 980, in _find_and_load
SystemError: <class '_frozen_importlib._ModuleLockManager'> returned a result with an error set
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
2019-06-22 03:38:35.403667: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr

When I manually import numpy.core.multiarray and numpy.core.umath from python prompt it is importing fine.

Am I missing something?

About Train

Hello!
I appreciate your excellent work very much, so I tried to run your code in order to find about your result precisely.But as I trained,in the size 20,50,100,after a few steps,actor loss became NAN and critic loss became 0. Why does that happened?

confused of the glimpses

Are the glimpses in the code corresponding to the equation 4 and 5 in the article?
I an quite confused of it.
if so, the M in the equation 5 is the number of glimpses?
I like your paper very much, so I want to know how to realize it.
Thank you ~

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.