Skip to content

Python implementation for a Genetic Algorithm to solve linear equations.

Notifications You must be signed in to change notification settings

Mou97/genetic-algorithm-equation-solving

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

genetic-algorithm-equation-solving

Python implementation for a Genetic Algorithm to solve linear equations.

The equation a+2b+3c+4d = 30 , this implementation will find the value of a,b,c and d using an evolutionary algorithm.

Steps

Initialization:

randomly initialize the population

Compute the fitness function:

for each vector compute the value of a+2b+3c+4d-30 = 0

Selection:

choose the 3 best chromosomes.

Crossover:

preform crossover between the best 3 chromosomes to generate the new population.

Mutation:

preform mutation according to the following probability: threshold = (1/population size /chromosome length)

additional notes:

  • the algorithm will run until finding the optimal solution.
  • to solve other equations: change line 84
    Equation((1,2,3,4),30)
    

to whatever coefficients or result you want.

About

Python implementation for a Genetic Algorithm to solve linear equations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages