go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGenericConjugateGradientOptimizer.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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
19#ifndef itkGenericConjugateGradientOptimizer_h
20#define itkGenericConjugateGradientOptimizer_h
21
24#include <vector>
25#include <map>
26
27namespace itk
28{
41{
42public:
44
47 using Pointer = SmartPointer<Self>;
48 using ConstPointer = SmartPointer<const Self>;
49
50 itkNewMacro(Self);
52
53 using Superclass::ParametersType;
54 using Superclass::DerivativeType;
55 using Superclass::CostFunctionType;
57 using Superclass::MeasureType;
59
62
65 using ComputeBetaFunctionType = double (Self::*)(const DerivativeType &,
66 const DerivativeType &,
67 const ParametersType &);
68 using BetaDefinitionType = std::string;
69 using BetaDefinitionMapType = std::map<BetaDefinitionType, ComputeBetaFunctionType>;
70
72 {
80 };
81
82 void
84
85 virtual void
87
88 virtual void
90
92 itkGetConstMacro(CurrentIteration, unsigned long);
93 itkGetConstMacro(CurrentValue, MeasureType);
94 itkGetConstReferenceMacro(CurrentGradient, DerivativeType);
95 itkGetConstMacro(InLineSearch, bool);
96 itkGetConstReferenceMacro(StopCondition, StopConditionType);
97 itkGetConstMacro(CurrentStepLength, double);
98
102
104 itkGetConstMacro(MaximumNumberOfIterations, unsigned long);
105 itkSetClampMacro(MaximumNumberOfIterations, unsigned long, 1, NumericTraits<unsigned long>::max());
106
113 itkGetConstMacro(GradientMagnitudeTolerance, double);
114 itkSetMacro(GradientMagnitudeTolerance, double)
115
116
123 itkGetConstMacro(ValueTolerance, double);
124 itkSetMacro(ValueTolerance, double);
125
129 virtual void
131
132 itkGetConstMacro(MaxNrOfItWithoutImprovement, unsigned long);
133
135 void
137
138 itkGetConstReferenceMacro(BetaDefinition, BetaDefinitionType);
139
140protected:
143
144 void
145 PrintSelf(std::ostream & os, Indent indent) const override;
146
147 DerivativeType m_CurrentGradient;
148 MeasureType m_CurrentValue{ 0.0 };
149 unsigned long m_CurrentIteration{ 0 };
151 bool m_Stop{ false };
152 double m_CurrentStepLength{ 0.0 };
153
157
159 bool m_InLineSearch{ false };
160 itkSetMacro(InLineSearch, bool);
161
167
170
174
180 void
182
193 virtual void
194 ComputeSearchDirection(const DerivativeType & previousGradient,
195 const DerivativeType & gradient,
196 ParametersType & searchDir);
197
202 virtual void
203 LineSearch(const ParametersType searchDir, double & step, ParametersType & x, MeasureType & f, DerivativeType & g);
204
209 virtual bool
210 TestConvergence(bool firstLineSearchDone);
211
213 virtual double
214 ComputeBeta(const DerivativeType & previousGradient,
215 const DerivativeType & gradient,
216 const ParametersType & previousSearchDir);
217
221 double
222 ComputeBetaSD(const DerivativeType & previousGradient,
223 const DerivativeType & gradient,
224 const ParametersType & previousSearchDir);
225
227 double
228 ComputeBetaFR(const DerivativeType & previousGradient,
229 const DerivativeType & gradient,
230 const ParametersType & previousSearchDir);
231
233 double
234 ComputeBetaPR(const DerivativeType & previousGradient,
235 const DerivativeType & gradient,
236 const ParametersType & previousSearchDir);
237
239 double
240 ComputeBetaDY(const DerivativeType & previousGradient,
241 const DerivativeType & gradient,
242 const ParametersType & previousSearchDir);
243
245 double
246 ComputeBetaHS(const DerivativeType & previousGradient,
247 const DerivativeType & gradient,
248 const ParametersType & previousSearchDir);
249
251 double
252 ComputeBetaDYHS(const DerivativeType & previousGradient,
253 const DerivativeType & gradient,
254 const ParametersType & previousSearchDir);
255
256private:
257 unsigned long m_MaximumNumberOfIterations{ 100 };
258 double m_ValueTolerance{ 1e-5 };
260 unsigned long m_MaxNrOfItWithoutImprovement{ 10 };
261
263};
264
265} // end namespace itk
266
267#endif //#ifndef itkGenericConjugateGradientOptimizer_h
virtual void SetMaxNrOfItWithoutImprovement(unsigned long arg)
double ComputeBetaPR(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
void PrintSelf(std::ostream &os, Indent indent) const override
virtual bool TestConvergence(bool firstLineSearchDone)
ITK_DISALLOW_COPY_AND_MOVE(GenericConjugateGradientOptimizer)
std::map< BetaDefinitionType, ComputeBetaFunctionType > BetaDefinitionMapType
double ComputeBetaHS(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
void SetBetaDefinition(const BetaDefinitionType &arg)
double(Self::*)(const DerivativeType &, const DerivativeType &, const ParametersType &) ComputeBetaFunctionType
virtual void ComputeSearchDirection(const DerivativeType &previousGradient, const DerivativeType &gradient, ParametersType &searchDir)
double ComputeBetaSD(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
virtual void LineSearch(const ParametersType searchDir, double &step, ParametersType &x, MeasureType &f, DerivativeType &g)
double ComputeBetaFR(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
virtual double ComputeBeta(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
void AddBetaDefinition(const BetaDefinitionType &name, ComputeBetaFunctionType function)
double ComputeBetaDY(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
double ComputeBetaDYHS(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
itkGetModifiableObjectMacro(LineSearchOptimizer, LineSearchOptimizerType)
A base class for LineSearch optimizers.
SmartPointer< Self > Pointer
A cost function that applies a scaling to another cost function.


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo