This is simple project that use Genetic Algorithm to solve Traveling Salesman Problem (TSP). The visualization part is done with SFML library.
The program will start with a set of solutions (randomly generated routes between cities) which is called Population. Solutions from one population are then taken and used to form a new population through Selection, Cross-over and Mutation methods.
-
Selection: The fittest solution of thePopulationis hand-picked to be included in the next generation. -
Cross-over: In each generation, there are chances that two solution can produce offspring, which contain genetic information from both parents. -
Mutate: Aftercross-over, each offspring can have a chance to mutate into totally new solution.
- The project uses {fmt} library for formating output. The library can be easily installed with Microsoft's vcpkg.
vcpkg install fmt
- Clone the project:
git clone https://github.com/phuongtran7/Accelerator. - Download and extract SFML library. Adjust
includeandlibdirectory of the project. - Open project's
Property Pagesin Visual Studio. SelectDebugging, adjust theEnviromentto point to thebindirectory of SFML. - Build the project with Visual Studio.
- The dataset for TSP problem can be download here: http://www.math.uwaterloo.ca/tsp/world/countries.html.
- Put the dataset (in
TSPLIB Format (.tsp)) next to the executable. The program supports multiple.tspfiles in the same location as the executable. It will ask to choose with dataset to use each startup. - Start the program.
This project is extremely inefficient and incredibly slow. Don't run large dataset with high number of member and generation.