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 itkOptimizerParameterScalesEstimator_h
19 #define itkOptimizerParameterScalesEstimator_h
20 
21 #include "itkObject.h"
22 #include "itkObjectFactory.h"
23 #include "itkOptimizerParameters.h"
24 
25 namespace itk
26 {
27 
28 /** \class OptimizerParameterScalesEstimatorTemplate
29  *  \brief OptimizerParameterScalesEstimatorTemplate is the base class offering a
30  * empty method of estimating the parameter scales for optimizers.
31  *
32  * Its subclass RegistrationParameterScalesEstimator estimates scales for
33  * registration optimizers.
34  *
35  * \ingroup ITKOptimizersv4
36  */
37 template< typename TInternalComputationValueType=double >
38 class OptimizerParameterScalesEstimatorTemplate : public Object
39 {
40 public:
41   ITK_DISALLOW_COPY_AND_ASSIGN(OptimizerParameterScalesEstimatorTemplate);
42 
43   /** Standard class type aliases. */
44   using Self = OptimizerParameterScalesEstimatorTemplate;
45   using Superclass = Object;
46   using Pointer = SmartPointer<Self>;
47   using ConstPointer = SmartPointer<const Self>;
48 
49   /** Run-time type information (and related methods). */
50   itkTypeMacro( OptimizerParameterScalesEstimatorTemplate, Object );
51 
52   /** Type of scales */
53   using ScalesType = OptimizerParameters<TInternalComputationValueType>;
54   /** Type of parameters of the optimizer */
55   using ParametersType = OptimizerParameters<TInternalComputationValueType>;
56 
57   /** Type of float */
58   using FloatType = TInternalComputationValueType;
59 
60   /** Estimate parameter scales. */
61   virtual void EstimateScales(ScalesType &scales) = 0;
62 
63   /** Estimate the scale of a step. */
64   virtual FloatType EstimateStepScale(const ParametersType &step) = 0;
65 
66   /** Estimate the scales of local steps. */
67   virtual void EstimateLocalStepScales(const ParametersType &step,
68     ScalesType &localStepScales) = 0;
69 
70   /** Estimate the maximum size for steps. */
71   virtual FloatType EstimateMaximumStepSize() = 0;
72 
73 protected:
74   OptimizerParameterScalesEstimatorTemplate()= default;
75   ~OptimizerParameterScalesEstimatorTemplate() override = default;
76 
PrintSelf(std::ostream & os,Indent indent)77   void PrintSelf(std::ostream &os, Indent indent) const override
78     {
79     Superclass::PrintSelf(os,indent);
80     }
81 }; //class OptimizerParameterScalesEstimatorTemplate
82 
83 /** This helps to meet backward compatibility */
84 using OptimizerParameterScalesEstimator = OptimizerParameterScalesEstimatorTemplate<double>;
85 
86 }  // namespace itk
87 
88 #endif
89