ITK  4.4.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 <string>
24 namespace itk
25 {
50 class ITK_EXPORT GradientDescentOptimizer:
52 {
53 public:
59 
61  itkNewMacro(Self);
62 
65 
67  typedef enum {
69  MetricError
70  } StopConditionType;
71 
73  itkGetConstReferenceMacro(Maximize, bool);
74  itkSetMacro(Maximize, bool);
75  itkBooleanMacro(Maximize);
76  bool GetMinimize() const
77  { return !m_Maximize; }
78  void SetMinimize(bool v)
79  { this->SetMaximize(!v); }
80  void MinimizeOn()
81  { this->MaximizeOff(); }
82  void MinimizeOff()
83  { this->MaximizeOn(); }
85 
87  virtual void AdvanceOneStep(void);
88 
90  void StartOptimization(void);
91 
94  void ResumeOptimization(void);
95 
98  void StopOptimization(void);
99 
101  itkSetMacro(LearningRate, double);
102 
104  itkGetConstReferenceMacro(LearningRate, double);
105 
107  itkSetMacro(NumberOfIterations, SizeValueType);
108 
110  itkGetConstReferenceMacro(NumberOfIterations, SizeValueType);
111 
113  itkGetConstMacro(CurrentIteration, SizeValueType);
114 
116  itkGetConstReferenceMacro(Value, double);
117 
119  itkGetConstReferenceMacro(StopCondition, StopConditionType);
120  const std::string GetStopConditionDescription() const;
122 
124  itkGetConstReferenceMacro(Gradient, DerivativeType);
125 
126 protected:
129  void PrintSelf(std::ostream & os, Indent indent) const;
130 
131  // made protected so subclass can access
132  DerivativeType m_Gradient;
133 
135 
137 
138 private:
139  GradientDescentOptimizer(const Self &); //purposely not implemented
140  void operator=(const Self &); //purposely not implemented
141 
142  bool m_Stop;
143  double m_Value;
147  std::ostringstream m_StopConditionDescription;
148 };
149 } // end namespace itk
150 
151 #endif
152