ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMultiStartOptimizerv4.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 itkMultiStartOptimizerv4_h
19 #define itkMultiStartOptimizerv4_h
20 
23 
24 namespace itk
25 {
39 template<typename TInternalComputationValueType>
40 class ITK_TEMPLATE_EXPORT MultiStartOptimizerv4Template
41 : public ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>
42 {
43 public:
44  ITK_DISALLOW_COPY_AND_ASSIGN(MultiStartOptimizerv4Template);
45 
51 
54 
56  itkNewMacro(Self);
57 
58  using ParametersType = typename Superclass::ParametersType;
59  using ParametersListType = std::vector< ParametersType >;
60  using ParameterListSizeType = typename ParametersListType::size_type;
61 
65  using LocalOptimizerPointer = typename LocalOptimizerType::Pointer;
66 
68  typedef enum {
74  OTHER_ERROR
75  } StopConditionType;
76 
78  using StopConditionReturnStringType = typename Superclass::StopConditionReturnStringType;
79 
81  using StopConditionDescriptionType = typename Superclass::StopConditionDescriptionType;
82 
86  using InternalComputationValueType = TInternalComputationValueType;
87 
89  using MetricType = typename Superclass::MetricType;
90  using MetricTypePointer = typename MetricType::Pointer;
91 
93  using DerivativeType = typename MetricType::DerivativeType;
94 
97  using MetricValuesListType = std::vector< MeasureType >;
98 
100  itkGetConstReferenceMacro(StopCondition, StopConditionType);
101 
103  void InstantiateLocalOptimizer();
104 
106  void StartOptimization( bool doOnlyInitialization = false ) override;
107 
110  virtual void StopOptimization();
111 
114  virtual void ResumeOptimization();
115 
117  const StopConditionReturnStringType GetStopConditionDescription() const override;
118 
120  ParametersListType & GetParametersList();
121 
123  void SetParametersList(ParametersListType & p);
124 
126  const MetricValuesListType & GetMetricValuesList() const;
127 
129  ParametersType GetBestParameters( );
130 
132  itkSetObjectMacro( LocalOptimizer, OptimizerType );
133  itkGetModifiableObjectMacro(LocalOptimizer, OptimizerType );
135 
136  inline ParameterListSizeType GetBestParametersIndex( ) { return this->m_BestParametersIndex; }
137 
138 protected:
141  ~MultiStartOptimizerv4Template() override = default;
143 
144  void PrintSelf(std::ostream & os, Indent indent) const override;
145 
146  /* Common variables for optimization control and reporting */
147  bool m_Stop{false};
156 };
157 
160 
161 } // end namespace itk
162 
163 #ifndef ITK_MANUAL_INSTANTIATION
164 #include "itkMultiStartOptimizerv4.hxx"
165 #endif
166 
167 #endif
typename OptimizerType::Pointer OptimizerPointer
StopConditionDescriptionType m_StopConditionDescription
typename MetricType::DerivativeType DerivativeType
typename ParametersListType::size_type ParameterListSizeType
Light weight base class for most itk classes.
typename itk::GradientDescentOptimizerv4Template< TInternalComputationValueType > LocalOptimizerType
typename Superclass::MetricType MetricType
typename Superclass::MeasureType MeasureType
typename Superclass::StopConditionReturnStringType StopConditionReturnStringType
Multi-start searches over input parameters and returns the best metric value.
typename Superclass::StopConditionDescriptionType StopConditionDescriptionType
std::vector< ParametersType > ParametersListType
typename LocalOptimizerType::Pointer LocalOptimizerPointer
std::vector< MeasureType > MetricValuesListType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename MetricType::Pointer MetricTypePointer
TInternalComputationValueType InternalComputationValueType
Abstract base for object-to-object optimizers.
typename Superclass::ParametersType ParametersType