
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
natural-selection
Advanced tools
,(*
@@
*@ @@% *@
*@ @@ %@ @
@@/ @@ @@ @@
@@@(,@( @/ @@@@@@@&@@@@@
@ @& @@ /@@@#
/@ @@ ,@@ @@
,@@ @@ @@ @
%@@@ @@ @@@@@@@@@@@@@
,, @ @@ @@ &@@@
%@@ @@ &@@ @@
@%@@ &@@ @
,@,%@@
@@@@@@
_ _
_ __ __ _| |_ _ _ _ __ __ _| |
| '_ \ / _` | __| | | | '__/ _` | |
| | | | (_| | |_| |_| | | | (_| | |
|_| |_|\__,_|\__|\__,_|_| \__,_|_|
_ _ _
___ ___| | ___ ___| |_(_) ___ _ __
/ __|/ _ \ |/ _ \/ __| __| |/ _ \| '_ \
\__ \ __/ | __/ (__| |_| | (_) | | | |
|___/\___|_|\___|\___|\__|_|\___/|_| |_|
by Zipfian Science
Python tools for creating and running Evolutionary Algorithm (EA) experiments by Zipfian Science.
$ pip install natural-selection
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)
FAQs
Tools for running evolutionary algorithm experiments
We found that natural-selection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.