/* C code for the H-IFF GA test function. This version does not include the resource-based fitness sharing. If this is useful to you please let me know and I can forward anything else you need/ answer any questions you might have. I would be interested to know if you end-up using it in your work - please send me an email. Have fun. love, Richard. richardw@cs.brandeis.edu www.cs.brandeis.edu/~richardw */ /*============ HIFF test function and test examples ===========*/ /* compile line: cc -o testhiff hiff_func.c -lm */ #include #include #include #define NUMGENES 16 /* must equal K^P */ #define K 2 /* sub-blocks per block */ #define P 4 /* num of hierarchical levels eg N=16 so P=4 */ #define Rc 2 /* ratio of block contributions - originally 2 */ #define NONVALUE -1 /* null value for transform function (usually shown as "-") */ #define SHUFFLE 0 /* 0-ordinary HIFF, 1-shuffled HIFF */ /*=============================================================*/ double H(double *genes); double f(double b); double t(double* block, int first); void printme(); void make_shuffle(); int random_index(); void init_random(); /*================ a few test examples ========================*/ double testme[NUMGENES]; int order[NUMGENES]; main(){ int i; init_random(); make_shuffle(); for(i=0;i