ITK  6.0.0
Insight Toolkit
itkPowellOptimizer.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 itkPowellOptimizer_h
19#define itkPowellOptimizer_h
20
21#include "itkVector.h"
22#include "itkMatrix.h"
24#include "ITKOptimizersExport.h"
25
26namespace itk
27{
62class ITKOptimizers_EXPORT PowellOptimizer : public SingleValuedNonLinearOptimizer
63{
64public:
70
72
74 itkNewMacro(Self);
75
77 itkOverrideGetNameOfClassMacro(PowellOptimizer);
78
82
84 itkSetMacro(Maximize, bool);
85 itkBooleanMacro(Maximize);
86 itkGetConstReferenceMacro(Maximize, bool);
90 itkSetMacro(MaximumIteration, unsigned int);
91 itkGetConstReferenceMacro(MaximumIteration, unsigned int);
95 itkSetMacro(MaximumLineIteration, unsigned int);
96 itkGetConstMacro(MaximumLineIteration, unsigned int);
101 itkSetMacro(StepLength, double);
102 itkGetConstReferenceMacro(StepLength, double);
107 itkSetMacro(StepTolerance, double);
108 itkGetConstReferenceMacro(StepTolerance, double);
114 itkSetMacro(ValueTolerance, double);
115 itkGetConstReferenceMacro(ValueTolerance, double);
119 itkGetConstReferenceMacro(CurrentCost, MeasureType);
121 GetValue() const
122 {
123 return this->GetCurrentCost();
124 }
128 itkGetConstReferenceMacro(CurrentIteration, unsigned int);
129
131 itkGetConstReferenceMacro(CurrentLineIteration, unsigned int);
132
134 void
136
140 void
142 {
143 m_Stop = true;
144 }
145
146 itkGetConstReferenceMacro(CatchGetValueException, bool);
147 itkSetMacro(CatchGetValueException, bool);
148
149 itkGetConstReferenceMacro(MetricWorstPossibleValue, double);
150 itkSetMacro(MetricWorstPossibleValue, double);
151
152 std::string
154
155protected:
159 void
160 PrintSelf(std::ostream & os, Indent indent) const override;
161
162 itkSetMacro(CurrentCost, double);
163
166 void
167 SetLine(const ParametersType & origin, const vnl_vector<double> & direction);
168
172 double
173 GetLineValue(double x) const;
174
175 double
176 GetLineValue(double x, ParametersType & tempCoord) const;
177
180 void
181 SetCurrentLinePoint(double x, double fx);
182
185 void
186 Swap(double * a, double * b) const;
187
190 void
191 Shift(double * a, double * b, double * c, double d) const;
192
202 virtual void
203 LineBracket(double * x1, double * x2, double * x3, double * f1, double * f2, double * f3);
204
205 virtual void
206 LineBracket(double * x1, double * x2, double * x3, double * f1, double * f2, double * f3, ParametersType & tempCoord);
207
213 virtual void
215 double bx,
216 double cx,
217 double fa,
218 double functionValueOfb,
219 double fc,
220 double * extX,
221 double * extVal);
222
223 virtual void
225 double bx,
226 double cx,
227 double fa,
228 double functionValueOfb,
229 double fc,
230 double * extX,
231 double * extVal,
232 ParametersType & tempCoord);
233
234 itkGetMacro(SpaceDimension, unsigned int);
235 void
236 SetSpaceDimension(unsigned int dim)
237 {
238 this->m_SpaceDimension = dim;
239 this->m_LineDirection.set_size(dim);
240 this->m_LineOrigin.set_size(dim);
241 this->m_CurrentPosition.set_size(dim);
242 this->Modified();
243 }
244
245 itkSetMacro(CurrentIteration, unsigned int);
246
247 itkGetMacro(Stop, bool);
248 itkSetMacro(Stop, bool);
249
250private:
251 unsigned int m_SpaceDimension{};
252
254 unsigned int m_CurrentIteration{};
255 unsigned int m_CurrentLineIteration{};
256
258 unsigned int m_MaximumIteration{};
259 unsigned int m_MaximumLineIteration{};
260
261 bool m_CatchGetValueException{};
262 double m_MetricWorstPossibleValue{};
263
265 bool m_Maximize{};
266
268 double m_StepLength{};
269 double m_StepTolerance{};
270
271 ParametersType m_LineOrigin{};
272 vnl_vector<double> m_LineDirection{};
273
274 double m_ValueTolerance{};
275
277 MeasureType m_CurrentCost{};
278
283 bool m_Stop{};
284
285 std::ostringstream m_StopConditionDescription{};
286}; // end of class
287} // end of namespace itk
288
289#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Implements Powell optimization using Brent line search.
void SetSpaceDimension(unsigned int dim)
std::string GetStopConditionDescription() const override
virtual void LineBracket(double *x1, double *x2, double *x3, double *f1, double *f2, double *f3)
virtual void LineBracket(double *x1, double *x2, double *x3, double *f1, double *f2, double *f3, ParametersType &tempCoord)
void SetLine(const ParametersType &origin, const vnl_vector< double > &direction)
void StartOptimization() override
PowellOptimizer(const PowellOptimizer &)
virtual void BracketedLineOptimize(double ax, double bx, double cx, double fa, double functionValueOfb, double fc, double *extX, double *extVal)
double GetLineValue(double x, ParametersType &tempCoord) const
double GetLineValue(double x) const
void SetCurrentLinePoint(double x, double fx)
void Swap(double *a, double *b) const
void PrintSelf(std::ostream &os, Indent indent) const override
void Shift(double *a, double *b, double *c, double d) const
MeasureType GetValue() const
~PowellOptimizer() override
virtual void BracketedLineOptimize(double ax, double bx, double cx, double fa, double functionValueOfb, double fc, double *extX, double *extVal, ParametersType &tempCoord)
This class is a base for the CostFunctions returning a single value.
This class is a base for the Optimization methods that optimize a single valued function.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....