go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxConjugateGradient.h
Go to the documentation of this file.
00001 /*======================================================================
00002 
00003   This file is part of the elastix software.
00004 
00005   Copyright (c) University Medical Center Utrecht. All rights reserved.
00006   See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
00007   details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE. See the above copyright notices for more information.
00012 
00013 ======================================================================*/
00014 
00015 #ifndef __elxConjugateGradient_h
00016 #define __elxConjugateGradient_h
00017 
00018 #include "itkGenericConjugateGradientOptimizer.h"
00019 #include "itkMoreThuenteLineSearchOptimizer.h"
00020 #include "elxIncludes.h"
00021 
00022 namespace elastix
00023 {
00024 using namespace itk;
00025 
00026 
00089   template <class TElastix>
00090     class ConjugateGradient :
00091     public
00092       itk::GenericConjugateGradientOptimizer,
00093     public
00094       OptimizerBase<TElastix>
00095   {
00096   public:
00097 
00099     typedef ConjugateGradient                   Self;
00100     typedef GenericConjugateGradientOptimizer           Superclass1;
00101     typedef OptimizerBase<TElastix>             Superclass2;
00102     typedef SmartPointer<Self>                  Pointer;
00103     typedef SmartPointer<const Self>            ConstPointer;
00104 
00106     itkNewMacro( Self );
00107 
00109     itkTypeMacro( ConjugateGradient, GenericConjugateGradientOptimizer );
00110 
00115     elxClassNameMacro( "ConjugateGradient" );
00116 
00118     typedef Superclass1::CostFunctionType                   CostFunctionType;
00119     typedef Superclass1::CostFunctionPointer                CostFunctionPointer;
00120     typedef Superclass1::StopConditionType                  StopConditionType;
00121     typedef Superclass1::ParametersType                     ParametersType;
00122     typedef Superclass1::DerivativeType                     DerivativeType;
00123     typedef Superclass1::ScalesType                         ScalesType;
00124 
00126     typedef typename Superclass2::ElastixType           ElastixType;
00127     typedef typename Superclass2::ElastixPointer        ElastixPointer;
00128     typedef typename Superclass2::ConfigurationType     ConfigurationType;
00129     typedef typename Superclass2::ConfigurationPointer  ConfigurationPointer;
00130     typedef typename Superclass2::RegistrationType      RegistrationType;
00131     typedef typename Superclass2::RegistrationPointer   RegistrationPointer;
00132     typedef typename Superclass2::ITKBaseType           ITKBaseType;
00133 
00135     typedef MoreThuenteLineSearchOptimizer              LineOptimizerType;
00136     typedef LineOptimizerType::Pointer                  LineOptimizerPointer;
00137     typedef ReceptorMemberCommand<Self>                 EventPassThroughType;
00138     typedef typename EventPassThroughType::Pointer      EventPassThroughPointer;
00139 
00142     virtual void StartOptimization(void);
00143 
00146     virtual void BeforeRegistration(void);
00147     virtual void BeforeEachResolution(void);
00148     virtual void AfterEachResolution(void);
00149     virtual void AfterEachIteration(void);
00150     virtual void AfterRegistration(void);
00151 
00152     itkGetConstMacro(StartLineSearch, bool);
00153 
00154 
00155   protected:
00156 
00157     ConjugateGradient();
00158     virtual ~ConjugateGradient() {};
00159 
00160     LineOptimizerPointer          m_LineOptimizer;
00161 
00163     virtual std::string GetLineSearchStopCondition(void) const;
00164 
00167     virtual std::string DeterminePhase(void) const;
00168 
00172     virtual bool TestConvergence( bool firstLineSearchDone );
00173 
00178     virtual void LineSearch(
00179       const ParametersType searchDir,
00180       double & step,
00181       ParametersType & x,
00182       MeasureType & f,
00183       DerivativeType & g );
00184 
00185   private:
00186 
00187     ConjugateGradient( const Self& ); // purposely not implemented
00188     void operator=( const Self& );              // purposely not implemented
00189 
00190     void InvokeIterationEvent(const EventObject & event);
00191 
00192     EventPassThroughPointer     m_EventPasser;
00193     double                      m_SearchDirectionMagnitude;
00194     bool                        m_StartLineSearch;
00195     bool                        m_GenerateLineSearchIterations;
00196     bool                        m_StopIfWolfeNotSatisfied;
00197     bool                        m_WolfeIsStopCondition;
00198 
00199   }; // end class ConjugateGradient
00200 
00201 
00202 } // end namespace elastix
00203 
00204 #ifndef ITK_MANUAL_INSTANTIATION
00205 #include "elxConjugateGradient.hxx"
00206 #endif
00207 
00208 #endif // end #ifndef __elxConjugateGradient_h
00209 


Generated on 24-05-2012 for elastix by doxygen 1.7.6.1 elastix logo