ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMultiStartOptimizerv4.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkMultiStartOptimizerv4_h
00019 #define __itkMultiStartOptimizerv4_h
00020 #include "itkObjectToObjectOptimizerBase.h"
00021 #include "itkGradientDescentOptimizerv4.h"
00022 
00023 namespace itk
00024 {
00039 class ITK_EXPORT MultiStartOptimizerv4
00040   : public ObjectToObjectOptimizerBase
00041 {
00042 public:
00044   typedef MultiStartOptimizerv4          Self;
00045   typedef ObjectToObjectOptimizerBase    Superclass;
00046   typedef SmartPointer< Self >           Pointer;
00047   typedef SmartPointer< const Self >     ConstPointer;
00048 
00050   itkTypeMacro(MultiStartOptimizerv4, ObjectToObjectOptimizerBase);
00051 
00053   itkNewMacro(Self);
00054 
00055   typedef Superclass::ParametersType                 ParametersType;
00056   typedef std::vector< ParametersType >              ParametersListType;
00057   typedef ParametersListType::size_type              ParameterListSizeType;
00058   typedef ObjectToObjectOptimizerBase                OptimizerType;
00059   typedef OptimizerType::Pointer                     OptimizerPointer;
00060   typedef itk::GradientDescentOptimizerv4            LocalOptimizerType;
00061   typedef itk::GradientDescentOptimizerv4::Pointer   LocalOptimizerPointer;
00062 
00064   typedef enum {
00065     MAXIMUM_NUMBER_OF_ITERATIONS,
00066     COSTFUNCTION_ERROR,
00067     UPDATE_PARAMETERS_ERROR,
00068     STEP_TOO_SMALL,
00069     CONVERGENCE_CHECKER_PASSED,
00070     OTHER_ERROR
00071     } StopConditionType;
00072 
00074   typedef std::string                            StopConditionReturnStringType;
00075 
00077   typedef std::ostringstream                     StopConditionDescriptionType;
00078 
00080   typedef Superclass::MetricType                    MetricType;
00081   typedef MetricType::Pointer                       MetricTypePointer;
00082 
00084   typedef MetricType::DerivativeType                DerivativeType;
00085 
00087   typedef Superclass::MeasureType                   MeasureType;
00088   typedef std::vector< MeasureType >                MetricValuesListType;
00089 
00091   typedef Superclass::InternalComputationValueType InternalComputationValueType;
00092 
00094   itkGetConstReferenceMacro(StopCondition, StopConditionType);
00095 
00097   itkSetMacro(NumberOfIterations, SizeValueType);
00098 
00100   itkGetConstReferenceMacro(NumberOfIterations, SizeValueType);
00101 
00103   itkGetConstMacro(CurrentIteration, SizeValueType);
00104 
00106   void InstantiateLocalOptimizer(void);
00107 
00109   virtual void StartOptimization(void);
00110 
00113   virtual void StopOptimization(void);
00114 
00117   virtual void ResumeOptimization();
00118 
00120   virtual const StopConditionReturnStringType GetStopConditionDescription() const;
00121 
00123   ParametersListType & GetParametersList();
00124 
00126   void SetParametersList(ParametersListType & p);
00127 
00129   const MetricValuesListType & GetMetricValuesList() const;
00130 
00132   ParametersType GetBestParameters( );
00133 
00135   itkSetObjectMacro( LocalOptimizer, OptimizerType );
00136   itkGetObjectMacro( LocalOptimizer, OptimizerType );
00138 
00139   inline ParameterListSizeType GetBestParametersIndex( ) { return this->m_BestParametersIndex; }
00140 
00141 protected:
00142 
00144   MultiStartOptimizerv4();
00145   virtual ~MultiStartOptimizerv4();
00147 
00148   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00149 
00150   /* Common variables for optimization control and reporting */
00151   bool                          m_Stop;
00152   StopConditionType             m_StopCondition;
00153   StopConditionDescriptionType  m_StopConditionDescription;
00154   SizeValueType                 m_NumberOfIterations;
00155   SizeValueType                 m_CurrentIteration;
00156   ParametersListType            m_ParametersList;
00157   MetricValuesListType          m_MetricValuesList;
00158   MeasureType                   m_MinimumMetricValue;
00159   MeasureType                   m_MaximumMetricValue;
00160   ParameterListSizeType         m_BestParametersIndex;
00161   OptimizerPointer              m_LocalOptimizer;
00162 
00163 private:
00164   MultiStartOptimizerv4( const Self & ); //purposely not implemented
00165   void operator=( const Self& ); //purposely not implemented
00166 
00167 };
00168 
00169 } // end namespace itk
00170 
00171 #endif
00172