Main Page | Data Structures | File List | Data Fields | Globals

/home/kevin/Documents/PYLikeC/mutation.c

Go to the documentation of this file.
00001 #include <math.h>
00002 #include <gsl/gsl_rng.h>
00003 #include <gsl/gsl_randist.h>
00004 #include "pga.h"
00005 
00006 void mutation(struct individual parents[], struct individual children[], int gen, gsl_rng * r)
00007 {
00008    double tau;
00009    double tau_prime;
00010    int i, j;
00011    
00012    tau       = 1.0 / sqrt( 2 * sqrt(NUM_PARAMS));
00013    tau_prime = 1.0 / sqrt( 2 * NUM_PARAMS) * gsl_ran_gaussian(r, 1.0);
00014    for (i = 0; i < NUM_PARAMS; i++)
00015      for (j = 0; j < GEN_SIZE; j++)
00016        {
00017           
00018           children[j].std_dev[i] = parents[j].std_dev[i] * exp(tau_prime + tau * gsl_ran_gaussian(r, 1.0));
00019           children[j].params[i] = parents[j].params[i] + children[j].std_dev[i] * gsl_ran_cauchy(r, 1.0);
00020           children[j].created = gen;
00021           /* Copy fitness for recombination choosiness */
00022           children[j].fitness = parents[j].fitness;
00023          
00024           /*
00025           children[j].std_dev[i] = parents[j].std_dev[i] + parents[j].std_dev[i] * 0.5 * g05ddc(0.0, 1.0);
00026           children[j].params[i] = parents[j].params[i] + children[j].std_dev[i] * g05ddc(0.0, 1.0);
00027           */
00028           if (children[j].params[i] < 0)
00029             children[j].params[i] = 0;
00030        }
00031 }
00032 
00033         

Generated on Thu Mar 3 11:45:32 2005 for spga by  doxygen 1.3.9.1