Giter Site home page Giter Site logo

kkkaan / reinforcement-learning-for-tsp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 223 KB

A Q-learning like algorithm to find the optimal solutions for the Travelling Salesman Problem (TSP).

License: MIT License

C++ 98.62% Makefile 1.38%
cpp q-learning-algorithm travelling-salesman-problem

reinforcement-learning-for-tsp's Introduction

A Q-Learning Implementation for Travelling Salesman Problem

This project aims to solve the Travelling Salesman Problem (TSP) using two algorithms, including a greedy approach and a reinforcement learning (RL)-like implementation.

Overview

The project consists of several C++ source files organized into different modules:

  • Main.cpp: Entry point of the program. Reads data from a file and invokes the RL-based algorithm.
  • RL.cpp: Contains the implementation of the RL-like algorithm for solving the TSP.
  • Travel.cpp: Implements an old version of the TSP solver using a greedy approach.
  • Helpers.cpp: Provides helper functions used by the main algorithms.
  • ReadFile.cpp: Reads input data from a CSV file.
  • Headers: Header files containing function declarations and necessary includes.

Algorithm Implementations

Reinforcement Learning (RL)

The RL algorithm employs a Q-learning-like approach to learn an optimal policy for visiting cities in the TSP. It utilizes a Q-table to estimate the value of taking a particular action (visiting a city) in a given state (current city).

Greedy Approach

The greedy algorithm iteratively selects the next city to visit based on the closest available neighbor, aiming to minimize the total distance travelled.

Usage

To compile and run the program, follow these steps:

  1. Ensure you have a C++ compiler installed (e.g., g++).

  2. Clone the repository to your local machine.

  3. Navigate to the project directory in your terminal.

  4. The program will read data from the "DistancesBetweenCities.csv" file (adjust path if necessary), apply the RL algorithm, and output the results.

  5. Compile the source files using the provided Makefile:

    make all
    
  6. Run the executable:

    ./main
    

reinforcement-learning-for-tsp's People

Contributors

kkkaan avatar

Stargazers

 avatar

Watchers

 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.