00001 // QMcBeaver 00002 // 00003 // Constructed by 00004 // 00005 // Michael Todd Feldmann 00006 // and 00007 // David Randall "Chip" Kent IV 00008 // 00009 // Copyright 2000. All rights reserved. 00010 // 00011 // drkent@users.sourceforge.net mtfeldmann@users.sourceforge.net 00012 00013 #ifndef CKGENETICALGORITHM1_H 00014 #define CKGENETICALGORITHM1_H 00015 00016 #include "SortedParameterScorePairList.h" 00017 #include "QMCObjectiveFunction.h" 00018 #include "QMCObjectiveFunctionResult.h" 00019 #include "QMCOptimizationAlgorithm.h" 00020 #include "Random.h" 00021 #include "Stopwatch.h" 00022 00039 class CKGeneticAlgorithm1 : public QMCOptimizationAlgorithm 00040 { 00041 public: 00054 CKGeneticAlgorithm1(QMCObjectiveFunction * function, 00055 int populationsize, 00056 double mutationrate, 00057 double distributionwidth); 00058 00059 Array1D<double> optimize(Array1D<double> & initialGuess, 00060 QMCDerivativeProperties & dp, 00061 double,int); 00062 00063 private: 00064 Stopwatch sw; 00065 00069 QMCObjectiveFunction* OF; 00070 00074 double MutationRate; 00075 00079 int PopulationSize; 00080 00084 double InitialDistributionWidth; 00085 00089 SortedParameterScorePairList Population; 00090 00094 ParameterScorePair BestPopulationMember; 00095 00106 void mutate(Array1D<double>& parameters, double width); 00107 00115 Array1D<double> crossover(Array1D<double> &parent1, 00116 Array1D<double> &parent2); 00117 00131 int selectParent(); 00132 00136 void generateNewPopulation(); 00137 00146 void initializePopulation(Array1D<double> &initialguess); 00147 }; 00148 00149 #endif