Merge branch 'master' of https://github.com/danielwilczak101/EasyGA
This commit is contained in:
19
MANIFEST.in
Normal file
19
MANIFEST.in
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
graft docs
|
||||||
|
graft src
|
||||||
|
graft ci
|
||||||
|
graft tests
|
||||||
|
|
||||||
|
include .bumpversion.cfg
|
||||||
|
include .coveragerc
|
||||||
|
include .cookiecutterrc
|
||||||
|
include .editorconfig
|
||||||
|
|
||||||
|
include AUTHORS.rst
|
||||||
|
include CHANGELOG.rst
|
||||||
|
include CONTRIBUTING.rst
|
||||||
|
include LICENSE
|
||||||
|
include README.rst
|
||||||
|
|
||||||
|
include tox.ini .travis.yml .appveyor.yml .readthedocs.yml .pre-commit-config.yaml
|
||||||
|
|
||||||
|
global-exclude *.py[cod] __pycache__/* *.so *.dylib
|
||||||
42
README.md
42
README.md
@ -1,6 +1,6 @@
|
|||||||
# EasyGA - A general solution to Genetic Algorithms
|
# EasyGA - A general solution to Genetic Algorithms
|
||||||
|
|
||||||
The projects has just started
|
The project has just started
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -12,34 +12,48 @@ pip3 install EasyGA
|
|||||||
|
|
||||||
To use the package:
|
To use the package:
|
||||||
```python
|
```python
|
||||||
import EasyGA as ga
|
import EasyGA
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import EasyGA as ga
|
import random
|
||||||
|
import EasyGA
|
||||||
|
|
||||||
chromosome = ga.chromosome()
|
# The user defined gene function
|
||||||
|
def user_gene_function():
|
||||||
|
return random.randint(1, 100)
|
||||||
|
|
||||||
# Fill the chromosome with genes with Gene Number i'th number
|
# Standard user size requirements:
|
||||||
for i in range(10):
|
Population_size = 10
|
||||||
gene_value = f"Gene Number {i}"
|
Chromosome_length = 10
|
||||||
new_gene = ga.gene("gene_value")
|
|
||||||
chromosome.add_gene(new_gene)
|
|
||||||
|
|
||||||
# Chromosome has 10 genes in it
|
# Create the Genetic algorithm
|
||||||
print(len(chromosome.genes))
|
ga = EasyGA.GA(Population_size, Chromosome_length,user_gene_function)
|
||||||
|
ga.initialize()
|
||||||
|
|
||||||
# Get the first genes value
|
# Looking at the first chromosome in the population:
|
||||||
print(chromosome.genes[0].get_value())
|
ga.population.chromosomes[0].print_chromosome()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Developing EasyGA
|
# Developing EasyGA
|
||||||
|
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
|
||||||
|
```
|
||||||
|
Then install the repositroy using this command:
|
||||||
|
```
|
||||||
|
pip install -e .
|
||||||
|
```
|
||||||
|
|
||||||
|
# Working on developing a devel branch
|
||||||
To install EASY, along with the tools you need to develop and run tests, run the following in your virtual env:
|
To install EASY, along with the tools you need to develop and run tests, run the following in your virtual env:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
<<<<<<< HEAD
|
||||||
$ pip install -e .[dev]
|
$ pip install -e .[dev]
|
||||||
|
=======
|
||||||
|
$ pip install -e .[devel]
|
||||||
|
>>>>>>> 306f98d8664024828f5d094268f3da852e904262
|
||||||
```
|
```
|
||||||
|
|||||||
3
setup.py
3
setup.py
@ -5,10 +5,11 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='EasyGA',
|
name='EasyGA',
|
||||||
version='0.0.7',
|
version='0.0.8',
|
||||||
description='A ubiquitous or general purpuse GA',
|
description='A ubiquitous or general purpuse GA',
|
||||||
py_modules=["EasyGA"],
|
py_modules=["EasyGA"],
|
||||||
package_dir={'':'src'},
|
package_dir={'':'src'},
|
||||||
|
python_requires='>=3.6',
|
||||||
url="https://github.com/danielwilczak101/EasyGA",
|
url="https://github.com/danielwilczak101/EasyGA",
|
||||||
author="Daniel Wilczak",
|
author="Daniel Wilczak",
|
||||||
author_email="danielwilczak101@gmail.com",
|
author_email="danielwilczak101@gmail.com",
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from initialization.random_initialization import random_initialization
|
from initialization.random_initialization import random_initialization
|
||||||
|
|
||||||
def check_gene(value):
|
def check_gene(value):
|
||||||
|
#Check to make sure the gene is not empty
|
||||||
assert value != "" , "Gene can not be empty"
|
assert value != "" , "Gene can not be empty"
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@ -36,11 +37,15 @@ class chromosome:
|
|||||||
|
|
||||||
def print_chromosome(self):
|
def print_chromosome(self):
|
||||||
for i in range(len(self.genes)):
|
for i in range(len(self.genes)):
|
||||||
|
# Print the gene one by one.
|
||||||
|
if(i == len(self.genes) - 1):
|
||||||
|
print(f"[{self.genes[i].get_value()}]", end = '')
|
||||||
|
else:
|
||||||
print(f"[{self.genes[i].get_value()}],", end = '')
|
print(f"[{self.genes[i].get_value()}],", end = '')
|
||||||
|
|
||||||
|
|
||||||
class population:
|
class population:
|
||||||
# chromosomes = [chromosome,chromosome,etc]
|
# population = [chromosome,chromosome,etc]
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.chromosomes = []
|
self.chromosomes = []
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
import random
|
import random
|
||||||
import EasyGA
|
import EasyGA
|
||||||
|
|
||||||
|
# The user defined gene function
|
||||||
def user_gene_function():
|
def user_gene_function():
|
||||||
return random.randint(1, 100)
|
return random.randint(1, 100)
|
||||||
|
|
||||||
|
# Standard user size requirements
|
||||||
Population_size = 10
|
Population_size = 10
|
||||||
Chromosome_length = 10
|
Chromosome_length = 10
|
||||||
|
|
||||||
|
# Create the Genetic algorithm
|
||||||
ga = EasyGA.GA(Population_size, Chromosome_length,user_gene_function)
|
ga = EasyGA.GA(Population_size, Chromosome_length,user_gene_function)
|
||||||
|
|
||||||
# Setup the GA's population,chromosomes and genes
|
|
||||||
ga.initialize()
|
ga.initialize()
|
||||||
|
|
||||||
print(ga.population.chromosomes[0].print_chromosome())
|
# Looking at the first chromosome in the population
|
||||||
|
ga.population.chromosomes[0].print_chromosome()
|
||||||
|
|||||||
Reference in New Issue
Block a user