simplega
simplega is a simple python implementation of genetic algorithm and it is available through PyPI.
Install
python3 -m pip install simplega
Usage
Import the package
from simplega import Chromosome, Population, GA, GAHelper
# or
from simplega import *
Create a fitness function that suits your problem
def maximize(chromosome):
return sum( [ ord(gene) for gene in chromosome.dna ] )
Create a new instance of GA specifying the fitness function to be used
ga = GA(maximize)
Perform the steps of the genetic algorithm and retrieve the fittest chromosome
ga.run()
print(ga.get_fittest())
All the script - really simple:
from simplega import *
def maximize(chromosome):
return sum( [ ord(gene) for gene in chromosome.dna ] )
ga = GA(maximize)
ga.run()
print(ga.get_fittest())
Advanced usage
You can customize your instance of GA, replacing any or all of its default values
ga = GA(fitness_function,
genes = [ chr(n) for n in range(65,91) ],
chromosome_size = 10,
population_size = 100,
generations = 100,
crossover_points = 1,
elitism_rate = 0.05,
crossover_rate = 0.85,
mutation_rate = 0.01,
)
You can print the fittest chromosome of each generation with ga.run(True)
Contributing
Please submit bugfixes, enhancements, unit tests, usecases and examples with a pull request.
Metadata
Release files for simplega 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simplega-1.0.2.tar.gz | 4.7 kB | Without provenance | Details for simplega-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simplega-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for simplega-1.0.2-py3-none-any.whl |
Total release size: 10.4 kB
Release files / simplega-1.0.2.tar.gz
| Download URL | simplega-1.0.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7e02e93285ad838f55f5d8247348b397bc959f3b8237fdceffb7faa8b1b7866
|
|
BLAKE2b-256 checksum How to use checksums |
93524d641fda56a97940286e5ad37dbe27af2e3a09f980118e4c022e9138858a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
|
Release files / simplega-1.0.2-py3-none-any.whl
| Download URL | simplega-1.0.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7cf9b7707cb81df68019364ddc679256d5376bac19b95cdf7489245ae2e19e8
|
|
BLAKE2b-256 checksum How to use checksums |
69c031990907c4f86f1255c8b08dc3f45daf5455507a00fbd727cf2974d59c07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
|
Security for simplega 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.