00001 // EvolutionStrategy.h: interface for the CEvolutionStrategy class. 00002 // 00004 00005 #if !defined(AFX_EVOLUTIONSTRATEGY_H__CA201537_5E8F_44BF_8F51_87D452D0BB82__INCLUDED_) 00006 #define AFX_EVOLUTIONSTRATEGY_H__CA201537_5E8F_44BF_8F51_87D452D0BB82__INCLUDED_ 00007 00008 #if _MSC_VER > 1000 00009 #pragma once 00010 #endif // _MSC_VER > 1000 00011 00012 //#ifndef _WIN32 00013 //using namespace std; 00014 //#endif 00015 00016 #include "Minimizer.h" 00017 #include "Rand.h" 00018 #include "typedefs.h" 00019 #include "ParameterFilter.h" 00020 #include "EvolutionStrategyChromosome.h" 00021 using namespace std; 00022 00023 class CEvolutionStrategy : public Minimizer 00024 { 00025 public: 00026 CEvolutionStrategy(CParameterFilter *pFilter); 00027 CEvolutionStrategy(CParameterFilter *pFilter, int mu, int rho, int lambda, int nGenerations, int seed); 00028 virtual ~CEvolutionStrategy(); 00029 // allocates memory and sets algorithm-specific parameters 00030 virtual void InitializePopulation(double *parameters) = 0; 00031 // performs the minimization 00032 double Minimize(double *parameters, Minimizable *minimizable); 00033 // selects rho parents from the population to form one offspring 00034 virtual void SelectParents() = 0; 00035 // mutates object and strategy parameters for one offspring 00036 virtual void Mutation(int whichOffspring) = 0; 00037 // recombines object and strategy parameters for one offspring 00038 virtual void Recombination(int whichOffspring) = 0; 00039 // performs selection on the offspring to form a new population 00040 virtual void Select() = 0; 00041 // evaluates the cost for one offspring 00042 double EvaluateOffspring(Minimizable *minimizable, int whichOffspring); 00043 protected: 00044 std::vector<CEvolutionStrategyChromosome *> m_vpPopulation; 00045 std::vector<CEvolutionStrategyChromosome *> m_vpOffspring; 00046 // size of population 00047 int m_iMu; 00048 // number of parents involved in production of one offspring 00049 int m_iRho; 00050 // size of offspring pool subject to selection 00051 int m_iLambda; 00052 // number of strategy parameters 00053 int m_iNStrategyParameters; 00054 // number of generations over which to run the algorithm 00055 int m_iNGenerations; 00056 // random number generator 00057 Rand *m_pRNG; 00058 // filter for parameters 00059 CParameterFilter *m_pFilter; 00060 // cost statistics 00061 double m_dAvgCost; 00062 // list of parent indices for offspring production 00063 intVector m_viParents; 00064 }; 00065 00066 #endif // !defined(AFX_EVOLUTIONSTRATEGY_H__CA201537_5E8F_44BF_8F51_87D452D0BB82__INCLUDED_)