7e587d48d043f331fd8e1aa8b932031fc0c25a4a
The current test implementation includes random mutation, single point crossover, and tournament selection. The implementation, in short, is a nested approach. The selection method is the only thing actually called by the GA. Both crossover and mutation occur within the selection method. As long as these three systems all follow a standard input/output system, any implementation we build, as well as any user implementations, will work perfectly. The selection function must take GA as a parameter and output a new population. Crossover takes in GA and outputs a population. Mutation takes a chromosome set and outputs a new chromosome set. Many of the changes in this commit are regarding this test implementation. I have also changed many of the file names from "x_examples" to "x_types" and updated the class names to follow capitalziation standards. I did this because I feel personally like the built-in mutation, crossover, and selection implementations are less "examples" and more just already built implementations to make the code required from the user smaller.
EasyGA - A general solution to Genetic Algorithms
Project description
Installation:
Run the rolling to install:
pip3 install EasyGA
Getting started with EasyGA:
import EasyGA
# Setup the default genetic algorithm
ga = EasyGA.GA()
# Run the default genetic algorithm
ga.evolve()
Output:
Put the out here
Customized:
import random
import EasyGA
# Create the Genetic algorithm
ga = EasyGA.GA()
# Makes a new gene
new_gene = ga.make_gene("HelloWorld")
# Makes a chromosome to store genes in
new_chromosome = ga.make_chromosome()
# Makes a Population to store chromosomes in
new_population = ga.make_population()
ga.initialize()
print(ga.population)
for chromosome in ga.population.chromosomes:
print(chromosome.genes[0].__dict__)
Output:
<initialization.population_structure.population.population object at 0x7f993002fdf0>
{'fitness': None, 'value': 47}
{'fitness': None, 'value': 4}
{'fitness': None, 'value': 68}
{'fitness': None, 'value': 57}
How Testing works
Getting started with testing
pip3 install pytest
Navigate to your EasyGA folder and run:
pytest
Output
============================== 1 passed in 0.02s ===============================
danielwilczak@Daniels-MacBook-Pro EasyGA % pytest
============================= test session starts ==============================
platform darwin -- Python 3.8.6rc1, pytest-6.0.2, py-1.9.0, pluggy-0.13.1
rootdir: /Users/danielwilczak/github/EasyGA
collected 1 item
src/gene/test_gene.py . [100%]
============================== 1 passed in 0.03s ===============================
This is only an example and we will create hundreds of tests so this list will become bigger and bigger.
Developing EasyGA:
If you know how to use Github and git ignore this section.
Getting started with development
To work together we plan on using github and the git framework. This is made easy with the Atom software.
Download Atom for whatever OS you have. https://atom.io/
Use the github tab to pull the github repository. Its self explanitory.
Use the run_testing.py file inside the src folder to run your code and test while we build the package.
Other options
Download the repository to some folder - If you never used git. Look up a youtube tutorial. It will all make sense.
git clone https://github.com/danielwilczak101/EasyGA.git
Or download as a zip file.
https://github.com/danielwilczak101/EasyGA/archive/master.zip
Use the example.py file inside the src folder to run your code and test while we build the package.
Description
Languages
Python
100%