Giter Club home page Giter Club logo

genetic-algorithm's Introduction

About

Simple implementation of genetic algorithm for solving n Queens problem.

Evolution process

This project implements genetic algorithm for solving n Queens problem. Code generates random population od declared size where every invidual is represented by list containg row position on the board. One individal represents one setting of queens on the board. For example positions of queens on the picture below are represented as: [5, 10, 8, 1, 3, 9, 7, 2, 0, 6]

solution

Initial population undergoes multiple evolution processes that generates new, stronger population. Every epoch population is corssed-over, creating x new individuals, where x is size of the initial population. Crossovers are created by randomly selecting parents based on their scores - the higher the score, the greater the probability of being selected as a parent for crossover. After that, population of size 2x is randomly mutated with declared chance of being mutated. Then scores are calculated again to select x best performing individuals. This process is repeated by declared number of iterations or unitl the solution is found.

Training visualization

This graph represents training process for solution shown above. training

Benchmark

This graph shows comparision in number of iterations needed to find a solution using genetiv algorithm vs randomly selecting population. This benchmark has been created for population of size 10 and board size of 10. For both, random search and genetic algorithm there were 35 attempts undertaken.

benchmark

genetic-algorithm's People

Contributors

wsobanski avatar

Watchers

 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.