Git Product home page Git Product logo

geneticpy's Introduction

GeneticPy

Genetic solver written in Python

Usage

import genetic

best = genetic.getBest(get_fitness, display, minLen, optimalFitness,
        geneSet=None, createGene=None, maxLen=None,
        customMutate=None, customCrossover=None)

Output:

an Individual with attributes:

  • Genes: list of genes
  • Fitness: fitness value for those genes
  • Strategy: strategy that produced the gene sequence (mutate, crossover, or random)

Inputs:

  • get_fitness: takes a list of genes and returns an integer value representing how close that particular candidate comes to the optimal solution. Higher values are better.
  • display: takes an Individual. Called to provide visual output of better candidates as they are discovered.
  • minLen: minimum valid length for an Individual's genes.
  • maxLen: optional maximum valid length for an Individual's genes. Defaults to minLen.
  • optimalFitness: expected fitness value for the best solution.
  • geneSet: optional list of gene values for generating new gene sequences. If not provided, createGene must be provided.
  • createGene: optional function to create a random gene. Called with the gene sequence index into which it will be placed, and the length of that gene sequence. If not provided, geneSet must be provided.
  • customMutate: optional replacement for the built in mutate function. Called with the new child genes. Changes should be made to the child genes.
  • customCrossover: optional replacement for the built in crossover function. Called with the new child genes, and a copy of a second parent's genes. Changes should be made to the child genes.

Sample projects (in order of genetic complexity)

Obsolete samples

The following sample projects included in this repository work but no longer have a related blog post because I've changed my implementation approach.

  • equationGenerationTests.py - equation discovery

  • operationGenerationTests.py - generating OR and XOR with only AND and NOT

e-book

The code and examples in ths repository work as is and you are welcome to use them. In late 2015 I restarted from scratch with a slower feature progression to resolve some performance issues with more advanced genetic programming topics. That has evolved into an e-book entitled Genetic Algorithms with Python that I'm writing on Leanpub. Try the sample chapter.

License

MIT License

geneticpy's People

Contributors

handcraftsman avatar brandonmburroughs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.