go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGradientDescentOptimizer2.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
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 __itkGradientDescentOptimizer2_h
19 #define __itkGradientDescentOptimizer2_h
20 
22 #include "itkMultiThreader.h"
23 
24 namespace itk
25 {
26 
55 {
56 public:
57 
62  typedef SmartPointer< const Self > ConstPointer;
63 
65  itkNewMacro( Self );
66 
69 
78 
82  typedef enum {
87 
89  virtual void AdvanceOneStep( void );
90 
92  virtual void StartOptimization( void );
93 
96  virtual void ResumeOptimization( void );
97 
99  virtual void MetricErrorResponse( ExceptionObject & err );
100 
103  virtual void StopOptimization( void );
104 
106  itkSetMacro( LearningRate, double );
107 
109  itkGetConstReferenceMacro( LearningRate, double );
110 
112  itkSetMacro( NumberOfIterations, unsigned long );
113 
115  itkGetConstReferenceMacro( NumberOfIterations, unsigned long );
116 
118  itkGetConstMacro( CurrentIteration, unsigned int );
119 
121  itkGetConstReferenceMacro( Value, double );
122 
124  itkGetConstReferenceMacro( StopCondition, StopConditionType );
125 
127  itkGetConstReferenceMacro( Gradient, DerivativeType );
128 
130  itkGetConstReferenceMacro( SearchDirection, DerivativeType );
131 
133  void SetNumberOfThreads( ThreadIdType numberOfThreads )
134  {
135  this->m_Threader->SetNumberOfThreads( numberOfThreads );
136  }
137 
138 
139  //itkGetConstReferenceMacro( NumberOfThreads, ThreadIdType );
140  itkSetMacro( UseMultiThread, bool );
141  itkSetMacro( UseOpenMP, bool );
142  itkSetMacro( UseEigen, bool );
143 
144 protected:
145 
148  void PrintSelf( std::ostream & os, Indent indent ) const;
149 
151  typedef itk::MultiThreader ThreaderType;
152  typedef ThreaderType::ThreadInfoStruct ThreadInfoType;
153 
154  // made protected so subclass can access
155  double m_Value;
156  DerivativeType m_Gradient;
157  DerivativeType m_SearchDirection;
159  StopConditionType m_StopCondition;
160 
161  ThreaderType::Pointer m_Threader;
162 
163  bool m_Stop;
164  unsigned long m_NumberOfIterations;
165  unsigned long m_CurrentIteration;
166 
167 private:
168 
169  GradientDescentOptimizer2( const Self & ); // purposely not implemented
170  void operator=( const Self & ); // purposely not implemented
171 
172  // multi-threaded AdvanceOneStep:
175  {
176  ParametersType * t_NewPosition;
177  Self * t_Optimizer;
178  };
179 
182 
184  static ITK_THREAD_RETURN_TYPE AdvanceOneStepThreaderCallback( void * arg );
185 
187  inline void ThreadedAdvanceOneStep( ThreadIdType threadId, ParametersType & newPosition );
188 
189 };
190 
191 } // end namespace itk
192 
193 #endif
Implement a gradient descent optimizer.
void operator=(const Self &)
virtual void StartOptimization(void)
ScaledSingleValuedNonLinearOptimizer Superclass
Superclass::DerivativeType DerivativeType
Superclass::ScaledCostFunctionType ScaledCostFunctionType
virtual void StopOptimization(void)
void SetNumberOfThreads(ThreadIdType numberOfThreads)
virtual void AdvanceOneStep(void)
virtual void MetricErrorResponse(ExceptionObject &err)
void ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType &newPosition)
Superclass::ParametersType ParametersType
Superclass::CostFunctionType CostFunctionType
ThreaderType::ThreadInfoStruct ThreadInfoType
virtual void ResumeOptimization(void)
Superclass::ScaledCostFunctionPointer ScaledCostFunctionPointer
static ITK_THREAD_RETURN_TYPE AdvanceOneStepThreaderCallback(void *arg)
void PrintSelf(std::ostream &os, Indent indent) const


Generated on OURCE_DATE_EPOCH for elastix by doxygen 1.8.13 elastix logo