Code Monkey home page Code Monkey logo

n-queen-problem-using-genetic-algorithm's Introduction

N-Queen problem using Genetic Algorithm

Solving N-Queen problem using Genetic Algorithm

The aim of N-Queens Problem is to place N queens on an N x N chessboard, in a way so that no queen is in conflict with the others.

Terminology

  • Gene: An individual is characterized by a set of variables
  • Chromosome: Genes are joined into a string to form a Chromosome (solution). A chromosome is a set of parameters which define a proposed solution to the problem that the genetic algorithm is trying to solve
  • Population: The set of all solutions
  • Fitness Function: Pairs of non-attacking queens (say for N=6, Fmax= 6C2 = 6*5/2 = 15)
  • Crossover: Also called recombination, is a genetic operator used to combine the genetic information of two parents to generate new offspring
  • Mutation: It alters one or more gene values in a chromosome from its initial state

How the genetic algorithm solves the n-queen problem?

  • Step 1: A random chromosome is generated
  • Step 2: Fitness value of the chromosome is calculated
  • Step 3: If fitness is not equal to Fmax
  • Step 4: Reproduce (crossover) new chromosome from 2 randomly selected best chromosomes
  • Step 5: Mutation may take place
  • Step 6: New chromosome added to population
  • Repeat Step 2 to 6 until a chromosome (solution) with Fitness value = Fmax is found

Note

Since most of the process is random, it doesn't always take the same time to converge to a solution. If you want to dig deep, watch this.

n-queen-problem-using-genetic-algorithm's People

Contributors

waqqasiq 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.