Download presentation
Presentation is loading. Please wait.
2
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
3
Components of binary GA in Feature Selection Problem: max R 2 110101 111111 000000 f 1 = 0.60 f 2 = 0.30 f 3 = 0.10 0.6 0.3 0.1 110101 000000 Crossover point 111111 000000 111100 000011 Crossover Selection Population Fitness Selected gene 111111111110 Mutation Selected Population Mutated gene R 2 = Goodness of fit
4
Genetic Operators
12
Traveling Salesman Problem
24
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; //user data to objective function in box double (* fptr) (data*, VECTOR); //function pointer to objective fnctn genotype pop; fptr = Salesman3; MatrixAllocate(&distances, 500, 500); userData(&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); MatrixFree(distances, 500); }
25
double Salesman2(data *a, VECTOR x) { int i, isum=0;double tour= 0, pen1=0, pen2=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) pen1=alpha; getche(); box->penn1=pen1; box->penn2=pen2; return tour + pen1; }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.