ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkGradientDescentOptimizer.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 itkGradientDescentOptimizer_h
19 #define itkGradientDescentOptimizer_h
20 
21 #include "itkIntTypes.h"
23 #include "ITKOptimizersExport.h"
24 #include <string>
25 namespace itk
26 {
52 class ITKOptimizers_EXPORT GradientDescentOptimizer:
54 {
55 public:
61 
63  itkNewMacro(Self);
64 
67 
69  typedef enum {
71  MetricError
72  } StopConditionType;
73 
75  itkGetConstReferenceMacro(Maximize, bool);
76  itkSetMacro(Maximize, bool);
77  itkBooleanMacro(Maximize);
78  bool GetMinimize() const
79  { return !m_Maximize; }
80  void SetMinimize(bool v)
81  { this->SetMaximize(!v); }
82  void MinimizeOn()
83  { this->MaximizeOff(); }
84  void MinimizeOff()
85  { this->MaximizeOn(); }
87 
89  virtual void AdvanceOneStep();
90 
92  virtual void StartOptimization(void) ITK_OVERRIDE;
93 
96  void ResumeOptimization();
97 
100  void StopOptimization();
101 
103  itkSetMacro(LearningRate, double);
104 
106  itkGetConstReferenceMacro(LearningRate, double);
107 
109  itkSetMacro(NumberOfIterations, SizeValueType);
110 
112  itkGetConstReferenceMacro(NumberOfIterations, SizeValueType);
113 
115  itkGetConstMacro(CurrentIteration, SizeValueType);
116 
118  itkGetConstReferenceMacro(Value, double);
119 
121  itkGetConstReferenceMacro(StopCondition, StopConditionType);
122  virtual const std::string GetStopConditionDescription() const ITK_OVERRIDE;
124 
126  itkGetConstReferenceMacro(Gradient, DerivativeType);
127 
128 protected:
130  virtual ~GradientDescentOptimizer() {}
131  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
132 
133  // made protected so subclass can access
134  DerivativeType m_Gradient;
135 
137 
139 
140 private:
141  GradientDescentOptimizer(const Self &); //purposely not implemented
142  void operator=(const Self &); //purposely not implemented
143 
144  bool m_Stop;
145  double m_Value;
149  std::ostringstream m_StopConditionDescription;
150 };
151 } // end namespace itk
152 
153 #endif
SmartPointer< const Self > ConstPointer
Light weight base class for most itk classes.
Implement a gradient descent optimizer.
This class is a base for the Optimization methods that optimize a single valued function.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
SingleValuedNonLinearOptimizer Superclass
Control indentation during Print() invocation.
Definition: itkIndent.h:49