https://github.com/aftersol/basic_genetic_algorithm
Basic genetic algorithm that computes tries to find best global maximum of two variables functions
https://github.com/aftersol/basic_genetic_algorithm
Last synced: 7 days ago
JSON representation
Basic genetic algorithm that computes tries to find best global maximum of two variables functions
- Host: GitHub
- URL: https://github.com/aftersol/basic_genetic_algorithm
- Owner: Aftersol
- Created: 2024-08-08T06:46:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-08T21:35:40.000Z (over 1 year ago)
- Last Synced: 2024-08-09T08:31:55.457Z (over 1 year ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 321 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic Genetic Algorithm From Scratch

This code calculates the best fitness of the equation below:
$$\left(f(x,y)=(1-x)^2*exp(-x^2-(y+1)^2)-(x-x^3-y^3)*exp((-x^2-y^2))\right)$$
Where
$$-2<=x,y<=2$$
## How to run
A Jupyter Notebook software such as Google Colab is required. Copy genetic_ai.ipynb to your Jupyter Notebook software and then run the code.
Elite Selection is enabled by default. You can disable this by setting
elite_selection=False
Change this variable to set the amount generations the genetic algorithm will run for
generation=200
You can adjust the fitness equation in the genetic_ai.ipynb provided to find the best fitness of different functions given the variables x and y
Adjust the left and right limits to adjust the range of the decoding function
Increasing the range will decrease the accuracy of the solution
left_limit = -2.0
right_limit = 2.0
Adjust the crossover and mutation probability to change how fast each member mutates and crossover with each other within the next generation.
crossover_prob = 0.7 # probabity of crossover
mutation_prob = 0.01 # probabity of mutations
## Requirements
- A Jupyter Notebook software such as Google Colab
- Numpy
- Deepcopy