Git Product home page Git Product logo

mathispeyronne / evolve_swarm_fireflies Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 5.87 MB

New idea: Genetic algorithm which applies it's selective pressure at the level of the group. Details: Each swarm has many fireflies (40), Each firefly is a feed forward neural network (1X16X16X1). The genetic algorithm finds the right coefficient and biases for the fireflies to blink in union(after converging).

License: MIT License

Python 100.00%

evolve_swarm_fireflies's Introduction

Evolve_Swarm_Fireflies

The core idea

A genetic algorithm which applies its selective pressure at the level of the group instead of at the level of the individual like commonly done. Selecting based on an emergent property.

Proof of concept: evolve swarm of fireflies blinking in unison



Context

Each swarm has 40 fireflies and each fireflie has 8 neighbors. Each firefly is a neural network that has 1 input neuron(taking the clock of the neighbor who blinked), two hidden layers of 16 nodes each and 1 output neuron(which gives the update to the internal clock of the firefly).

The fitness/objective function must measure the degree to which the fireflies are blinking in unison. This is done by looking at the standard deviation of the clocks after 500 iterations in the simulation. This score is attributed as the fitness value of that specific swarm.

Proposed method

In order to find the right coefficients and biases for the fireflies to blink in unison, the proposed evolutionary algorithm process is similar to the common one, but it applies its selective pressure at a higher level of aggregation.

  • Draw a pool of swarms, instead of a pool of individual fireflies.
  • Let each swarm live for 500 iterations and then measure how well each swarm managed to get its fireflies blinking in unison. This is the fitness function.
  • Then create the next generation by making the best swarms reproduce more. Add a small mutation rate.
  • And Repeat(for about ~100 generations).

Results

It works :) After 100-150 generations, the best fireflies are very well synchronized together. Diminishing returns kick in after around 80 generations. This evolutionary algorithm has evolved the local rules(which are the right coefficient and biases in our neural networks) in order for a swarm of firefly to converge to the same tempo, pulsating in near-unison. A common fitness value after 100 generations is <2e-4 seconds (cf. fitness function definition above)

Details

  • Written from scratch in Python and Numpy
  • To evolve best swarm: python main.py
  • To animate best swarm: python Animate_best_swarm.py

If you have any further questions, let me know [email protected] :)

evolve_swarm_fireflies's People

Contributors

mathispeyronne avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  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.