All Projects → PytLab → Gaft

PytLab / Gaft

Licence: gpl-3.0
A Genetic Algorithm Framework in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Gaft

GARI
GARI (Genetic Algorithm for Reproducing Images) reproduces a single image using Genetic Algorithm (GA) by evolving pixel values.
Stars: ✭ 41 (-93.7%)
Mutual labels:  genetic-algorithm, optimization-algorithms
geneticalgorithm2
Supported highly optimized and flexible genetic algorithm package for python
Stars: ✭ 36 (-94.47%)
Mutual labels:  genetic-algorithm, optimization-algorithms
sopt
sopt:A simple python optimization library
Stars: ✭ 42 (-93.55%)
Mutual labels:  genetic-algorithm, optimization-algorithms
ai-n-queens
Solving and GUI demonstration of traditional N-Queens Problem using Hill Climbing, Simulated Annealing, Local Beam Search, and Genetic Algorithm.
Stars: ✭ 30 (-95.39%)
Mutual labels:  genetic-algorithm, optimization-algorithms
Solid
🎯 A comprehensive gradient-free optimization framework written in Python
Stars: ✭ 546 (-16.13%)
Mutual labels:  genetic-algorithm, optimization-algorithms
Ascension
A metaheuristic optimization framework
Stars: ✭ 24 (-96.31%)
Mutual labels:  genetic-algorithm, optimization-algorithms
biteopt
Derivative-Free Optimization Method for Global Optimization (C++)
Stars: ✭ 91 (-86.02%)
Mutual labels:  genetic-algorithm, optimization-algorithms
geneal
A genetic algorithm implementation in python
Stars: ✭ 47 (-92.78%)
Mutual labels:  genetic-algorithm, optimization-algorithms
zoofs
zoofs is a python library for performing feature selection using a variety of nature-inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics-based to Evolutionary. It's easy to use , flexible and powerful tool to reduce your feature size.
Stars: ✭ 142 (-78.19%)
Mutual labels:  genetic-algorithm, optimization-algorithms
Pagmo2
A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
Stars: ✭ 540 (-17.05%)
Mutual labels:  genetic-algorithm, optimization-algorithms
Ojalgo
oj! Algorithms
Stars: ✭ 336 (-48.39%)
Mutual labels:  optimization-algorithms
Ml From Scratch
Python implementations of some of the fundamental Machine Learning models and algorithms from scratch.
Stars: ✭ 20,624 (+3068.05%)
Mutual labels:  genetic-algorithm
Hyperparameter Optimization Of Machine Learning Algorithms
Implementation of hyperparameter optimization/tuning methods for machine learning & deep learning models (easy&clear)
Stars: ✭ 516 (-20.74%)
Mutual labels:  genetic-algorithm
Smile
Statistical Machine Intelligence & Learning Engine
Stars: ✭ 5,412 (+731.34%)
Mutual labels:  genetic-algorithm
Car Simulator
Autonomous car simulator (based on JavaScript & WebGL) implemented by fuzzy control system, genetic algorithm and particle swarm optimization.
Stars: ✭ 335 (-48.54%)
Mutual labels:  genetic-algorithm
Dissecting Reinforcement Learning
Python code, PDFs and resources for the series of posts on Reinforcement Learning which I published on my personal blog
Stars: ✭ 512 (-21.35%)
Mutual labels:  genetic-algorithm
Artificial Intelligence
Awesome Artificial Intelligence Projects
Stars: ✭ 330 (-49.31%)
Mutual labels:  genetic-algorithm
Fmin
Unconstrained function minimization in Javascript
Stars: ✭ 317 (-51.31%)
Mutual labels:  optimization-algorithms
Curvaturefilter
Curvature Filters are efficient solvers for Variational Models
Stars: ✭ 291 (-55.3%)
Mutual labels:  optimization-algorithms
Jenetics
Jenetics - Genetic Algorithm, Genetic Programming, Evolutionary Algorithm, and Multi-objective Optimization
Stars: ✭ 616 (-5.38%)
Mutual labels:  genetic-algorithm

==== GAFT

A G\ enetic A\ lgorithm F\ ramework in py\ T\ hon

.. image:: https://travis-ci.org/PytLab/gaft.svg?branch=master :target: https://travis-ci.org/PytLab/gaft :alt: Build Status

.. image:: https://img.shields.io/codecov/c/github/PytLab/gaft/master.svg :target: https://codecov.io/gh/PytLab/gaft :alt: Codecov

.. image:: https://landscape.io/github/PytLab/gaft/master/landscape.svg?style=flat :target: https://landscape.io/github/PytLab/gaft/master :alt: Code Health

.. image:: https://img.shields.io/badge/python-3.5-green.svg :target: https://www.python.org/downloads/release/python-351/ :alt: platform

.. image:: https://img.shields.io/badge/pypi-v0.5.7-blue.svg :target: https://pypi.python.org/pypi/gaft/ :alt: versions

.. image:: https://readthedocs.org/projects/gaft/badge/?version=latest :target: https://gaft.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

Introduction

GAFT is a general Python Framework for genetic algorithm computation. It provides built-in genetic operators for target optimization and plugin interfaces for users to define your own genetic operators and on-the-fly analysis for algorithm testing.

GAFT is now accelerated using MPI parallelization interfaces. You can run it on your cluster in parallel with MPI environment.

Python Support

GAFT requires Python version 3.x (Python 2.x is not supported).

Installation

  1. Via pip::

    pip install gaft

  2. From source::

    python setup.py install

If you want GAFT to run in MPI env, please install mpi4py explicitly::

pip install mpi4py

See INSTALL.md <https://github.com/PytLab/gaft/blob/master/INSTALL.md>_ for more installation details.

Test

Run unit test::

python setup.py test

Quick start

  1. Importing

.. code-block:: python

    from gaft import GAEngine
    from gaft.components import BinaryIndividual, Population
    from gaft.operators import RouletteWheelSelection, UniformCrossover, FlipBitMutation

    # Analysis plugin base class.
    from gaft.plugin_interfaces.analysis import OnTheFlyAnalysis

2. Define population

.. code-block:: python

indv_template = BinaryIndividual(ranges=[(0, 10)], eps=0.001)
population = Population(indv_template=indv_template, size=50)
population.init()  # Initialize population with individuals.
  1. Create genetic operators

.. code-block:: python

    # Use built-in operators here.
    selection = RouletteWheelSelection()
    crossover = UniformCrossover(pc=0.8, pe=0.5)
    mutation = FlipBitMutation(pm=0.1)

4. Create genetic algorithm engine to run optimization

.. code-block:: python

engine = GAEngine(population=population, selection=selection,
                  crossover=crossover, mutation=mutation,
                  analysis=[FitnessStore])
  1. Define and register fitness function

.. code-block:: python

    @engine.fitness_register
    def fitness(indv):
        x, = indv.solution
        return x + 10*sin(5*x) + 7*cos(4*x)

or if you want to minimize it, you can add a minimization decorator on it

.. code-block:: python

    @engine.fitness_register
    @engine.minimize
    def fitness(indv):
        x, = indv.solution
        return x + 10*sin(5*x) + 7*cos(4*x)

6. Define and register an on-the-fly analysis (optional)

.. code-block:: python

@engine.analysis_register
class ConsoleOutput(OnTheFlyAnalysis):
    master_only = True
    interval = 1
    def register_step(self, g, population, engine):
        best_indv = population.best_indv(engine.fitness)
        msg = 'Generation: {}, best fitness: {:.3f}'.format(g, engine.fmax)
        engine.logger.info(msg)
  1. Run

.. code-block:: python

    if '__main__' == __name__:
        engine.run(ng=100)

8. Evolution curve

.. image:: https://github.com/PytLab/gaft/blob/master/examples/ex01/envolution_curve.png

  1. Optimization animation

.. image:: https://github.com/PytLab/gaft/blob/master/examples/ex01/animation.gif

See `example 01 <https://github.com/PytLab/gaft/blob/master/examples/ex01/ex01.py>`_ for a one-dimension search for the global maximum of function `f(x) = x + 10sin(5x) + 7cos(4x)`

Global maximum search for binary function
-----------------------------------------

.. image:: https://github.com/PytLab/gaft/blob/master/examples/ex02/surface_animation.gif

See `example 02 <https://github.com/PytLab/gaft/blob/master/examples/ex02/ex02.py>`_ for a two-dimension search for the global maximum of function `f(x, y) = y*sin(2*pi*x) + x*cos(2*pi*y)`

Plugins
-------

You can define your own genetic operators for GAFT and run your algorithm test.

The plugin interfaces are defined in `/gaft/plugin_interfaces/ <https://github.com/PytLab/gaft/tree/master/gaft/plugin_interfaces>`_, you can extend the interface class and define your own analysis class or genetic operator class. The `built-in operators <https://github.com/PytLab/gaft/tree/master/gaft/operators>`_ and `built-in on-the-fly analysis <https://github.com/PytLab/gaft/tree/master/gaft/analysis>`_ can be treated as an official example for plugins development.

Blogs(Chinese Simplified)
-------------------------
- `GAFT-一个使用Python实现的遗传算法框架 <http://pytlab.github.io/2017/07/23/gaft-%E4%B8%80%E4%B8%AA%E5%9F%BA%E4%BA%8EPython%E7%9A%84%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95%E6%A1%86%E6%9E%B6/>`_

- `使用MPI并行化遗传算法框架GAFT <http://pytlab.github.io/2017/08/02/%E4%BD%BF%E7%94%A8MPI%E5%B9%B6%E8%A1%8C%E5%8C%96%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95/>`_

- `遗传算法中几种不同选择算子的比较 <http://pytlab.github.io/2017/09/19/%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95%E4%B8%AD%E5%87%A0%E7%A7%8D%E4%B8%8D%E5%90%8C%E9%80%89%E6%8B%A9%E7%AE%97%E5%AD%90%E7%9A%84%E6%AF%94%E8%BE%83/>`_

- `遗传算法中适值函数的标定与大变异算法 <http://pytlab.github.io/2017/09/23/%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95%E4%B8%AD%E9%80%82%E5%80%BC%E5%87%BD%E6%95%B0%E7%9A%84%E6%A0%87%E5%AE%9A%E4%B8%8E%E5%A4%A7%E5%8F%98%E5%BC%82%E7%AE%97%E6%B3%95/>`_

- `遗传算法框架GAFT优化小记 <http://pytlab.github.io/2017/10/08/%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95%E6%A1%86%E6%9E%B6GAFT%E4%BC%98%E5%8C%96%E5%B0%8F%E8%AE%B0/>`_

- `机器学习算法实践-Platt SMO和遗传算法优化SVM <http://pytlab.github.io/2017/10/15/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E7%AE%97%E6%B3%95%E5%AE%9E%E8%B7%B5-Platt-SMO%E5%92%8C%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95%E4%BC%98%E5%8C%96SVM/>`_

- `遗传算法框架GAFT已支持自定义个体编码方式 <http://pytlab.github.io/2018/03/07/%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95%E6%A1%86%E6%9E%B6GAFT%E6%94%AF%E6%8C%81%E8%87%AA%E5%AE%9A%E4%B9%89%E4%B8%AA%E4%BD%93%E7%BC%96%E7%A0%81%E6%96%B9%E5%BC%8F/>`_

TODO
----
1. ✅ Parallelization 
2. ✅ Add more built-in genetic operators with different algorithms
3. 🏃 Add C++ backend(See `GASol <https://github.com/PytLab/GASol>`_)

Obtain a copy
-------------

The GAFT framework is distributed under the GPLv3 license and can be obtained from the GAFT git repository or PyPI 

- https://github.com/PytLab/gaft
- https://pypi.python.org/pypi/gaft/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].