ITK  6.0.0
Insight Toolkit
itkSingleValuedNonLinearVnlOptimizer.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 itkSingleValuedNonLinearVnlOptimizer_h
19 #define itkSingleValuedNonLinearVnlOptimizer_h
20 
23 #include "itkCommand.h"
24 #include "ITKOptimizersExport.h"
25 
26 #include <memory> // For unique_ptr.
27 
28 namespace itk
29 {
40 {
41 public:
42  ITK_DISALLOW_COPY_AND_MOVE(SingleValuedNonLinearVnlOptimizer);
43 
49 
51  itkOverrideGetNameOfClassMacro(SingleValuedNonLinearVnlOptimizer);
52 
58 
65  void
66  SetCostFunction(SingleValuedCostFunction * costFunction) override = 0;
67 
73  itkGetConstReferenceMacro(Maximize, bool);
74  itkSetMacro(Maximize, bool);
75  itkBooleanMacro(Maximize);
76  bool
77  GetMinimize() const
78  {
79  return !m_Maximize;
80  }
81  void
82  SetMinimize(bool v)
83  {
84  this->SetMaximize(!v);
85  }
86  void
88  {
89  this->MaximizeOff();
90  }
91  void
93  {
94  this->MaximizeOn();
95  }
103  itkGetConstReferenceMacro(CachedValue, MeasureType);
104  itkGetConstReferenceMacro(CachedDerivative, DerivativeType);
105  itkGetConstReferenceMacro(CachedCurrentPosition, ParametersType);
111  virtual bool
112  CanUseScales() const
113  {
114  return true;
115  }
116 
117 protected:
120 
122 
123  void
124  SetCostFunctionAdaptor(CostFunctionAdaptorType * adaptor);
125 
127  GetCostFunctionAdaptor() const;
128 
130  GetCostFunctionAdaptor();
131 
135  GetNonConstCostFunctionAdaptor() const;
136 
138  void
139  PrintSelf(std::ostream & os, Indent indent) const override;
140 
141 private:
143  void
144  IterationReport(const EventObject & event);
145 
146  std::unique_ptr<CostFunctionAdaptorType> m_CostFunctionAdaptor;
147 
148  bool m_Maximize{};
149 
150  CommandType::Pointer m_Command{};
151 
152  mutable ParametersType m_CachedCurrentPosition{};
153  mutable MeasureType m_CachedValue{};
154  mutable DerivativeType m_CachedDerivative{};
155 };
156 } // end namespace itk
157 
158 #endif
itk::OptimizerParameters< double >
itk::SingleValuedNonLinearOptimizer
This class is a base for the Optimization methods that optimize a single valued function.
Definition: itkSingleValuedNonLinearOptimizer.h:35
itk::SingleValuedNonLinearVnlOptimizer::CanUseScales
virtual bool CanUseScales() const
Definition: itkSingleValuedNonLinearVnlOptimizer.h:112
itk::SingleValuedNonLinearVnlOptimizer::m_CostFunctionAdaptor
std::unique_ptr< CostFunctionAdaptorType > m_CostFunctionAdaptor
Definition: itkSingleValuedNonLinearVnlOptimizer.h:146
itk::ReceptorMemberCommand
A Command subclass that calls a pointer to a member function.
Definition: itkCommand.h:164
itk::SingleValuedNonLinearVnlOptimizer::SetMinimize
void SetMinimize(bool v)
Definition: itkSingleValuedNonLinearVnlOptimizer.h:82
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SingleValuedVnlCostFunctionAdaptor
This class is an Adaptor that allows to pass itk::SingleValuedCostFunctions to vnl_optimizers expecti...
Definition: itkSingleValuedVnlCostFunctionAdaptor.h:37
itk::SingleValuedNonLinearVnlOptimizer::GetMinimize
bool GetMinimize() const
Definition: itkSingleValuedNonLinearVnlOptimizer.h:77
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::SingleValuedCostFunction
This class is a base for the CostFunctions returning a single value.
Definition: itkSingleValuedCostFunction.h:34
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::SingleValuedNonLinearOptimizer::MeasureType
CostFunctionType::MeasureType MeasureType
Definition: itkSingleValuedNonLinearOptimizer.h:62
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itk::EventObject
Abstraction of the Events used to communicating among filters and with GUIs.
Definition: itkEventObject.h:58
itk::SingleValuedNonLinearVnlOptimizer::MinimizeOn
void MinimizeOn()
Definition: itkSingleValuedNonLinearVnlOptimizer.h:87
itk::SingleValuedNonLinearVnlOptimizer
This class is a base for the Optimization methods that optimize a single valued function.
Definition: itkSingleValuedNonLinearVnlOptimizer.h:39
itkSingleValuedNonLinearOptimizer.h
itkSingleValuedVnlCostFunctionAdaptor.h
itkCommand.h
itk::SingleValuedNonLinearVnlOptimizer::MinimizeOff
void MinimizeOff()
Definition: itkSingleValuedNonLinearVnlOptimizer.h:92