Evolutionary Algorithms in Go

Related tags

Machine Learning evo
Overview

Evo

Evo is a framework for implementing evolutionary algorithms in Go.

go get github.com/cbarrick/evo

Documentation

https://godoc.org/github.com/cbarrick/evo

Status & Contributing

Evo is a general framework for developing genetic algorithms and more. It began life in fall 2015 as I studied evolutionary algorithms as an undergrad.

Contributions are welcome! I am currently a student and inexperienced maintainer, so please bear with me as I learn. The focus of the project thus far has been on the API design and less on performance. I am particularly interested in hearing about use-cases that are not well covered and success stories of where Evo excels. Testing, code reviews, and performance audits are always welcome and needed.

Examples

You can browse example problems in the example subpackage. The examples are maintained as a development tool rather than to provide optimal solutions to the problems they tackle. Reading the examples should give you a good idea of how easy it is to write code with Evo.

License (LGPL)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Comments
  • Memory management improvements

    Memory management improvements

    One space optimization for evolutionary algorithms is to reuse the space of dead genomes to reduce (even eliminate) allocations during the main loop. In the current API, Evo encourages using a finalizer to recycle the memory. To make this as easy as possible, Evo allows the user to define a Close method that gets registered as a finalizer. In the examples, the Close methods use a sync.Pool to handle the memory recycling.

    There are a couple problems here. First, finalizers are not guaranteed to run. This means the Close method has no real meaning in the API because Evo may ignore it. If the genome MUST cleanup resources, the user is forced to do this without relying on the Close method. Second, a sync.Pool frees the recycled but unused memory at each GC cycle. This limits the extent to which the optimization is valuable.

    Addressing the first problem, we could remove the Close method from the Population interface. This should have minimal backwards-compatibility implications since the method is not guaranteed to be called in the first place. A difficulty arises when we use a pool selector for replacement in that the user does not know when a genome is being discarded. We could incorporate the cleanup into a pool selector, and this may involve some kind of generic selector.

    As for the second problem, we can simply introduce our own long-lived free list type. This should be trivial relative to the sync.Pool type since we don't need to interact with the runtime.

    enhancement 
    opened by cbarrick 2
  • Update the core API

    Update the core API

    As started in #12, I'm revamping the core API to be easier to extend. As part of this, I'm going to rethink the way the Close hook works, per #11.

    TODO

    • [x] Update the interfaces
    • [x] Update the concrete populations
      • [x] generational
      • [x] graph
    • [x] Add migration functions
    • [x] Rework (Genome).Close
    • [x] Update the examples
      • [x] ackley
      • [x] queens
      • [x] tsp
    • [x] Cleanup (remove dead code, squash commits, etc.)
    opened by cbarrick 1
  • Separation of concerns

    Separation of concerns

    The Genome interface wraps the representation of the object being optimized. The inner loop of the GA needs to know of the representation, but it is not itself a property of the representation. Thus the Evolve method should be split from the Genome interface into a new type and provided to the population dynamically.

    eg, something like this:

    // A Genome is an instance of the object being optimized.
    type Genome interface{
        Fitness() float64
    }
    
    // An EvolveFn is called in parallel for each member of a population and returns a replacement.
    type EvolveFn func(current Genome, suitors []Genome) Genome
    
    // A Population manages the evolution of a population of genomes.
    type Population interface{
        Evolve(seed []Genome, loop EvolveFn)
        // ...
    }
    
    enhancement 
    opened by cbarrick 1
  • Expose a SetDelay method on the population interface

    Expose a SetDelay method on the population interface

    Currently, the graph population type is public to make the SetDelay method available. If SetDelay were required by all populations, then the graph population could be a private type.

    • [x] Add SetDelay to the population interface
    • [x] Implement SetDelay on the generational population
    • [x] Make the graph population private
    • [x] Implement Population.Start
    enhancement 
    opened by cbarrick 1
  • Race condition in graph population

    Race condition in graph population

    The graph population may close a genome before it's done using it.

    Genomes are closed when the inner-loop of the containing node is complete and a new genome is set to replace the contents. However, the genome may be used by neighboring nodes in their inner-loop. To fix this, we need to keep up with the references to the genome and delay closing until the reference count is 0.

    The work around is to not rely on the close method of genomes it you rely on the graph population. This prohibits certain optimizations, like recycling genomes. Fixing this is high priority.

    bug 
    opened by cbarrick 1
  • Evolution Strategies

    Evolution Strategies

    Adds the missing pieces for simple evolution strategies.

    • [x] Helpers for real valued vectors (naive)
    • [x] Coordinated elite replacement
    • [x] Ackley function as an ES example
    opened by cbarrick 0
  • Add helpers for selection

    Add helpers for selection

    The same helpers should work for parent and replacement selection. Non-trivial replacement selections require synchronizing many concurrent evolve loops.

    enhancement 
    opened by cbarrick 0
  • Rename Genome.Cross to Genome.Evolve

    Rename Genome.Cross to Genome.Evolve

    The Cross method does more than just crossover: it handles the entire inner-loop body. It would more appropriately be named Evolve. This requires updating both the code and documentation.

    opened by cbarrick 0
  • Faster stats package

    Faster stats package

    Hi,

    I love your project!!

    I changed the stats package to a faster single-pass calculation. sumsq is now truly a sum of squares and mean was replaced with sum. This allows for a much faster Put method which is where most time is spent. The determination of min and max is faster too as there is not overhead call to functions in the math package.

    Unit tests pass as they are. A local benchmark showed original package of ~18ns/op and new package is ~8ns/op. Every bit helps, especially in genetic algorithms.

    opened by bliksemstraal 3
Releases(v0.2.1)
  • v0.2.1(Feb 13, 2016)

  • v0.2.0(Feb 11, 2016)

    This release is oriented around API changes.

    • The Genome type has been simplified to separate representation from the evolution function.
    • A new type, EvolveFn, now serves the purpose of the old (Genome).Evolve.
    • The Population interface is more robust and include a new polling interface.
    • Both concrete populations have undergone a lot of review and refactoring.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Nov 9, 2015)

    This release is an API preview of Evo. I am currently focused on the API design, examples, and documentation. I've not done much profiling yet, so there is likely room for improvement in performance.

    I don't expect much of the existing API to change, but you never know. The project is using semantic versioning going forward.

    Source code(tar.gz)
    Source code(zip)
Owner
Chris Barrick
SRE, SWE, Rust enthusiast
Chris Barrick
Genetic Algorithms library written in Go / golang

Description Genetic Algorithms for Go/Golang Install $ go install git://github.com/thoj/go-galib.git Compiling examples: $ git clone git://github.com

Thomas Jager 193 Sep 27, 2022
Collaborative Filtering (CF) Algorithms in Go!

Go Recommend Recommendation algorithms (Collaborative Filtering) in Go! Background Collaborative Filtering (CF) is oftentimes used for item recommenda

Tim Kaye 193 Dec 28, 2022
Genetic algorithms using Golang Generics

Package genetic Package genetic implements genetic algorithms using Golang's Gen

Konnor Klashinsky 8 Sep 23, 2022
Evolutionary optimization library for Go (genetic algorithm, partical swarm optimization, differential evolution)

eaopt is an evolutionary optimization library Table of Contents Changelog Example Background Features Usage General advice Genetic algorithms Overview

Max Halford 823 Dec 30, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Hugo Bollon 373 Dec 20, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Hugo Bollon 373 Dec 20, 2022
Go translations of the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Overview Go translations of the Java source code for the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin

youngzy 175 Dec 13, 2022
:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go

Region quadtrees in Go Region quadtrees and efficient neighbour finding techniques in Go Go-rquad proposes various implementations of region quadtrees

Aurélien Rainone 122 Dec 13, 2022
Go implementation of C++ STL iterators and algorithms.

iter Go implementation of C++ STL iterators and algorithms. Less hand-written loops, more expressive code. README translations: 简体中文 Motivation Althou

disksing 170 Dec 19, 2022
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.

Trie Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching. Usage Create a Trie with: t := trie.New() Add Keys with:

Derek Parker 623 Dec 27, 2022
Graph algorithms and data structures

Your basic graph Golang library of basic graph algorithms Topological ordering, image by David Eppstein, CC0 1.0. This library offers efficient and we

Algorithms to Go 616 Jan 2, 2023
Graph algorithms written in Go

Graph Algorithms in Go This repository contains implementations of various graph algorithms written in Go. I’ve written them to learn about these algo

Thomas Cyron 59 Dec 26, 2022
Some algorithms in go: maxflow(min-cuts or graph-cuts), edit-distance.

Algorithms In this repository, some algorithms are implemented in go language. GoDoc link: ed maxflow About Max-flow problem: A flow network is repres

Yi Deng 15 Sep 8, 2022
Image processing algorithms in pure Go

bild A collection of parallel image processing algorithms in pure Go. The aim of this project is simplicity in use and development over absolute high

Anthony N. Simon 3.7k Jan 6, 2023
Selected Machine Learning algorithms for natural language processing and semantic analysis in Golang

Natural Language Processing Implementations of selected machine learning algorithms for natural language processing in golang. The primary focus for t

James Bowman 386 Dec 25, 2022
k-modes and k-prototypes clustering algorithms implementation in Go

go-cluster GO implementation of clustering algorithms: k-modes and k-prototypes. K-modes algorithm is very similar to well-known clustering algorithm

e-Xpert Solutions 37 Nov 29, 2022
Genetic Algorithms library written in Go / golang

Description Genetic Algorithms for Go/Golang Install $ go install git://github.com/thoj/go-galib.git Compiling examples: $ git clone git://github.com

Thomas Jager 193 Sep 27, 2022
Collaborative Filtering (CF) Algorithms in Go!

Go Recommend Recommendation algorithms (Collaborative Filtering) in Go! Background Collaborative Filtering (CF) is oftentimes used for item recommenda

Tim Kaye 193 Dec 28, 2022
Selected Machine Learning algorithms for natural language processing and semantic analysis in Golang

Natural Language Processing Implementations of selected machine learning algorithms for natural language processing in golang. The primary focus for t

James Bowman 386 Dec 25, 2022
Exponentially Weighted Moving Average algorithms for Go.

EWMA This repo provides Exponentially Weighted Moving Average algorithms, or EWMAs for short, based on our Quantifying Abnormal Behavior talk. Exponen

VividCortex 400 Dec 28, 2022