Coder Social home page Coder Social logo

mariojulian / randomtsp-opengl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from esmitt/randomtsp-opengl

0.0 0.0 0.0 3 KB

A basic code to draw a TSP solution using OpenGL. The solution is only using swaps between cities (nothing fancy)

CMake 8.01% C++ 91.99%

randomtsp-opengl's Introduction

Basic drawing of a TSP using OpenGL

The Traveling Salesman Problem is a famous problem in Computer Science where given k cities to travel, a "salesman" starting out from his home (or place of business), making his appointed rounds to show off the goods he is selling, and then returning to his starting point. To do that, salesman wants to visit all cities once, and the path to travel must be shortest.

In this code, cities are represents using points, and the path using lines between cities. An initial setup is created in sequential order, i.e. 1, 2, 3, ..., n. After that, the euclidean distance of points (x,y) from 1 to n are computed. Next, a 10000 iterations are performed in order to found a different order of cities to travel. This is made using simples swaps between 2 cities, and checking its distance: if the new distances is less than previous one, then is replaced, otherwise continue with the next iteration. It means, a random approach :-)

Pressing the key s, two cities are selected (randomly) and are swapped. If reached distance is less than current one, then is replaced otherwise is reverted. A distance is the distance to travel for the salesman (from a starting city to the last one). If the key a is pressing, the same process is performed but for all cities. This can be applied several times.

The last time, this code was tested on Visual Studio 2017.

Do you want to contribute? Great!

randomtsp-opengl's People

Contributors

esmitt avatar

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.