GA Applications Peaks function C code GOAT package

  • Slides: 25
Download presentation

GA Applications • Peaks function C- code GOAT package for MATLAB minimization and maximization

GA Applications • Peaks function C- code GOAT package for MATLAB minimization and maximization • Traveling Salesman Problem genotype and phenotype encoding customizing operators rank scaling • Hillis Sorting Problem • Sequence Alignment • Floating point GAs • Constraint optimization • Multi-objective optimization • The schemata theorem

Components of binary GA in Feature Selection R 2 = Goodness of fit Problem:

Components of binary GA in Feature Selection R 2 = Goodness of fit Problem: max R 2 Population 110101 111111 000000 Fitness f 1 = 0. 60 f 2 = 0. 30 f 3 = 0. 10 0. 1 0. 3 0. 6 Selection Crossover point 111111 000000 Crossover Selected gene 11111100 000011 Mutated gene Mutation 111110 Selected Population 110101 000000

Genetic Operators • Uniform Crossover Parent 1 5 24 131 534 603 Parent 2

Genetic Operators • Uniform Crossover Parent 1 5 24 131 534 603 Parent 2 19 33 255 334 508 Child 1 19 33 131 534 603 Child 2 5 24 255 334 508 • Mutation Parent 5 24 131 534 603 Child 5 24 344 534 603

Traveling Salesman Problem

Traveling Salesman Problem

void main(int argc, char *argv[]) {char mombassa[80], root[80]; data b; double alpha, beta; //user

void main(int argc, char *argv[]) {char mombassa[80], root[80]; data b; double alpha, beta; //user data int num_cities; MATRIX distances; Container box; double (* fptr) (data*, VECTOR); genotype pop; //user data to objective function in box //function pointer to objective fnctn fptr = Salesman 3; Matrix. Allocate(&distances, 500); user. Data(&b, &box); // tells pointer of userdata in data struct for b Read_User_Data(&alpha, &beta, &num_cities, distances); box. pop = &pop; box. alpha = alpha; box. beta = beta; box. num_cities = num_cities; box. distances = distances; if (argc == 2) strcpy( mombassa, argv[1]); Allocate_GA(&pop, &b, argc, mombassa, root, fptr); b. print_flag=0; Loop_GA(&b, &pop, root, fptr); Write_User_Data(&b, &pop, root, fptr); De_Allocate_GA(&pop, &b, root, fptr); Matrix. Free(distances, 500); }

double Salesman 2(data *a, VECTOR x) { int i, isum=0; double tour= 0, pen

double Salesman 2(data *a, VECTOR x) { int i, isum=0; double tour= 0, pen 1=0, pen 2=0; double alpha, beta; int num_cities, one, two, help; Container * box = (Container *)(a->ud); alpha = box->alpha; beta = box->beta; num_cities = box->num_cities; help = num_cities/2*(num_cities-1); if (num_cities%2 == 1) help = help+num_cities%2; for (i = 0; i < num_cities-1; i++) { one = (int) x[i]; two = (int) x[i+1]; tour = tour + box->distances[one][two]; } one = (int) x[num_cities-1]; two = (int) x[0]; tour = tour + box->distances[one][two]; for (i = 0; i < num_cities; i++) isum += (int) x[i]; if (isum!=help) pen 1=alpha; getche(); box->penn 1=pen 1; box->penn 2=pen 2; return tour + pen 1; }