Skip to content

Plain and clean implementation of a genetic algorithm in C

Notifications You must be signed in to change notification settings

Giebisch/GeneticAlgorithmInC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeneticAlgorithmInC

This is my implementation of a genetic algorithm in C. I've created this out of curiosity, as I've implemented several evolutionary algorithms in Python before, and just wanted to compare the performance of C and Python on a evolutionary algorithm. I also wanted to program in C again, as it is one of the coolest programming languages out there.

The optimization problem

This code currently optimizes the Rosenbrock function with n = 3. The Rosenbrock function is a tough function to optimize, read more about it on Wikipedia. You could also change the double calculate_function(Chromosome chromosome) function to any other Test function for optimization.

Output

The program creates a .txt with average and best fitness values for each generation. See docs/fitness_values.txt for an example. To visualize the progress better, a short python script has been used.

Optimization Plot

About

Plain and clean implementation of a genetic algorithm in C

Topics

Resources

Stars

Watchers

Forks