ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkRegularStepGradientDescentBaseOptimizer.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 itkRegularStepGradientDescentBaseOptimizer_h
19#define itkRegularStepGradientDescentBaseOptimizer_h
20
21#include "itkIntTypes.h"
23#include "ITKOptimizersExport.h"
24
25namespace itk
26{
48// Define how to print enumeration
49extern ITKOptimizers_EXPORT std::ostream &
51
59{
60public:
61 ITK_DISALLOW_COPY_AND_MOVE(RegularStepGradientDescentBaseOptimizer);
62
68
70 itkNewMacro(Self);
71
73 itkOverrideGetNameOfClassMacro(RegularStepGradientDescentBaseOptimizer);
74
76#if !defined(ITK_LEGACY_REMOVE)
77 // We need to expose the enum values at the class level
78 // for backwards compatibility
79 static constexpr StopConditionEnum GradientMagnitudeTolerance = StopConditionEnum::GradientMagnitudeTolerance;
80 static constexpr StopConditionEnum StepTooSmall = StopConditionEnum::StepTooSmall;
81 static constexpr StopConditionEnum ImageNotAvailable = StopConditionEnum::ImageNotAvailable;
82 static constexpr StopConditionEnum CostFunctionError = StopConditionEnum::CostFunctionError;
83 static constexpr StopConditionEnum MaximumNumberOfIterations = StopConditionEnum::MaximumNumberOfIterations;
84 static constexpr StopConditionEnum Unknown = StopConditionEnum::Unknown;
85#endif
88 itkSetMacro(Maximize, bool);
89 itkGetConstReferenceMacro(Maximize, bool);
90 itkBooleanMacro(Maximize);
91 bool
93 {
94 return !m_Maximize;
95 }
96 void
98 {
99 this->SetMaximize(!v);
100 }
101 void
103 {
104 SetMaximize(false);
105 }
106 void
108 {
109 SetMaximize(true);
110 }
111
113 void
115
118 void
120
123 void
125
128 itkSetMacro(MaximumStepLength, double);
129 itkSetMacro(MinimumStepLength, double);
130 itkSetMacro(RelaxationFactor, double);
131 itkSetMacro(NumberOfIterations, SizeValueType);
132 itkSetMacro(GradientMagnitudeTolerance, double);
133 itkGetConstReferenceMacro(CurrentStepLength, double);
134 itkGetConstReferenceMacro(MaximumStepLength, double);
135 itkGetConstReferenceMacro(MinimumStepLength, double);
136 itkGetConstReferenceMacro(RelaxationFactor, double);
137 itkGetConstReferenceMacro(NumberOfIterations, SizeValueType);
138 itkGetConstReferenceMacro(GradientMagnitudeTolerance, double);
139 itkGetConstMacro(CurrentIteration, unsigned int);
140 itkGetConstReferenceMacro(StopCondition, StopConditionEnum);
141 itkGetConstReferenceMacro(Value, MeasureType);
142 itkGetConstReferenceMacro(Gradient, DerivativeType);
145 std::string
147
148protected:
151 void
152 PrintSelf(std::ostream & os, Indent indent) const override;
153
157 virtual void
159
165 virtual void
167 {
169
170 ex.SetLocation(__FILE__);
171 ex.SetDescription("This method MUST be overloaded in derived classes");
172 throw ex;
173 }
174
175private:
176protected:
179
180 bool m_Stop{ false };
191 std::ostringstream m_StopConditionDescription{};
192};
193} // end namespace itk
194
195#endif
Standard exception handling object.
virtual void SetDescription(const std::string &s)
virtual void SetLocation(const std::string &s)
Control indentation during Print() invocation.
Definition itkIndent.h:50
Contains all enum classes for RegularStepGradientDescentBaseOptimizer class.
RegularStepGradientDescentBaseOptimizerEnums::StopCondition StopConditionEnum
void PrintSelf(std::ostream &os, Indent indent) const override
std::string GetStopConditionDescription() const override
~RegularStepGradientDescentBaseOptimizer() override=default
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)