- This mini-project contains a general genetic algorithm that supports changing the configuration of some of its attributes. In the next diagram we can see the algorithm process.
- The evaluation.py file contains the problem that has the fitness function. In this case, the implemented problem is the Triangle Classification. The Triangle Classification problem involves determining the type of a triangle based on its side lengths.
- You can change the way the solutions are being evaluated in the evaluation.py file. The method score() defined in the parent class Evaluation is considered to be the method where the fitness of the solution is given.
- As we can observe in the class diagram, the Factory Method pattern design was used almost everywhere, so you can add more evaluations/problems or types of gen, selections and so on without too much trouble.
- Create and activate a virtual environment (optional).
py -m venv .venv
.venv\Scripts\activate
- Install the requirements specified in the requirements.txt file.
py -m pip install -r requirements.txt
- Execute the main.py file.
py main.py
If you're using other OS or you're having trouble with the first two steps, this link might help you out.
Feel free to take inspiration from this code to create your own Genetic Algorithm applied to your problem!
I'll be grateful if you reference this project.