Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __cmtkOptimizer_h_included_
00034 #define __cmtkOptimizer_h_included_
00035
00036 #include <cmtkconfig.h>
00037
00038 #include <Registration/cmtkOptimizerBase.h>
00039 #include <Registration/cmtkRegistrationCallback.h>
00040
00041 #include <Base/cmtkMacros.h>
00042 #include <Base/cmtkFunctional.h>
00043 #include <Base/cmtkVector.h>
00044
00045 #include <System/cmtkSmartPtr.h>
00046
00047 #include <vector>
00048
00049 namespace
00050 cmtk
00051 {
00052
00055
00057 class Optimizer :
00059 public OptimizerBase
00060 {
00061 public:
00063 typedef Optimizer Self;
00064
00066 typedef OptimizerBase Superclass;
00067
00069 typedef SmartPointer<Self> SmartPtr;
00070
00078 cmtkGetSetMacro(bool,UpdateStepScaleVector);
00079
00084 cmtkGetSetMacro(RegistrationCallback::SmartPtr,Callback);
00085
00088 cmtkGetSetMacro(Functional::SmartPtr,Functional);
00089
00091 virtual void SetDeltaFThreshold( const Self::ReturnType value )
00092 {
00093 this->m_DeltaFThreshold = value;
00094 }
00095
00097 virtual CallbackResult CallbackExecuteWithData( const CoordinateVector &v, const Self::ReturnType metric )
00098 {
00099 if ( m_Callback )
00100 return m_Callback->ExecuteWithData( v, metric );
00101 return CALLBACK_OK;
00102 }
00103
00105 virtual CallbackResult CallbackExecute()
00106 {
00107 if ( m_Callback )
00108 m_Callback->Execute();
00109 return CALLBACK_OK;
00110 }
00111
00113 virtual void CallbackComment ( const char* comment = NULL )
00114 {
00115 if ( m_Callback )
00116 m_Callback->Comment( comment );
00117 }
00118
00120 virtual unsigned int GetSearchSpaceDimension() const
00121 {
00122 return this->m_Functional->VariableParamVectorDim();
00123 }
00124
00126 virtual Self::ParameterType GetParamStep( unsigned int idx, const Self::ParameterType mmStep = 1.0 ) const
00127 {
00128 return this->m_Functional->GetParamStep( idx, mmStep );
00129 }
00130
00132 virtual Self::ReturnType Evaluate ( CoordinateVector& v )
00133 {
00134 return this->m_Functional->EvaluateAt( v );
00135 }
00136
00138 virtual Self::ReturnType EvaluateWithGradient( CoordinateVector& v, CoordinateVector& directionVector, const Self::ParameterType step = 1 )
00139 {
00140 return this->m_Functional->EvaluateWithGradient( v, directionVector, step );
00141 }
00142
00144 Optimizer()
00145 : m_Callback( NULL ),
00146 m_Functional( NULL ),
00147 m_DeltaFThreshold( 0.0 )
00148 {
00149 this->m_UpdateStepScaleVector = false;
00150 }
00151
00153 virtual ~Optimizer () {}
00154
00156 virtual CallbackResult Optimize( CoordinateVector&, const Self::ParameterType = 1, const Self::ParameterType = 0 ) = 0;
00157
00159 bool GetLastOptimizeChangedParameters() const
00160 {
00161 return this->m_LastOptimizeChangedParameters;
00162 }
00163
00164 protected:
00166 bool m_LastOptimizeChangedParameters;
00167
00172 Self::ReturnType m_DeltaFThreshold;
00173 };
00174
00176
00177 }
00178
00179 #endif // #ifdef __cmtkOptimizer_h_included_