Skip to content

Traveling Salesman Problem (TSP) using Genetic Algorithm in cpp

Notifications You must be signed in to change notification settings

alperimo/tsp_ga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solution optimization of the Travelling Salesman Problem using the evolutionary Genetic Algorithm

Bachelor thesis - July 2024

Prerequisites

Before you can compile and run this program, make sure you have the following prerequisites installed on your system:

macOS

  1. Homebrew (for package management)

    To install Homebrew, open your terminal and run this command:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    You can use the link for detailled installation directives.

  2. g++-13

    To install this version of the compiler for C++, open your terminal and run this command:

    brew install gcc

Windows

  1. MinGW-w64 (for GCC)

  2. Add MinGW-w64 to PATH

    • Add the path to the bin directory of your MinGW-w64 installation to the system environment variables.

Compilation

macOS

Open your terminal and navigate to the project directory. Use the following command to compile the program:

/usr/local/bin/g++-13 -fdiagnostics-color=always -g chromosome.cpp crossover.cpp distance_helper.cpp file_reader.cpp mutation.cpp point.cpp population.cpp tsp_ga.cpp main.cpp -o executable_output

Windows

Open your Command Prompt (or PowerShell) and navigate to the project directory. Use the following command to compile the program:

g++ -g chromosome.cpp crossover.cpp distance_helper.cpp file_reader.cpp mutation.cpp point.cpp population.cpp tsp_ga.cpp main.cpp -o executable_output.exe

Usage

After compiling, you can run the executable. Make sure that you put the executable in the project directory folder src, otherwise add your dataset in an outer directory from your executable, in a folder named data.

macOS

Run the following command in your terminal, which is navigated to the correct directory:

./executable_output

*You might need to add the sudo prefix to your command, depending on the needed permissions for acceess

Windows

Run the following command in your Command Prompt (or PowerShell), which is navigated to the correct directory:

executable_output.exe

About

Traveling Salesman Problem (TSP) using Genetic Algorithm in cpp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published