ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkSingleValuedNonLinearVnlOptimizer.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 itkSingleValuedNonLinearVnlOptimizer_h
19 #define itkSingleValuedNonLinearVnlOptimizer_h
20 
23 #include "itkCommand.h"
24 #include "ITKOptimizersExport.h"
25 
26 namespace itk
27 {
37 class ITKOptimizers_EXPORT SingleValuedNonLinearVnlOptimizer:
39 {
40 public:
46 
49  SingleValueNonLinearOptimizer);
50 
56 
63  virtual void SetCostFunction(SingleValuedCostFunction *costFunction) ITK_OVERRIDE = 0;
64 
70  itkGetConstReferenceMacro(Maximize, bool);
71  itkSetMacro(Maximize, bool);
72  itkBooleanMacro(Maximize);
73  bool GetMinimize() const
74  { return !m_Maximize; }
75  void SetMinimize(bool v)
76  { this->SetMaximize(!v); }
77  void MinimizeOn()
78  { this->MaximizeOff(); }
79  void MinimizeOff()
80  { this->MaximizeOn(); }
82 
88  itkGetConstReferenceMacro(CachedValue, MeasureType);
89  itkGetConstReferenceMacro(CachedDerivative, DerivativeType);
90  itkGetConstReferenceMacro(CachedCurrentPosition, ParametersType);
92 
93 protected:
96 
98 
99  void SetCostFunctionAdaptor(CostFunctionAdaptorType *adaptor);
100 
101  const CostFunctionAdaptorType * GetCostFunctionAdaptor() const;
102 
103  CostFunctionAdaptorType * GetCostFunctionAdaptor();
104 
107  CostFunctionAdaptorType * GetNonConstCostFunctionAdaptor() const;
108 
110  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
111 
112 private:
114  void IterationReport(const EventObject & event);
115 
116  SingleValuedNonLinearVnlOptimizer(const Self &) ITK_DELETE_FUNCTION;
117  void operator=(const Self &) ITK_DELETE_FUNCTION;
118 
119  CostFunctionAdaptorType *m_CostFunctionAdaptor;
120 
121  bool m_Maximize;
122 
123  CommandType::Pointer m_Command;
124 
125  mutable ParametersType m_CachedCurrentPosition;
126  mutable MeasureType m_CachedValue;
127  mutable DerivativeType m_CachedDerivative;
128 };
129 } // end namespace itk
130 
131 #endif
Array class with size defined at construction time.
Definition: itkArray.h:50
This class is a base for the CostFunctions returning a single value.
Light weight base class for most itk classes.
This class is a base for the Optimization methods that optimize a single valued function.
This class is an Adaptor that allows to pass itk::SingleValuedCostFunctions to vnl_optimizers expecti...
SingleValuedVnlCostFunctionAdaptor CostFunctionAdaptorType
This class is a base for the Optimization methods that optimize a single valued function.
A Command subclass that calls a pointer to a member function.
Definition: itkCommand.h:168
Abstraction of the Events used to communicating among filters and with GUIs.
Control indentation during Print() invocation.
Definition: itkIndent.h:49