#include #include #include #include #include #include //#include #define SWARM_SIZE 50 #define SWARMTIME 1000 #define DEG 5 /*Actualy degree-1*/ #define POINT_NUM 4 #define SAMPLE_SIZE 50 #define ITERATIONS 100000 /*The Precision*/ #define PREC 64 //The co-efficents for the polynomials mpf_t RAND_COEFS[SAMPLE_SIZE][DEG]; //The evaluation of their integrals mpf_t RAND_AVES[SAMPLE_SIZE]; //Running fittness of each swarm member mpf_t SWARM_FIT[SWARM_SIZE]; //Evaluation co-ordinates for each swarm member mpf_t SWARM_POP[SWARM_SIZE][POINT_NUM]; mpf_t VAL,TEMP1,TEMP2,TEMP3; mpf_t THE_BEST; mpf_t BEST_POINT[POINT_NUM]; mpf_t WINDOW_SIZE; void cnt(int sig) { mpf_div_ui(WINDOW_SIZE,WINDOW_SIZE,2); printf("\n"); mpf_out_str(NULL,10,10,WINDOW_SIZE); printf("\n"); } //Get the fittest member of SWARM_POP, swap him to SWARM_POP[0] void findFittest() { int i,index; mpf_set_d(VAL,0.0); index=0; for(i=1;i0) { mpf_set(THE_BEST,SWARM_FIT[0]); bestCount=0; } if(bestCount>20) {cnt(1); bestCount=0;} } printf("Best Points:\n"); for(i=0;i