freESCMAMutation.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freESCMAMutation.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
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       /*Extracts the strategic parameters of the population that belong to this
00197        * class and converts them into the member variables m_CovMatrix, m_CurCentroid,
00198        * m_CurPath, m_LastCentroid, m_LastPath.
00199        * \param parameters Parameters of the population that contain the information.
00200        */
00201       void ConvertStrategicPopulationParametersToMember(PopulationStrategicParametersType& parameters) const;
00202       /*Stores the member variables m_CovMatrix, m_CurCentroid, m_CurPath,
00203        * m_LastCentroid, m_LastPath in the strategic parameters of the population.
00204        * bevor storing the members the parameters belonging to the class will be reseted.
00205        * \param parameters Parameters where the information should be stored.
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&); // Purposely not implemented.
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     } ; // end of class
00252 
00253   } // end of namespace ES
00254 } // end of namespace FREE
00255 
00256 
00257 #ifndef ITK_MANUAL_INSTANTIATION
00258 #include "freESCMAMutation.txx"
00259 #endif
00260 
00261 #endif

Generated at Sat Oct 13 15:53:27 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000