Use a genetic algorithm to evolve populations of bit strings.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

58 lines
1.1 KiB

  1. //
  2. #pragma once
  3. //
  4. namespace BitEvolver
  5. {
  6. //
  7. class Breeder
  8. {
  9. //
  10. public:
  11. //
  12. Breeder(std::shared_ptr<class Random> _random);
  13. //
  14. std::shared_ptr<class Chromosome> Breed(
  15. std::shared_ptr<class Chromosome> mama,
  16. std::shared_ptr<class Chromosome> papa,
  17. Enums::CrossoverType crossover_type,
  18. Enums::CrossoverOrder crossover_order,
  19. Enums::CrossoverBounds crossover_bounds,
  20. double crossover_point,
  21. double crossover_point_std,
  22. double mutation_rate
  23. );
  24. //
  25. void Mutate(std::shared_ptr<class Chromosome> chromosome, double mutation_rate);
  26. //
  27. private:
  28. //
  29. std::shared_ptr<class Random> random;
  30. //
  31. int PickRandomCrossoverPoint(
  32. std::shared_ptr<class Chromosome> chromosome,
  33. Enums::CrossoverBounds crossover_bounds,
  34. double crossover_point,
  35. double crossover_point_std
  36. );
  37. void ApplyCrossover(
  38. std::shared_ptr<class Chromosome> kiddo,
  39. std::shared_ptr<class Chromosome> parent,
  40. Enums::CrossoverType crossover_type,
  41. Enums::CrossoverBounds crossover_bounds,
  42. double crossover_point,
  43. double crossover_point_std
  44. );
  45. };
  46. };