Orfeo Toolbox  4.0
itkSPSAOptimizer.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 __itkSPSAOptimizer_h
19 #define __itkSPSAOptimizer_h
20 
23 
24 namespace itk
25 {
45 {
46 public:
47 
53 
55  itkNewMacro(Self);
56 
59 
61  typedef enum {
67 
69  virtual void AdvanceOneStep(void);
70 
72  void StartOptimization(void);
73 
76  void ResumeOptimization(void);
77 
80  void StopOptimization(void);
81 
83  virtual MeasureType GetValue(void) const;
84 
86  virtual MeasureType GetValue(const ParametersType & parameters) const;
87 
101  virtual void GuessParameters(
102  SizeValueType numberOfGradientEstimates,
103  double initialStepSize);
104 
106  itkGetConstMacro(CurrentIteration, SizeValueType);
107 
109  itkGetConstMacro(StopCondition, StopConditionType);
110 
112  itkGetConstMacro(LearningRate, double);
113 
115  itkGetConstMacro(GradientMagnitude, double);
116 
118  itkGetConstReferenceMacro(Gradient, DerivativeType);
119 
121  itkSetMacro(Sa, double);
122  itkGetConstMacro(Sa, double);
123  // For backward compatibility
124  void Seta(double a) { SetSa(a); }
125  double Geta() { return GetSa(); }
126 
128  itkSetMacro(Sc, double);
129  itkGetConstMacro(Sc, double);
130  // For backward compatibility
131  void Setc(double c) { SetSc(c); }
132  double Getc() { return GetSc(); }
133 
135  itkSetMacro(A, double);
136  itkGetConstMacro(A, double);
137 
139  itkSetMacro(Alpha, double);
140  itkGetConstMacro(Alpha, double);
141 
143  itkSetMacro(Gamma, double);
144  itkGetConstMacro(Gamma, double);
145 
147  itkGetConstMacro(Maximize, bool);
148  itkSetMacro(Maximize, bool);
149  itkBooleanMacro(Maximize);
150  bool GetMinimize() const
151  { return !m_Maximize; }
152  void SetMinimize(bool v)
153  { this->SetMaximize(!v); }
154  void MinimizeOn()
155  { this->MaximizeOff(); }
156  void MinimizeOff()
157  { this->MaximizeOn(); }
158 
164  itkSetMacro(NumberOfPerturbations, SizeValueType);
165  itkGetConstMacro(NumberOfPerturbations, SizeValueType);
166 
178  itkGetConstMacro(StateOfConvergence, double);
179 
181  itkSetMacro(StateOfConvergenceDecayRate, double);
182  itkGetConstMacro(StateOfConvergenceDecayRate, double);
183 
185  itkSetMacro(MinimumNumberOfIterations, SizeValueType);
186  itkGetConstMacro(MinimumNumberOfIterations, SizeValueType);
187 
190  itkGetConstMacro(MaximumNumberOfIterations, SizeValueType);
191 
193  itkSetMacro(Tolerance, double);
194  itkGetConstMacro(Tolerance, double);
195 
197  const std::string GetStopConditionDescription() const;
198 
199 protected:
200 
201  SPSAOptimizer();
202  virtual ~SPSAOptimizer() {}
203 
205  void PrintSelf(std::ostream & os, Indent indent) const;
206 
209 
211 
213 
214  bool m_Stop;
215 
217 
219 
221 
224 
226  virtual double Compute_a(SizeValueType k) const;
227 
232  virtual double Compute_c(SizeValueType k) const;
233 
235  virtual void GenerateDelta(const unsigned int spaceDimension);
236 
241  virtual void ComputeGradient(
242  const ParametersType & parameters,
243  DerivativeType & gradient);
244 
245 private:
246 
247  SPSAOptimizer(const Self &); // purposely not implemented
248  void operator=(const Self &); // purposely not implemented
249 
254  double m_Tolerance;
258 
260  double m_Sa;
261  double m_Sc;
262  double m_A;
263  double m_Alpha;
264  double m_Gamma;
265 }; // end class SPSAOptimizer
266 } // end namespace itk
267 
268 #endif // end #ifndef __itkSPSAOptimizer_h

Generated at Sat Mar 8 2014 15:35:06 for Orfeo Toolbox with doxygen 1.8.3.1