freEvolutionaryStrategySOOptimizer.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: freEvolutionaryStrategySOOptimizer.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 __freEvolutionaryStrategySOOptimizer_h
00023 #define __freEvolutionaryStrategySOOptimizer_h
00024 
00025 #include "freSetupOptimizationOptimizer.h"
00026 
00027 #include "freRegistrationObserver.h"
00028 
00029 #include "freItkSingleValuedCostFunctionWrapper.h"
00030 #include "freEvolutionaryStrategyOptimizer.h"
00031 #include "freESControllerInfo.h"
00032 
00033 namespace FREE
00034 {
00035   
00040   class ITK_EXPORT EvolutionaryStrategySOOptimizer : 
00041     public SetupOptimizationOptimizer
00042   {
00043   public:
00045     typedef EvolutionaryStrategySOOptimizer     Self;
00046     typedef SetupOptimizationOptimizer                                                          Superclass;
00047     typedef itk::SmartPointer<Self>                   Pointer;
00048     typedef itk::SmartPointer<const Self>             ConstPointer;
00049 
00051     itkTypeMacro( EvolutionaryStrategySOOptimizer, SetupOptimizationOptimizer );
00052 
00054     itkNewMacro(Self);
00055 
00056     typedef ES::EvolutionaryStrategyOptimizer< ESIndividualType > InternalOptimizerType;
00057     typedef InternalOptimizerType::Pointer InternalOptimizerPointer;
00058 
00059     typedef  InternalOptimizerType::IndividualType            IndividualType;
00060     typedef  InternalOptimizerType::IndividualPointer         IndividualPointer;
00061     typedef  InternalOptimizerType::ObjectiveValueType        ObjectiveValueType;
00062     typedef  InternalOptimizerType::IndividualIDType          IndividualIDType;
00063     typedef  InternalOptimizerType::IndividualSelectionType   IndividualSelectionType;
00064     typedef  InternalOptimizerType::HeritageMapType           HeritageMapType;
00065 
00067     typedef  InternalOptimizerType::PopulationType            PopulationType;
00068     typedef  InternalOptimizerType::PopulationPointer         PopulationPointer;
00069 
00071     typedef  InternalOptimizerType::ParentSelectorType        ParentSelectorType;
00072     typedef  InternalOptimizerType::ParentSelectorPointer     ParentSelectorPointer;
00073 
00075     typedef  InternalOptimizerType::RecombinatorType          RecombinatorType;
00076     typedef  InternalOptimizerType::RecombinatorPointer       RecombinatorPointer;
00077 
00079     typedef  InternalOptimizerType::MutationType              MutationType;
00080     typedef  InternalOptimizerType::MutationPointer           MutationPointer;
00081 
00083     typedef  InternalOptimizerType::SelectionType             SelectionType;
00084     typedef  InternalOptimizerType::SelectionPointer          SelectionPointer;
00085 
00087     void SetMaximize(bool maximize);
00088     bool GetMaximize() const;
00089     void MaximizeOn(void) 
00090     { SetMaximize( true ); }
00091     void MaximizeOff(void) 
00092     { SetMaximize( false ); }
00093     bool GetMinimize( ) const
00094     { return !GetMaximize(); }
00095     void SetMinimize(bool v)
00096     { this->SetMaximize(!v); }
00097     void MinimizeOn(void) 
00098     { SetMaximize( false ); }
00099     void MinimizeOff(void) 
00100     { SetMaximize( true ); }
00101 
00103     void SetMaximumIteration(unsigned int iMaximumIteration);
00104     const unsigned int GetMaximumIteration() const;
00105 
00106     void SetNumberOfParents(unsigned long iNumberOfParents);
00107     const unsigned long GetNumberOfParents() const;
00108 
00109     void SetNumberOfChildren(unsigned long iNumberOfChildren);
00110     const unsigned long GetNumberOfChildren() const;
00111 
00112     void SetMutateIntitialPopulation(bool bMutateIntitialPopulation);
00113     const bool GetMutateIntitialPopulation() const;
00114 
00115     void SetThreshold(ObjectiveValueType threshold);
00116     const ObjectiveValueType GetThreshold() const;
00117 
00118     virtual void SetParentSelector( ParentSelectorType * pParentSelector );
00119     virtual const ParentSelectorType* GetParentSelector() const;
00120     virtual ParentSelectorType* GetParentSelector();
00121 
00122     virtual void SetRecombinator( RecombinatorType * pRecombinator );
00123     virtual const RecombinatorType* GetRecombinator() const;
00124     virtual RecombinatorType* GetRecombinator();
00125 
00126     virtual void SetMutation( MutationType * pMutation );
00127     virtual const MutationType* GetMutation() const;
00128     virtual MutationType* GetMutation();
00129 
00130     virtual void SetSelection( SelectionType * pSelection );
00131     virtual const SelectionType* GetSelection() const;
00132     virtual SelectionType* GetSelection();
00133 
00134     virtual const PopulationType* GetPopulation() const;
00135     virtual PopulationType* GetPopulation();
00136 
00140     const IndividualType* GetBestIndividualEver() const;
00144     const IndividualType* GetBestIndividual() const;
00145 
00154     virtual void Initialize(const PopulationType& population);
00155 
00159     virtual void Initialize();
00160 
00161     virtual void SetCostFunction( CostFunctionType * costFunction );
00162 
00163     virtual void SetInitialPosition (const ParametersType &param);
00164 
00165     virtual void StartOptimization( void );
00166 
00167     virtual bool IsStoppable() const;
00168     virtual void StopOptimization();
00169 
00170     virtual bool IsResumeable() const;
00171     virtual void ResumeOptimization();
00172 
00176     const HeritageMapType& GetRecentParentSelections() const;
00177 
00180     const PopulationPointer& GetRecentPopulationSelections() const;
00182     const PopulationPointer& GetNewChildren() const;
00183 
00186     const IndividualType* GetCurrentChild() const;
00189     IndividualType* GetCurrentChild();
00190 
00191     InternalOptimizerType * GetInternalOptimizer();
00192 
00193     DecomposedMeasureType GetDecomposedIndividualValue(const IndividualIDType& rID);
00194 
00195   protected:
00196     EvolutionaryStrategySOOptimizer();
00197     void PrintSelf(std::ostream& os, itk::Indent indent) const;
00198 
00199     void OnOptIteration(void* pSender, long threadID);
00200     void OnOptStart(void* pSender, long threadID);
00201     void OnOptEnd(void* pSender, long threadID);
00202     void OnChildGen(void* pSender, long threadID);
00203     void OnChildEval(void* pSender, long threadID);
00204 
00205     IterationObserver::Pointer m_IterationObserver;
00206     NotificationEvent<Self>::Pointer m_IterationNotificationEvent;
00207 
00208     typedef RegistrationObserverBase<itk::StartEvent> StartObserver;
00209     StartObserver::Pointer m_StartObserver;
00210     NotificationEvent<Self>::Pointer m_StartNotificationEvent;
00211 
00212     typedef RegistrationObserverBase<itk::EndEvent> EndObserver;
00213     EndObserver::Pointer m_EndObserver;
00214     NotificationEvent<Self>::Pointer m_EndNotificationEvent;
00215 
00216     typedef RegistrationObserverBase<ES::NewChildGenerationEvent> ChildGenerationObserver;
00217     ChildGenerationObserver::Pointer m_ChildGenerationObserver;
00218     NotificationEvent<Self>::Pointer m_ChildGenerationNotificationEvent;
00219 
00220     typedef RegistrationObserverBase<ES::NewChildEvaluationEvent> ChildEvaluationObserver;
00221     ChildEvaluationObserver::Pointer m_ChildEvaluationObserver;
00222     NotificationEvent<Self>::Pointer m_ChildEvaluationNotificationEvent;
00223 
00224     InternalOptimizerPointer m_InternalOptimizer;
00225     ItkSingleValuedCostFunctionWrapper::Pointer m_CostFunctionWrapper;
00226 
00227     typedef  std::map<IndividualIDType,DecomposedMeasureType> IndividualMeasureMapType;
00228     //map containing all decomposed measures of individuals of the last optimization iteration
00229     IndividualMeasureMapType m_MeasureMap;
00230 
00231   private:  
00232     EvolutionaryStrategySOOptimizer(const Self&); //purposely not implemented
00233     void operator=(const Self&);//purposely not implemented
00234   };
00235 
00236 } // end namespace FREE
00237 
00238 #endif
00239     
00240  

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