This project, developed as part of my gymnasium (high school) studies, demonstrates a comparison between a Genetic Algorithm (GA) and a Brute Force method. The primary aim is to analyze and compare the efficiency and effectiveness of these two approaches in solving optimization problems, such as the Traveling Salesman Problem.
- Implementation of a Genetic Algorithm for optimization.
- Brute Force approach for comparison.
- Performance analysis between the two methods.
- Use of high-resolution timer for accurate performance measurement.
- C++ Compiler (e.g., GCC, Clang, MSVC)
- C++ Standard: C++11 or later (due to usage of and other features)
Clone the repository to your local machine:
git clone https://github.com/SimonNyvall/Traveling-Salesman-AI.git
Compile the C++ file using your preferred C++ compiler. For example, using g++:
g++ -o ga_comparison AI/SalemanAI.cpp
Run the compiled program:
./ga_comparison
Genetic Algorithm
: The GA is implemented to optimize the solution by evolving over generations.Brute Force Method
: A straightforward approach is implemented for comparison.Timer Class
: Used for measuring the execution time of both methods.Population and City Initialization
: Sets up the initial state for the GA.Mutation and Fitness Calculation
: Core components of the GA for evolving solutions.