https://github.com/governmentplates/geneticalgorithm
Genetic algorithm with Ackley function optimization
https://github.com/governmentplates/geneticalgorithm
ackley-function-optimization genetic-algorithm python
Last synced: 10 months ago
JSON representation
Genetic algorithm with Ackley function optimization
- Host: GitHub
- URL: https://github.com/governmentplates/geneticalgorithm
- Owner: GovernmentPlates
- License: afl-3.0
- Created: 2021-07-28T20:14:46.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-08-07T10:53:43.000Z (almost 4 years ago)
- Last Synced: 2025-01-19T16:49:20.401Z (over 1 year ago)
- Topics: ackley-function-optimization, genetic-algorithm, python
- Language: Python
- Homepage:
- Size: 123 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# (Simple) Genetic Algorithm
Simple genetic algorithm with Ackley's function optimization.
**Author:** Dominic Hollis (GovernmentPlates) -- Uni Coursework (May 2021)
***
## Running the GA
Make sure that all the files `main.py`, `GAFunctions.py` and `GAConfig.py` are in the same
directory.
Then run `main.py` from your Python CLI -- after a few seconds (depending on your parameters), you should see a GAOutput.csv generated.
The CSV contains the population coordinates, which can then be fed into a program like Excel to produce a graph.

**IMPORTANT:** Make sure that you are reading the output of the console for any messages.
## Adjusting the parameters of the GA
The script will read from the configuration file called `ga.config`. You can open this file up
in a text editor of your choice and change around the parameters on there.
If this is the first time you are running the script, it will generate a configuration file with default parameters for you. Once it does this, re-run `main.py`.
Example `ga.config` file:
```
populationSize:100
maximumGens:1000
minBoundsSolutionConstraint:-5
maxBoundsSolutionConstraint:5
```
**populationSize** Set's the size of the population (used in generating the population for the first time).
**maximumGens** Set's the maximum number of generations that the GA will go through.
**minBoundsSolutionConstraint** A minimum boundary value (used in generating random numbers).
**maxBoundsSolutionConstraint** A maximum boundary value (used in generating random numbers).
**NOTE:** As per the [university assignment] requirements, the **minBoundsSolutionConstraint** and **maxBoundsSolutionConstraint** must be set at **-5** and **5** (constraints).
## Features Implemented
* Population generation
* Genetic crossover + Mutation
* Child generation
* Ackley function optimization (used in the fitness function)
* Configuration system (innovation?)