• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a python grammar for evolutionary algorithms and heuristics

Documentation StatusDownloads Build Status Documentation StatusDownloads

Imgur

Evol is clear dsl for composable evolutionary algorithms that optimised for joy.

Installation

We currently support python3.6 and python3.7 and you can install it via pip.

pip install evol

Documentation

For more details you can read the docs but we advice everyone to get start by first checking out the examples in the /examples directory. These stand alone examples should show the spirit of usage better than the docs.

The Gist

The main idea is that you should be able to define a complex algorithm in a composable way. To explain what we mean by this: let's consider two evolutionary algorithms for travelling salesman problems.

The first approach takes a collections of solutions and applies:

  1. a survival where only the top 50% solutions survive
  2. the population reproduces using a crossover of genes
  3. certain members mutate
  4. repeat this, maybe 1000 times or more!

Drawing

We can also think of another approach:

  1. pick the best solution of the population
  2. make random changes to this parent and generate new solutions
  3. repeat this, maybe 1000 times or more!

Drawing

One could even combine the two algorithms into a new one:

  1. run algorithm 1 50 times
  2. run algorithm 2 10 times
  3. repeat this, maybe 1000 times or more!

Drawing

You might notice that many parts of these algorithms are similar and it is the goal of this library is to automate these parts. We hope to provide an API that is fun to use and easy to tweak your heuristics in.

A working example of something silimar to what is depicted above is shown below. You can also find this code as an example in the /examples/simple_nonlinear.py.

import random
from evol import Population, Evolution

random.seed(42)

def random_start():
    """
    This function generates a random (x,y) coordinate
    """
    return (random.random() - 0.5) * 20, (random.random() - 0.5) * 20

def func_to_optimise(xy):
    """
    This is the function we want to optimise (maximize)
    """
    x, y = xy
    return -(1-x)**2 - 2*(2-x**2)**2

def pick_random_parents(pop):
    """
    This is how we are going to select parents from the population
    """
    mom = random.choice(pop)
    dad = random.choice(pop)
    return mom, dad

def make_child(mom, dad):
    """
    This function describes how two candidates combine into a new candidate
    Note that the output is a tuple, just like the output of `random_start`
    We leave it to the developer to ensure that chromosomes are of the same type
    """
    child_x = (mom[0] + dad[0])/2
    child_y = (mom[1] + dad[1])/2
    return child_x, child_y

def add_noise(chromosome, sigma):
    """
    This is a function that will add some noise to the chromosome.
    """
    new_x = chromosome[0] + (random.random()-0.5) * sigma
    new_y = chromosome[1] + (random.random()-0.5) * sigma
    return new_x, new_y

# We start by defining a population with candidates.
pop = Population(chromosomes=[random_start() for _ in range(200)],
                 eval_function=func_to_optimise, maximize=True)

# We define a sequence of steps to change these candidates
evo1 = (Evolution()
       .survive(fraction=0.5)
       .breed(parent_picker=pick_random_parents, combiner=make_child)
       .mutate(func=add_noise, sigma=1))

# We define another sequence of steps to change these candidates
evo2 = (Evolution()
       .survive(n=1)
       .breed(parent_picker=pick_random_parents, combiner=make_child)
       .mutate(func=add_noise, sigma=0.2))

# We are combining two evolutions into a third one. You don't have to
# but this approach demonstrates the flexibility of the library.
evo3 = (Evolution()
       .repeat(evo1, n=50)
       .repeat(evo2, n=10)
       .evaluate())

# In this step we are telling evol to apply the evolutions
# to the population of candidates.
pop = pop.evolve(evo3, n=5)
print(f"the best score found: {max([i.fitness for i in pop])}")

Getting Started

The best place to get started is the /examples folder on github. This folder contains self contained examples that work out of the box.

How does it compare to ...

  • ... deap? We think our library is more composable and pythonic while not removing any functionality. Our library may be a bit slower though.
  • ... hyperopt? Since we force the user to make the actual algorithm we are less black boxy. Hyperopt is meant for hyperparameter tuning for machine learning and has better support for search in scikit learn.
  • ... inspyred? The library offers a simple way to get started but it seems the project is less actively maintained than ours.

More Repositories

1

whirl

Fast iterative local development and testing of Apache Airflow workflows
Shell
179
star
2

dbt-excel

[DEPRECATED] A dbt adapter for Excel.
Python
90
star
3

iterative-broadcast-join

The iterative broadcast join example code.
Scala
69
star
4

pydantic-avro

This library can convert a pydantic class to a avro schema or generate python code from a avro schema.
Python
62
star
5

pytest-dbt-core

Pytest plugin for dbt core
Python
57
star
6

airflow-testing-examples

Python
46
star
7

rhyme-with-ai

Rhyme with AI
Python
38
star
8

jiraview

Extract data from JIRA through REST and create charts.
Python
35
star
9

scala-spark-application

Scala
32
star
10

llm-archetype-batch-use-case

General solution to archetype LLM batch use case
Python
29
star
11

pydantic-spark

Python
22
star
12

risk-analysis

Genetic algorithms and the game of Risk
Jupyter Notebook
19
star
13

piven

Prediction Intervals with specific value prediction
Python
18
star
14

build-your-own-search-engine

This repository contains code to build an MVP search engine with google like interface.
Python
16
star
15

dbt-data-ai-summit

Code that was used as an example during the Data+AI Summit 2020
15
star
16

airflow_workspace

Workspace for Airflow training, inlcuding docker and docker compose
Dockerfile
15
star
17

python-devcontainer-template

Shows you how to use a Devcontainer for your Python project 🐳♡🐍
Python
15
star
18

airflow-training-skeleton

Skeleton project for Apache Airflow training participants to work on.
Python
15
star
19

ansible_cluster

Instant Hadoop cluster with Ansible and Cobbler - Just Add Water.
Shell
13
star
20

airflow-helm

Smarty
11
star
21

doobie-monix-jdbc-example

Example project demonstrating easy, concise and typechecked JDBC access
Scala
10
star
22

ParallelConnection

Python
10
star
23

auto-tagger

Tagging texts with tags automatically
Python
9
star
24

openllm-starter

Get started with open source LLMs on a GPU
Jupyter Notebook
9
star
25

asekuro

A utility tool to automate certain tasks with Jupyter notebooks.
Python
9
star
26

databricks-cdk

Deployment of databricks resources with cdk
Python
8
star
27

c4-model-example

ASL
7
star
28

druid-ansible

Ansible scripts to create druid cluster
Python
7
star
29

godatadriven-blog

Sources to our blog
HTML
6
star
30

organization-pr-scanner

Python
6
star
31

dropblox

Drop some Blox! The one who drops in the most efficient way wins! 🏆
Jupyter Notebook
6
star
32

stackexchange-parquet

Spark job for converting the StackExchange Network data into parquet format.
Scala
5
star
33

taster-sessions

4
star
34

private-package-in-gcp-tutorial

In this tutorial, we will register a package in GCP Artifact Registry both manually as well as with CICD. In the end, you will be able to install your own private package with pip just like you're used to.
Python
4
star
35

Kedro-Azureml-Starter

Python
4
star
36

prometheus-kafka-offsets

Scala
4
star
37

datamesh

Material for the DataMesh presentation at GoDataFest 2021
Jupyter Notebook
4
star
38

feature_catalog

A package to define features and create them via a simple API
Python
4
star
39

github-contributions

Gather and analyse Github contributions with dbt-duckdb
TypeScript
4
star
40

public_cloudera_on_azure

This is needed because the Azure template cannot read from a private github
Shell
3
star
41

code_breakfast_materialize_metabase

Building a real-time analytics dashboard with Materialize and Metabase
3
star
42

flink-streaming-xke

Example how to use Flink with Kafka
Java
3
star
43

pydantic-examples

3
star
44

godatadriven-vision

Computer vision with python and OpenCV
CSS
3
star
45

mlops-workshop

How to MLOps: Experiment tracking & deployment 📊
Jupyter Notebook
3
star
46

pr-scraper

Tracks our pull requests in public repositories
Python
2
star
47

monopoly-analysis

bigger simulations = moar profit
Python
2
star
48

code-breakfast-deep-learning

Material for PyData Code Breakfast: Introduction to Deep Learning
Jupyter Notebook
2
star
49

provision-nifi-hdinsight

Scripts to provision NiFi to HDInsight
Shell
2
star
50

os-training-materials

A selection of notebooks coming from the GoDataDriven trainings
HTML
2
star
51

dbt-bi-exposures

Python package that collects dbt exposure metadata from different BI providers such as Power BI, Tableau, Looker, Metabase, etc.
Python
2
star
52

duck-pond

A lightweight data lake using dbt-duckdb
2
star
53

ddsw-2018-dsp-workshop

Jupyter Notebook
2
star
54

azureml_experiment_tracking_tutorial

Python
2
star
55

hive-summary-loader

Scripts that load data into hive and create a summary for it
Python
2
star
56

clubcloud_dbt_soda

Repository for Club Cloud workshop on dbt + SodaSQL
Python
2
star
57

hadoop-ds-workshop

Hadoop Data Science workshop
Python
1
star
58

azure_function_python_remote_build

Example repository to show how a minimal Python application can be built and deployed remotely as Azure Function.
HCL
1
star
59

azure_function_terraform

HCL
1
star
60

data-centric-ai-hackathon

Jupyter Notebook
1
star
61

mac-install

Setting up your new Macbook with an install script.
Shell
1
star
62

airflow-aks-dags

Python
1
star
63

hdp-smokey

Hadoop smoke testing framework
Python
1
star
64

tmnl-spark-graphs-training

Python
1
star
65

code_breakfast_tutorial

HTML
1
star
66

bandit-friday

February 2021 GDD Friday project of Roel, Rogier and Vadim
Jupyter Notebook
1
star
67

balancing-heroes-and-pokemon

Balancing Heroes and Pokemon in Real Time: A Streaming Variant of Trueskill for Online Ranking
Scala
1
star
68

academy-git-fundamentals

1
star