#ifdef HAVE_STDLIB_H #include #endif #include #include #include #include #include #include "yagi.h" typedef struct { int parent1,parent2 ; char *gene ; double fitness ; } GeneRecord ; int population_size=0 ; int gene_length=0 ; int elite=1 ; int ramp=0 ; int PRINT=1 ; double MX ; /* double pmutate=0.4 ; double pcross=0.6 ; double psimplex=0.4 ; double ptrans=0.2 ; */ double pmutate=0.1 ; double pcross=0.9 ; double psimplex=0.5 ; double ptrans=0.03 ; extern int errno; GeneRecord *Pop1=NULL,*Pop2=NULL ; void setprobs(double pm,double pc,double ps,double pt) { pmutate=pm ; pcross=pc ; psimplex=ps; ptrans=pt ; } int GA_Free(void) { int a ; if (Pop1!=NULL) { for(a=0 ; a1000)) GA_Error("Bad parameters to Initialise") ; /* Allocate memory for population 1 */ Pop1=(GeneRecord *)calloc(PopSize,sizeof(GeneRecord)) ; /* Mem alloc error */ if (Pop1==NULL) GA_Error((char *)"Memory allocation for population 1") ; /* Blank population array */ for (a=0 ; a0 ; outer--) { moved=0 ; for (inner=0 ; innermaxfit) maxfit=Pop1[a].fitness ; sigma+=Pop1[a].fitness ; } MX=maxfit ; Sort() ; dump_pop1(fd,gen,maxfit,sigma/population_size); for(a=0 ; a