Skip to content

One-Liu/genetic_algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ABOUT

  • 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.

Genetic 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.

Class diagram

How to run the program (Windows)

  1. Create and activate a virtual environment (optional).
py -m venv .venv
.venv\Scripts\activate
  1. Install the requirements specified in the requirements.txt file.
py -m pip install -r requirements.txt
  1. 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.

Releases

No releases published

Packages

No packages published

Languages