I quote below a personal portable implementation (in C++) of a classic genetic algorithm (evolutionary algorithm) used to maximize the function f(x) = sin(x) in the domain 0 <= x <= 2pi. You can compile the program with the g++ compiler.

The Genetic Algorithm implements the following features:

  1. Monoparametric optimization problem (with continuous parameter)
  2. Binary encoded genotypes (with integers)
  3. Genotypes of only one chromosome
  4. Number of iterations as the termination criterion
  5. Elitism by cloning of the best individuals
  6. Roulette wheel method for the selection of parents
  7. Generational replacement of parents and children
  8. One-point crossover and cloning of parents
  9. Deterministic method of mutation (probability of mutation per bit)
  10. Use of the climbing operator “phenotype mutation”

For more information you can get the project itself: