Saturday, 2 April 2011

GA virtual interface

I will use C++ as language to implement the canonical genetic algorithm.

 #include <unistd.h>  
 enum CROSSOVER {  
     SINGLE_POINT,TWO_POINT  
 };  
 class Population{  
     virtual void create (size_t n)=0;  
     virtual void initialize (double complexity = 0.2)=0;  
 };  
 class Target{  
     virtual bool reached (Population * p , double weight = 0.99)=0;  
 };  
 class Fitness{  
     virtual void run (Population * p)=0;  
 };  
 class Breed{  
     virtual void mutate (Population &p, int odds=1)=0;  
     virtual void crossover (Population &p, CROSSOVER c = SINGLE_POINT)=0;  
 };  
 class Result{  
     virtual void intermidiate (void)=0;  
     virtual void totalize (void)=0;  
 };  


 For those interested in the link to insert code snippets into your blog here is the link:


No comments:

Post a Comment