ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkGradientDescentOptimizerv4.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkGradientDescentOptimizerv4_h
00019 #define __itkGradientDescentOptimizerv4_h
00020 
00021 #include "itkGradientDescentOptimizerBasev4.h"
00022 #include "itkOptimizerParameterScalesEstimator.h"
00023 #include "itkWindowConvergenceMonitoringFunction.h"
00024 
00025 namespace itk
00026 {
00079 class ITK_EXPORT GradientDescentOptimizerv4
00080   : public GradientDescentOptimizerBasev4
00081 {
00082 public:
00084   typedef GradientDescentOptimizerv4     Self;
00085   typedef GradientDescentOptimizerBasev4 Superclass;
00086   typedef SmartPointer< Self >           Pointer;
00087   typedef SmartPointer< const Self >     ConstPointer;
00088 
00090   itkTypeMacro(GradientDescentOptimizerv4, GradientDescentOptimizerBasev4);
00091 
00093   itkNewMacro(Self);
00094 
00096   typedef Superclass::DerivativeType      DerivativeType;
00097 
00099   typedef Superclass::MeasureType                  MeasureType;
00100   typedef Superclass::InternalComputationValueType InternalComputationValueType;
00101 
00103   typedef itk::Function::WindowConvergenceMonitoringFunction<double>
00104     ConvergenceMonitoringType;
00105 
00107   itkSetMacro(LearningRate, InternalComputationValueType);
00108 
00110   itkGetConstReferenceMacro(LearningRate, InternalComputationValueType);
00111 
00118   itkSetMacro(MaximumStepSizeInPhysicalUnits, InternalComputationValueType);
00119 
00121   itkGetConstReferenceMacro(MaximumStepSizeInPhysicalUnits, InternalComputationValueType);
00122 
00132   itkSetObjectMacro(ScalesEstimator, OptimizerParameterScalesEstimator);
00133 
00138   itkSetMacro(DoEstimateScales, bool);
00139   itkGetConstReferenceMacro(DoEstimateScales, bool);
00140   itkBooleanMacro(DoEstimateScales);
00142 
00150   itkSetMacro(DoEstimateLearningRateAtEachIteration, bool);
00151   itkGetConstReferenceMacro(DoEstimateLearningRateAtEachIteration, bool);
00152   itkBooleanMacro(DoEstimateLearningRateAtEachIteration);
00154 
00162   itkSetMacro(DoEstimateLearningRateOnce, bool);
00163   itkGetConstReferenceMacro(DoEstimateLearningRateOnce, bool);
00164   itkBooleanMacro(DoEstimateLearningRateOnce);
00166 
00176   itkSetMacro(MinimumConvergenceValue, InternalComputationValueType);
00177 
00186   itkSetMacro(ConvergenceWindowSize, SizeValueType);
00187 
00189   itkGetConstReferenceMacro( ConvergenceValue, InternalComputationValueType );
00190 
00192   virtual void StartOptimization();
00193 
00196   virtual void ResumeOptimization();
00197 
00198 protected:
00199 
00202   virtual void AdvanceOneStep(void);
00203 
00205   virtual void ModifyGradientByScalesOverSubRange( const IndexRangeType& subrange );
00206   virtual void ModifyGradientByLearningRateOverSubRange( const IndexRangeType& subrange );
00208 
00212   InternalComputationValueType  m_LearningRate;
00213 
00217   InternalComputationValueType  m_MaximumStepSizeInPhysicalUnits;
00218 
00220   virtual void EstimateLearningRate();
00221 
00223   GradientDescentOptimizerv4();
00224 
00226   virtual ~GradientDescentOptimizerv4();
00227 
00228   virtual void PrintSelf( std::ostream & os, Indent indent ) const;
00229 
00230   OptimizerParameterScalesEstimator::Pointer m_ScalesEstimator;
00231 
00237   InternalComputationValueType m_MinimumConvergenceValue;
00238 
00243   SizeValueType m_ConvergenceWindowSize;
00244 
00246   InternalComputationValueType m_ConvergenceValue;
00247 
00249   ConvergenceMonitoringType::Pointer m_ConvergenceMonitoring;
00250 
00251 private:
00255   bool m_DoEstimateScales;
00256 
00260   bool m_DoEstimateLearningRateAtEachIteration;
00261 
00265   bool m_DoEstimateLearningRateOnce;
00266 
00267   GradientDescentOptimizerv4( const Self & ); //purposely not implemented
00268   void operator=( const Self& ); //purposely not implemented
00269 };
00270 
00271 } // end namespace itk
00272 
00273 #endif
00274