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  void SetNumberOfThreads( ThreadIdType numberOfThreads )
131  {
132  this->m_Threader->SetNumberOfThreads( numberOfThreads );
133  }
134 
135 
136  //itkGetConstReferenceMacro( NumberOfThreads, ThreadIdType );
137  itkSetMacro( UseMultiThread, bool );
138 
139  itkSetMacro( UseOpenMP, bool );
140  itkSetMacro( UseEigen, bool );
141 
142 protected:
143 
146  void PrintSelf( std::ostream & os, Indent indent ) const;
147 
149  typedef itk::MultiThreader ThreaderType;
150  typedef ThreaderType::ThreadInfoStruct ThreadInfoType;
151 
152  // made protected so subclass can access
153  double m_Value;
154  DerivativeType m_Gradient;
157 
158  ThreaderType::Pointer m_Threader;
159 
160  bool m_Stop;
161  unsigned long m_NumberOfIterations;
162  unsigned long m_CurrentIteration;
163 
164 private:
165 
166  GradientDescentOptimizer2( const Self & ); // purposely not implemented
167  void operator=( const Self & ); // purposely not implemented
168 
169  // multi-threaded AdvanceOneStep:
172  {
173  ParametersType * t_NewPosition;
174  Self * t_Optimizer;
175  };
176 
179 
181  static ITK_THREAD_RETURN_TYPE AdvanceOneStepThreaderCallback( void * arg );
182 
184  inline void ThreadedAdvanceOneStep( ThreadIdType threadId, ParametersType & newPosition );
185 
186 };
187 
188 } // end namespace itk
189 
190 #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 PrintSelf(std::ostream &os, Indent indent) const
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)


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo