00001 #ifndef GLBREEDERSTANDARD_H_ 00002 #define GLBREEDERSTANDARD_H_ 00003 00004 #include "GLBaseBreeder.h" 00005 #include "GLBaseParameters.h" 00006 #include "GLLogicError.h" 00007 00008 class GLBaseEvaluator; 00009 class GLBaseGeneticAlgorithm; 00010 class GLBaseRanker; 00023 class GLBreederStandard: public GLBaseBreeder 00024 { 00025 public: 00026 class TParameters; 00038 GLBreederStandard(GLBaseCrossover *crossover, 00039 GLBreederStandard::TParameters* parameters, 00040 GLBaseGeneticAlgorithm *parent_ga); 00044 virtual ~GLBreederStandard(); 00045 00062 virtual int breedOrganisms(GLBasePopulation* population, 00063 GLBaseOrganismStorage* potential_parents, 00064 GLBaseOrganismStorage* offsprings, 00065 GLConstants::TStorageFilling fill = 00066 GLConstants::APPEND, 00067 GLConstants::TTwinsFlags twins = 00068 GLConstants::NO_TWINS, 00069 int size_limits = -1); 00070 public: 00075 struct TParameters:public GLBaseParameters 00076 { 00082 TParameters(double breeding_probability) 00083 { 00084 //check, that the breeding probability is within the limits. 00085 if ((breeding_probability < 0) || (breeding_probability > 1)) 00086 { 00087 char errormsg[1000]; 00088 sprintf(errormsg, "\nGLBreederStandard::TParameters::TParameters\n" 00089 "Parameter breeding_probability (= %e) should " 00090 "be in interval [0; 1]", 00091 breeding_probability); 00092 throw GLLogicError(errormsg); 00093 } 00094 t_breeding_probability = breeding_probability; 00095 }//constructor 00096 00099 TParameters(const TParameters *source) 00100 { 00101 t_breeding_probability = source->t_breeding_probability; 00102 }//constructor 00103 00108 virtual GLBaseParameters* copy() const 00109 { return new TParameters(this); } 00110 00112 double t_breeding_probability; 00113 }; 00114 private: 00115 //probability of applying crossover to any pair 00116 //organisms which will be considered. 00117 double m_breeding_probability; 00118 GLBaseGeneticAlgorithm *m_parent_ga; 00119 }; 00120 00121 #endif /* GLBREEDERSTANDARD_H_ */