go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkPreconditionedGradientDescentOptimizer.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#ifndef itkPreconditionedGradientDescentOptimizer_h
19#define itkPreconditionedGradientDescentOptimizer_h
20
22#include "itkArray2D.h"
23#include <vnl/vnl_sparse_matrix.h>
24#include "cholmod.h"
25
26namespace itk
27{
56{
57public:
59
63 using Pointer = SmartPointer<Self>;
64 using ConstPointer = SmartPointer<const Self>;
65
67 itkNewMacro(Self);
68
71
73 using Superclass::MeasureType;
74 using Superclass::ParametersType;
75 using Superclass::DerivativeType;
76 using Superclass::CostFunctionType;
80
82 using PreconditionValueType = DerivativeType::ValueType;
83 // typedef Array2D<PreconditionValueType> PreconditionType;
84 // typedef vnl_symmetric_eigensystem<
85 // PreconditionValueType > EigenSystemType;
86 using PreconditionType = vnl_sparse_matrix<PreconditionValueType>;
87
93 {
97 };
98
100 virtual void
102
104 virtual void
106
110 virtual void
112
114 virtual void
115 MetricErrorResponse(ExceptionObject & err);
116
119 virtual void
121
123 itkSetMacro(LearningRate, double);
124
126 itkGetConstReferenceMacro(LearningRate, double);
127
129 itkSetMacro(NumberOfIterations, unsigned long);
130
132 itkGetConstReferenceMacro(NumberOfIterations, unsigned long);
133
135 itkGetConstMacro(CurrentIteration, unsigned int);
136
138 itkGetConstReferenceMacro(Value, double);
139
141 itkGetConstReferenceMacro(StopCondition, StopConditionType);
142
144 itkGetConstReferenceMacro(Gradient, DerivativeType);
145
147 itkGetConstReferenceMacro(SearchDirection, DerivativeType);
148
155 virtual void
157
159 const cholmod_common *
161 {
162 return this->m_CholmodCommon;
163 }
164
165
166 const cholmod_factor *
168 {
169 return this->m_CholmodFactor;
170 }
171
173 itkSetMacro(DiagonalWeight, double);
174 itkGetConstMacro(DiagonalWeight, double);
175
177 itkSetMacro(MinimumGradientElementMagnitude, double);
178 itkGetConstMacro(MinimumGradientElementMagnitude, double);
179
182 itkGetConstMacro(ConditionNumber, double);
183
186 itkGetConstMacro(LargestEigenValue, double);
187
192 itkGetConstMacro(Sparsity, double);
193
194protected:
197
198 void
199 PrintSelf(std::ostream & os, Indent indent) const;
200
202 using cholmod_l = int CInt; // change to UF_long if using;
203
204 // made protected so subclass can access
205 DerivativeType m_Gradient;
206 double m_LearningRate{ 1.0 };
208 DerivativeType m_SearchDirection;
209 double m_LargestEigenValue{ 1.0 };
210 double m_ConditionNumber{ 1.0 };
211 double m_Sparsity{ 1.0 };
212
213 cholmod_common * m_CholmodCommon;
214 cholmod_factor * m_CholmodFactor{ nullptr };
215 cholmod_sparse * m_CholmodGradient{ nullptr };
216
221 virtual void
222 CholmodSolve(const DerivativeType & gradient, DerivativeType & searchDirection, int solveType = CHOLMOD_A);
223
224private:
225 bool m_Stop{ false };
226 double m_Value{ 0.0 };
227
228 unsigned long m_NumberOfIterations{ 100 };
229 unsigned long m_CurrentIteration{ 0 };
230
231 double m_DiagonalWeight{ 1e-6 };
233};
234
235} // end namespace itk
236
237
238#endif
virtual void SetPreconditionMatrix(PreconditionType &precondition)
void PrintSelf(std::ostream &os, Indent indent) const
ITK_DISALLOW_COPY_AND_MOVE(PreconditionedGradientDescentOptimizer)
virtual void MetricErrorResponse(ExceptionObject &err)
virtual void CholmodSolve(const DerivativeType &gradient, DerivativeType &searchDirection, int solveType=CHOLMOD_A)
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