00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freESCMAMutation_h
00023 #define __freESCMAMutation_h
00024
00025 #include "freESMutationBase.h"
00026 #include "freESParentSelectorBase.h"
00027 #include "freESRecombinatorBase.h"
00028
00029 #include "itkNormalVariateGenerator.h"
00030
00031 #include "vnl/vnl_vector.h"
00032 #include "vnl/vnl_matrix.h"
00033
00034 namespace FREE
00035 {
00036 namespace ES
00037 {
00038
00060 template <class TIndividual>
00061 class ITK_EXPORT CMAMutation:
00062 public MutationBase<TIndividual>
00063 {
00064 public:
00066 typedef CMAMutation<TIndividual> Self ;
00067 typedef MutationBase<TIndividual> Superclass;
00068 typedef itk::SmartPointer<Self> Pointer;
00069 typedef itk::SmartPointer<const Self> ConstPointer;
00070
00072 itkNewMacro(Self);
00073
00075 itkTypeMacro(CMAMutation, MutationBase);
00076
00077 typedef typename Superclass::IndividualType IndividualType;
00078 typedef typename IndividualType::Pointer IndividualPointer;
00079 typedef typename Superclass::PopulationType PopulationType;
00080 typedef typename PopulationType::Pointer PopulationPointer;
00081
00082 typedef vnl_matrix<double> MatrixType;
00083 typedef vnl_vector<double> VectorType;
00084
00085 void RegisterStrategicPopulationParameters(PopulationType& population) const;
00086 void MutateStrategicPopulationParameters(PopulationType& population) const;
00087
00088 double MutateValue(const double& value);
00089
00100 void InitializeControlValues_Mean(const long& lN);
00101
00115 void InitializeControlValues_Hansen(const long& lMu, const long& lN);
00116
00117 itkSetMacro( Sigma, double );
00118 itkGetMacro( Sigma, double );
00119
00120 itkGetMacro( Mu, long );
00121
00122 itkSetMacro( Mu_eff, double );
00123 itkGetMacro( Mu_eff, double );
00124
00125 itkSetMacro( Mu_cov, double );
00126 itkGetMacro( Mu_cov, double );
00127
00128 itkSetMacro( C_c, double );
00129 itkGetMacro( C_c, double );
00130
00131 itkSetMacro( C_cov, double );
00132 itkGetMacro( C_cov, double );
00133
00134 itkSetMacro( C_sigma, double );
00135 itkGetMacro( C_sigma, double );
00136
00137 itkSetMacro( D_sigma, double );
00138 itkGetMacro( D_sigma, double );
00139
00140 itkGetConstReferenceMacro(CurMatrix,MatrixType);
00141 itkGetConstReferenceMacro(CurCentroid,VectorType);
00142 itkGetConstReferenceMacro(CurMatrixPath,VectorType);
00143 itkGetConstReferenceMacro(CurStepPath,VectorType);
00144 itkGetConstReferenceMacro(CurStepLength,double);
00145
00147 typedef ParentSelectorBase<TIndividual> SearchPointSelectorType;
00148 typedef typename SearchPointSelectorType::Pointer SearchPointSelectorPointer;
00149 typedef RecombinatorBase<TIndividual> CentroidCombinatorType;
00150 typedef typename CentroidCombinatorType::Pointer CentroidCombinatorPointer;
00151
00152 virtual void SetCentroidCombinator( CentroidCombinatorType * pCentroidCombinator );
00153 itkGetConstObjectMacro( CentroidCombinator, CentroidCombinatorType );
00154 itkGetObjectMacro( CentroidCombinator, CentroidCombinatorType );
00155
00156 virtual void SetSearchPointSelector( SearchPointSelectorType * pSearchPointSelector );
00157 itkGetConstObjectMacro( SearchPointSelector, SearchPointSelectorType );
00158 itkGetObjectMacro( SearchPointSelector, SearchPointSelectorType );
00159
00161 typedef itk::Statistics::NormalVariateGenerator VariateGeneratorType ;
00162 VariateGeneratorType& GetRandomGenerator() {return *(m_RandomGenerator.GetPointer());};
00163
00164 protected:
00165 CMAMutation() ;
00166
00168 double m_Sigma;
00169
00174 double m_Mu_cov;
00175
00178 double m_Mu_eff;
00179
00181 double m_C_c;
00182
00184 double m_C_cov;
00185
00187 double m_C_sigma;
00188
00190 double m_D_sigma;
00191
00192 void MutateObjectivParameters(IndividualType* pIndividual, PopulationType* pPopulation) const;
00193
00194 typedef typename PopulationType::StrategicParametersType PopulationStrategicParametersType;
00195
00196
00197
00198
00199
00200
00201 void ConvertStrategicPopulationParametersToMember(PopulationStrategicParametersType& parameters) const;
00202
00203
00204
00205
00206
00207 void ConvertMemberToStrategicPopulationParameters(PopulationStrategicParametersType& parameters) const;
00208
00209 VectorType ComputeCentroid(PopulationType& rPopulation) const;
00210 VectorType ComputeMatrixPath(const VectorType& curMatrixPath, double curStepLength, const VectorType& curCentroid, const VectorType& nextCentroid) const;
00211 MatrixType ComputeMatrix(const MatrixType& curMatrix, const VectorType& nextMatrixPath, double curStepLength, const VectorType& curCentroid, const PopulationType& population) const;
00212 VectorType ComputeStepPath(const VectorType& curStepPath,const MatrixType& curMatrix, double curStepLength, const VectorType& curCentroid, const VectorType& nextCentroid) const;
00213 double ComputeStepLength(double curStepLength, const VectorType& nextStepPath) const;
00214 VectorType GetRandomVector(unsigned long lSize) const;
00215
00216 VectorType ConvertObjectivParameterToVector(const IndividualType* pIndividual) const;
00217 private:
00218 CMAMutation(Self const&);
00219
00222 mutable long m_Mu;
00223
00226 mutable MatrixType m_CurMatrix;
00228 mutable VectorType m_CurCentroid;
00231 mutable VectorType m_CurMatrixPath;
00234 mutable VectorType m_CurStepPath;
00238 mutable double m_CurStepLength;
00239
00244 mutable unsigned long m_ObjectiveCount;
00245
00246 SearchPointSelectorPointer m_SearchPointSelector;
00247 CentroidCombinatorPointer m_CentroidCombinator;
00248
00249
00250 VariateGeneratorType::Pointer m_RandomGenerator;
00251 } ;
00252
00253 }
00254 }
00255
00256
00257 #ifndef ITK_MANUAL_INSTANTIATION
00258 #include "freESCMAMutation.txx"
00259 #endif
00260
00261 #endif