Natural Selection
,(*
@@
*@ @@% *@
*@ @@ %@ @
@@/ @@ @@ @@
@@@(,@( @/ @@@@@@@&@@@@@
@ @& @@ /@@@#
/@ @@ ,@@ @@
,@@ @@ @@ @
%@@@ @@ @@@@@@@@@@@@@
,, @ @@ @@ &@@@
%@@ @@ &@@ @@
@%@@ &@@ @
,@,%@@
@@@@@@
_ _
_ __ __ _| |_ _ _ _ __ __ _| |
| '_ \ / _` | __| | | | '__/ _` | |
| | | | (_| | |_| |_| | | | (_| | |
|_| |_|\__,_|\__|\__,_|_| \__,_|_|
_ _ _
___ ___| | ___ ___| |_(_) ___ _ __
/ __|/ _ \ |/ _ \/ __| __| |/ _ \| '_ \
\__ \ __/ | __/ (__| |_| | (_) | | | |
|___/\___|_|\___|\___|\__|_|\___/|_| |_|
by Zipfian Science
Python tools for creating and running Evolutionary Algorithm (EA) experiments by Zipfian Science.
Install
$ pip install natural-selection
And use
from natural_selection.genetic_algorithms import Gene, Chromosome, Individual, Island
from natural_selection.genetic_algorithms.utils.random_functions import random_int, random_gaussian
# Create a gene
g_1 = Gene(name="test_int", value=3, gene_max=10, gene_min=1, randomise_function=random_int)
g_2 = Gene(name="test_real", value=0.5, gene_max=1.0, gene_min=0.1, randomise_function=random_gaussian)
# Add a list of genes to a genome
gen = Chromosome([g_1, g_2])
# Next, create an individual to carry these genes and evaluate them
fitness_function = lambda island, individual, x, y: individual.chromosome[0].value * x + individual.chromosome[0].value * y
adam = Individual(fitness_function, name="Adam", chromosome=gen)
# Now we can create an island for running the evolutionary process
# Notice the fitness function parameters are given here.
params = dict()
params['x'] = 0.5
params['y'] = 0.2
isolated_island = Island(function_params=params)
# Using a single individual, we can create a new population
isolated_island.initialise(adam, population_size=5)
# And finally, we let the randomness of life do its thing: optimise
best_individual = isolated_island.evolve(n_generations=5)
# After running for a few generations, we have an individual with the highest fitness
fitness = best_individual.fitness
genes = best_individual.chromosome
for gene in genes:
print(gene.name, gene.value)
Release
- Date: 2023-02-15
- Version: 0.2.33
Metadata
Release files for natural-selection 0.2.33
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 |
|---|---|---|---|---|
| natural_selection-0.2.33.tar.gz | 40.8 kB | Without provenance | Details for natural_selection-0.2.33.tar.gz |
Release files / natural_selection-0.2.33.tar.gz
| Download URL | natural_selection-0.2.33.tar.gz |
|---|---|
| Size | 40.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a87831694d0f3cb7fc1bb26363644d6194fa1c12634e7497a355429ff912b872
|
|
BLAKE2b-256 checksum How to use checksums |
757193382094adfcb184c4f97c01664f3dd5beca09b33bcc9061e4e5b798427c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9
|
Security for natural-selection 0.2.33
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.