Orfeo Toolbox  3.16
itkSPSAOptimizer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkSPSAOptimizer.h,v $
5  Language: C++
6  Date: $Date: 2009-06-24 12:02:54 $
7  Version: $Revision: 1.10 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkSPSAOptimizer_h
18 #define __itkSPSAOptimizer_h
19 
22 
23 
24 namespace itk
25 {
26 
45 {
46 public:
47 
53 
55  itkNewMacro( Self );
56 
59 
61  typedef enum {
65  MetricError } StopConditionType;
66 
68  virtual void AdvanceOneStep( void );
69 
71  void StartOptimization( void );
72 
75  void ResumeOptimization( void );
76 
79  void StopOptimization( void );
80 
82  virtual MeasureType GetValue( void ) const;
83 
85  virtual MeasureType GetValue( const ParametersType & parameters ) const;
86 
100  virtual void GuessParameters(
101  unsigned long numberOfGradientEstimates,
102  double initialStepSize);
103 
105  itkGetConstMacro( CurrentIteration, unsigned long );
106 
108  itkGetConstMacro( StopCondition, StopConditionType );
109 
111  itkGetConstMacro( LearningRate, double);
112 
114  itkGetConstMacro( GradientMagnitude, double);
115 
117  itkGetConstReferenceMacro( Gradient, DerivativeType);
118 
120  itkSetMacro( Sa, double );
121  itkGetConstMacro( Sa, double );
122  // For backward compatibility
123  void Seta (double a) { SetSa(a);}
124  double Geta () {return GetSa();}
125 
127  itkSetMacro( Sc, double );
128  itkGetConstMacro( Sc, double );
129  // For backward compatibility
130  void Setc (double c) {SetSc(c);}
131  double Getc () {return GetSc();}
132 
134  itkSetMacro( A, double );
135  itkGetConstMacro( A, double );
136 
138  itkSetMacro( Alpha, double );
139  itkGetConstMacro( Alpha, double );
140 
142  itkSetMacro( Gamma, double );
143  itkGetConstMacro( Gamma, double );
144 
146  itkGetConstMacro( Maximize, bool );
147  itkSetMacro( Maximize, bool );
148  itkBooleanMacro( Maximize );
149  bool GetMinimize( ) const
150  { return !m_Maximize; }
151  void SetMinimize(bool v)
152  { this->SetMaximize(!v); }
153  void MinimizeOn()
154  { this->MaximizeOff(); }
155  void MinimizeOff()
156  { this->MaximizeOn(); }
157 
163  itkSetMacro( NumberOfPerturbations, unsigned long );
164  itkGetConstMacro( NumberOfPerturbations, unsigned long );
165 
166 
178  itkGetConstMacro( StateOfConvergence, double );
179 
181  itkSetMacro( StateOfConvergenceDecayRate, double );
182  itkGetConstMacro( StateOfConvergenceDecayRate, double );
183 
185  itkSetMacro( MinimumNumberOfIterations, unsigned long);
186  itkGetConstMacro( MinimumNumberOfIterations, unsigned long);
187 
189  itkSetMacro( MaximumNumberOfIterations, unsigned long );
190  itkGetConstMacro( MaximumNumberOfIterations, unsigned long );
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 
208  DerivativeType m_Gradient;
210  DerivativeType m_Delta;
211  bool m_Stop;
214  unsigned long m_CurrentIteration;
215 
218 
220  virtual double Compute_a( unsigned long k ) const;
221 
226  virtual double Compute_c( unsigned long k ) const;
227 
229  virtual void GenerateDelta( const unsigned int spaceDimension );
230 
235  virtual void ComputeGradient(
236  const ParametersType & parameters,
237  DerivativeType & gradient);
238 
239 private:
240 
241  SPSAOptimizer( const Self& ); // purposely not implemented
242  void operator=( const Self& ); // purposely not implemented
243 
248  double m_Tolerance;
251  unsigned long m_NumberOfPerturbations;
252 
254  double m_Sa;
255  double m_Sc;
256  double m_A;
257  double m_Alpha;
258  double m_Gamma;
259 
260 }; // end class SPSAOptimizer
261 
262 } // end namespace itk
263 
264 #endif // end #ifndef __itkSPSAOptimizer_h

Generated at Sun Feb 3 2013 00:08:31 for Orfeo Toolbox with doxygen 1.8.1.1