ITK  4.6.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 {
53 {
54 public:
60 
62  itkNewMacro(Self);
63 
66 
68  typedef enum {
72 
74  itkGetConstReferenceMacro(Maximize, bool);
75  itkSetMacro(Maximize, bool);
76  itkBooleanMacro(Maximize);
77  bool GetMinimize() const
78  { return !m_Maximize; }
79  void SetMinimize(bool v)
80  { this->SetMaximize(!v); }
81  void MinimizeOn()
82  { this->MaximizeOff(); }
83  void MinimizeOff()
84  { this->MaximizeOn(); }
86 
88  virtual void AdvanceOneStep(void);
89 
91  virtual void StartOptimization(void) ITK_OVERRIDE;
92 
95  void ResumeOptimization(void);
96 
99  void StopOptimization(void);
100 
102  itkSetMacro(LearningRate, double);
103 
105  itkGetConstReferenceMacro(LearningRate, double);
106 
108  itkSetMacro(NumberOfIterations, SizeValueType);
109 
111  itkGetConstReferenceMacro(NumberOfIterations, SizeValueType);
112 
114  itkGetConstMacro(CurrentIteration, SizeValueType);
115 
117  itkGetConstReferenceMacro(Value, double);
118 
120  itkGetConstReferenceMacro(StopCondition, StopConditionType);
121  virtual const std::string GetStopConditionDescription() const ITK_OVERRIDE;
123 
125  itkGetConstReferenceMacro(Gradient, DerivativeType);
126 
127 protected:
129  virtual ~GradientDescentOptimizer() {}
130  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
131 
132  // made protected so subclass can access
134 
136 
138 
139 private:
140  GradientDescentOptimizer(const Self &); //purposely not implemented
141  void operator=(const Self &); //purposely not implemented
142 
143  bool m_Stop;
144  double m_Value;
148  std::ostringstream m_StopConditionDescription;
149 };
150 } // end namespace itk
151 
152 #endif
SmartPointer< const Self > ConstPointer
virtual void SetMaximize(bool _arg)
Light weight base class for most itk classes.
Implement a gradient descent optimizer.
virtual void AdvanceOneStep(void)
void operator=(const Self &)
This class is a base for the Optimization methods that optimize a single valued function.
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
unsigned long SizeValueType
Definition: itkIntTypes.h:143
SingleValuedNonLinearOptimizer Superclass
virtual void StartOptimization(void) ITK_OVERRIDE
virtual const std::string GetStopConditionDescription() const ITK_OVERRIDE
Control indentation during Print() invocation.
Definition: itkIndent.h:49