2023-09-23 22:52:21 -05:00
|
|
|
#ifndef GENETIC_ALGORITHM_HPP
|
|
|
|
#define GENETIC_ALGORITHM_HPP
|
|
|
|
|
|
|
|
#define P_c 0.7 //crossover probability (typical val.)
|
|
|
|
#define P_m 0.001 //mutation probability (typical val.)
|
|
|
|
#define N 8 //population size (change to something even)
|
|
|
|
#define L 8 //string length (don't change)
|
2023-09-24 18:17:51 -05:00
|
|
|
#define G 10000 //number of generations (something huge)
|
2023-09-23 22:52:21 -05:00
|
|
|
|
|
|
|
void print_population(unsigned char population_in[]);
|
|
|
|
int get_fitness(unsigned char string_in);
|
|
|
|
void init_population(unsigned char* population);
|
|
|
|
void do_selection(unsigned char* population, int* selected);
|
|
|
|
unsigned char get_mask(int locus_in);
|
|
|
|
void do_crossover(unsigned char* population, int* selected);
|
|
|
|
void do_mutation(unsigned char* population);
|
|
|
|
|
|
|
|
#endif // GENETIC_ALGORITHM_HPP
|
|
|
|
|