Giter Club home page Giter Club logo

som-tsp's Introduction

Solving the Traveling Salesman Problem using Self-Organizing Maps

This repository contains an implementation of a Self Organizing Map that can be used to find sub-optimal solutions for the Traveling Salesman Problem. The instances of the problems that the program supports are .tsp files, which is a widespread format in this problem. All the source code can be found in the src directory, while a report and brief presentation slides (in Spanish) can be found in the report folder. However, for a complete read on the topic, you can read my blog post explaining this implementation and its evaluation.

diagrams/uruguay.gif

To run the code, only Python 3 and the dependencies (matplotlib, numpy and pandas, which are included in the Anaconda distribution by default) are needed. In case you are not using Anaconda, you can install all the dependencies with:

pip install -r requirements.txt

To run the code, simply execute:

cd som-tsp
python src/main.py assets/<instance>.tsp

The images generated will be stored in the diagrams folder. Using a tool like convert, you can easily generate an animation like the one in this file by running:

convert -delay 10 -loop 0 *.png animation.gif

This code is licensed under MIT License, so feel free to modify and/or use it in your projects. If you have any doubts, feel free to contact me or contribute to this repository by creating an issue.


This code was presented for the Bio-Inspired Artificial Intelligence course in the Computer Science & Technology master’s degree @ UC3M. A previous version of this code can be found in this repository. Special thanks to Leonard Kleinans, who worked with me in that previous version.

som-tsp's People

Contributors

diego-vicente avatar eurus-holmes avatar pickfire 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  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

som-tsp's Issues

Distributed TSP

Hi,
Is it possible to run the code in distributed mode? (Having several agents)

Pypi package

Hey @diego-vicente,
It would be nice to have a Pypi package for your algorithm.

We could be able to solve a TSP problem with the following command som-tsp myfile.tsp.

With some options I could choose whether to output the brut path, print the logs, display the distance, plot a graph or an animation...etc

A few comments needed

Hello Diego!
Can you please add some comments on TSP files.
I understand, that these are city coordinates.
OK, but why they are in such strange format - 25270.8333 51505.8333 ?
Why the generic format, e.g. 56.124122, 25.076389 is not used?

And why some coordinates are duplicated?
E.g. (assets/qa194.tsp file)

39 25270.8333 51505.8333
40 25270.8333 51523.0556

What's the point of duplicating 25270.8333 value? (and many others)

Also I've noticed, that many values has different integer part, but fraction parts of the values are the same:

3345 61200.0000 23466.6667
3346 61200.0000 23500.0000
3347 61200.0000 23766.6667
3348 61200.0000 24066.6667
3349 61200.0000 24100.0000

Why so?

Fix x/y ratio into io_helper.py:normalize

normalize() functions uniformly scales positions 'x' and 'y' columns to a [0,1] range, this transformation doesn't keep the initial map dx/dy ratio and has negative impact on solution.

You can keep the ratio while bounding values to [0,1]:
dx = max(x)-min(x)
dy = max(y)-min(y)
ratio = max(dx, dy)
return (c-c.min()) / ratio

Most of your assets are squares and returns similar results but on assets/qa194.tsp, where dx/dy=1.64, it gives a -7% bonus to total route length.

som-tsp-perf-scalefix

Using SOM to find best bath in picking warehouse process

Hi Diego,
I've just seen your work regarding self-organized map in salesman problem and I thank you for share your work.. I was looking some salesman problem solution because I'd like to implement something similar applied the process of peaces picking in my firm's warehouse.
Let me explain the issue: suppose there's a order of production included all peaces needed to accomplish that order.. naturally each peace is located in a different place of the warehouse... so it'll be usefull to find the best way.
I just need to change distance.py class due I'm not going to use euclidean metric...
Am I right?

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.