ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkGradientDescentOptimizerBasev4.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkGradientDescentOptimizerBasev4_h
19 #define itkGradientDescentOptimizerBasev4_h
20 
24 #include "itkDomainThreader.h"
25 
26 namespace itk
27 {
38 template<typename TInternalComputationValueType>
40  : public ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>
41 {
42 public:
48 
51 
53  typedef enum {
62 
65 
68 
70  typedef TInternalComputationValueType InternalComputationValueType;
71 
74  typedef typename MetricType::Pointer MetricTypePointer;
75 
78 
81 
83 
85 
89 
91  itkGetConstReferenceMacro( Gradient, DerivativeType );
92 
94  itkGetConstReferenceMacro(StopCondition, StopConditionType);
95 
97  virtual void SetNumberOfIterations( const SizeValueType numberOfIterations ) ITK_OVERRIDE
98  {
99  itkDebugMacro("setting NumberOfIterations to " << numberOfIterations );
100  if ( this->m_NumberOfIterations != numberOfIterations)
101  {
102  this->m_NumberOfIterations = numberOfIterations;
103  this->Modified();
104  }
105  }
107 
109  virtual SizeValueType GetNumberOfIterations() const ITK_OVERRIDE
110  {
111  return this->m_NumberOfIterations;
112  }
113 
115  virtual SizeValueType GetCurrentIteration() const ITK_OVERRIDE
116  {
117  return this->m_CurrentIteration;
118  }
119 
121  virtual void StartOptimization( bool doOnlyInitialization = false ) ITK_OVERRIDE;
122 
126  virtual void ResumeOptimization() = 0;
127 
130  virtual void StopOptimization();
131 
133  virtual const StopConditionReturnStringType GetStopConditionDescription() const ITK_OVERRIDE;
134 
147  virtual void ModifyGradientByScales();
148  virtual void ModifyGradientByLearningRate();
150 
152 
158  virtual void ModifyGradientByScalesOverSubRange( const IndexRangeType& subrange ) = 0;
159 
168  virtual void ModifyGradientByLearningRateOverSubRange( const IndexRangeType& subrange ) = 0;
169 
170 protected:
171 
174  virtual ~GradientDescentOptimizerBasev4Template();
176 
181 
186 
193  TInternalComputationValueType m_MaximumStepSizeInPhysicalUnits;
194 
200 
206 
209 
211  typename DomainThreader<ThreadedIndexedContainerPartitioner, Self>::Pointer m_ModifyGradientByLearningRateThreader;
212 
213  /* Common variables for optimization control and reporting */
214  bool m_Stop;
217 
220  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
221 
222 private:
223 
224  GradientDescentOptimizerBasev4Template( const Self & ); //purposely not implemented
225  void operator=( const Self& ); //purposely not implemented
226 
227 };
228 
230 typedef GradientDescentOptimizerBasev4Template<double> GradientDescentOptimizerBasev4;
231 
232 } // end namespace itk
233 
234 #ifndef ITK_MANUAL_INSTANTIATION
235 #include "itkGradientDescentOptimizerBasev4.hxx"
236 #endif
237 
238 #endif
OptimizerParameters< TInternalComputationValueType > ScalesType
Light weight base class for most itk classes.
Superclass::StopConditionDescriptionType StopConditionDescriptionType
Multi-threaded processing on a domain by processing sub-domains per thread.
virtual void ModifyGradientByLearningRateOverSubRange(const IndexRangeType &subrange)=0
Superclass::StopConditionReturnStringType StopConditionReturnStringType
DomainThreader< ThreadedIndexedContainerPartitioner, Self >::Pointer m_ModifyGradientByLearningRateThreader
virtual void PrintSelf(std::ostream &os, Indent indent) const override
virtual SizeValueType GetCurrentIteration() const override
virtual SizeValueType GetNumberOfIterations() const override
unsigned long SizeValueType
Definition: itkIntTypes.h:143
ObjectToObjectMetricBaseTemplate< TInternalComputationValueType > MetricType
virtual void SetNumberOfIterations(const SizeValueType numberOfIterations) override
Class to hold and manage different parameter types used during optimization.
Class which monitors convergence during the course of optimization.
virtual void Modified() const
virtual void StartOptimization(bool doOnlyInitialization=false) override
virtual const StopConditionReturnStringType GetStopConditionDescription() const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void ModifyGradientByScalesOverSubRange(const IndexRangeType &subrange)=0
DomainThreader< ThreadedIndexedContainerPartitioner, Self >::Pointer m_ModifyGradientByScalesThreader
Abstract base for object-to-object optimizers.
ObjectToObjectOptimizerBaseTemplate< TInternalComputationValueType > Superclass
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
itk::Function::WindowConvergenceMonitoringFunction< TInternalComputationValueType > ConvergenceMonitoringType