Coder Social home page Coder Social logo

genetic-algorithm's Introduction

Genetic-Algorithm (EA)

In this project, Genetic Algorithm MATLAB code is provided and 3 common problems including: Knapsack, nQueen and TSP have been modeled to being optimized by Genetic algorithm. First, a brief overview of Genetic algorithm is provided as follow:

The genetic algorithm is a search for revelation inspired by Charles Darwin's theory of natural evolution. This algorithm reflects the natural selection process in which people are selected for reproduction with greater fit to form the offspring of the next generation.

(Genetic Algorithm):

pic1

(The concept of natural selection):

The natural selection process begins with selecting the most well-off individuals from the population. These people create a generation that inherits the characteristics of their parents and adds these characteristics to the next generation. If parents are better off, their offspring will be better off than their parents and have a better chance of survival. This process continues to the end, and eventually a generation with the most people is fit.

(Initial population):

This process begins with a set of people called "Population." Each person is a solution to the problem we want to solve. Each person is identified by a set of parameters (variables) called genes. Genes join a string to form a chromosome (solution). In a genetic algorithm, a person's genes are represented using a string in alphabetical order. Normally binary values are used (strings 1 and 0). We assume that genes are encoded in a chromosome.

pic1

(Fitness function):

The Fitness Function determines how well a person fits. In other words, it determines one's ability to compete with others. This function gives each person a point of fit. The likelihood that a person will be selected for reproduction is based on his or her fitness score.

(Selection):

The idea of the selection phase is based on selecting the most suitable people and allowing their genes to pass on to the next generation. Pairs of individuals (parents) are selected based on their fitness scores. People with the highest fit are more likely to choose to reproduce.

(Crossover):

Crossover is the most important phase in the genetic algorithm. For each pair of parents who have amalgamation, a point of intersection is selected at a random point within the genes.

For example, suppose the intersection point in the image below is 3.

pic1

Children are born by exchanging parental genes among themselves to the point of intersection.

pic1

New children are added to the population.

pic1

(Mutation):

In the new generation that is being formed, some of their genes may be mutated with a low probability of accident. This means that some bits in the string can be reversed.

pic1

Mutations are necessary to maintain diversity within the population and prevent premature convergence.

(End):

The genetic algorithm ends if the population becomes convergent, that is, produces a generation that is not very different from its predecessor. In this case, it is said that the genetic algorithm has provided a set of solutions to our problem.

(Description):

The population is stable. When a new generation is formed, people with the least fit die and space is created for the new generation. The sequence of phases is repeated until there are people in each new generation who are better than the previous generation.

genetic-algorithm's People

Contributors

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