Giter Site home page Giter Site logo

gega's Introduction

Generalised Genetic Algorithm (gega)

This package provides a generalised flexible genetic algorithm implementation that can be used to optimise a set of parameters. For an example of applied usage, see the optimisation scripts in the Reinforcement Learning repo ALLAgents that extend the autonomous-learning-library.

Terminology and Genetic Algorithm (GA) Pseudocode:

  1. A "solution" or "individual" is a vector containing all of the parameters to be optimised. Each parameter is called a "gene", where there are N genes
  2. The "Population" is created by randomly creating M solutions, giving the population a size of M rows x N columns
  3. The overridden fitness_function gets called for each solution in the population giving a fitness vector of size Mx1
  4. Two "Parents" get selected using a "Selection Strategy" from the population, creating an 2xN array
  5. An "Offspring" is created by a "Crossover" function of the two parents
  6. The Offspring has a stochastic "Mutation" applied to one or all of it's genes
  7. The overridden fitness_function gets called for the new offspring to get the offspring's fitness value
  8. An "Update Strategy" occurs, whereby the offspring is inserted into the population under certain conditions. e.g. If elitest, the offspring will only replace a solution in the population if it has a better fitness value than one of them
  9. Repeat back to step (4) for desired number of generations

##Package components

  1. The SolutionDescription class - this defines the properties of the parameters/genes to be optimised. i.e. for each gene, what it's valid range is, and what type of mutation to apply to it etc.
  2. the ga module contains self-contained functions for selection strategies, mutation, and update strategies.
  3. the utility module contains useful methods for interacting with numpy arrays needed in typical ga actions
  4. the main GeneticAlgorithm class takes as input a SolutionDescription instance, and internally uses the ga and utility modules to execute the algorithm outlined above

Usage

Clone the repository using:

git clone https://github.com/gordon-frost-hwu/gega.git

Install the local cloned repository as a python module:

cd gega
pip install -e .

gega's People

Contributors

gordon-frost-hwu avatar

Watchers

 avatar

gega's Issues

Crossover does not consider gene allowed range

Population:
[[4.20811472e-05 2.36883931e-02 2.57036134e-01]
[3.02056257e-06 3.46459225e-05 7.20088016e-01]
[6.93548990e-02 8.92521794e-02 1.44878746e-01]
[1.18646553e-04 9.50123547e-04 4.39412184e-01]
[7.34020157e-02 6.22628085e-02 4.02289529e-01]
[1.11607501e-03 9.50123547e-04 4.08666072e-02]
[5.26274885e-02 8.53531517e-06 4.08666072e-02]
[1.18646553e-04 9.50123547e-04 9.72814564e-01]]
Fitness:
[[22534.38485705]
[23341.18681529]
[25147.70456994]
[13895.81044149]
[25079.98252894]
[ 2952.92815302]
[21741.5724174 ]
[20232.27854945]]
Parents:
[[1.18646553e-04 9.50123547e-04 4.39412184e-01]
[5.26274885e-02 8.53531517e-06 4.08666072e-02]]
Child after crossover:
[0.05262749 0.43941218 0.00095012]

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.