00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkSingleValuedNonLinearVnlOptimizer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2007/03/22 21:39:38 $ 00007 Version: $Revision: 1.26 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkSingleValuedNonLinearVnlOptimizer_h 00018 #define __itkSingleValuedNonLinearVnlOptimizer_h 00019 00020 #include "itkSingleValuedNonLinearOptimizer.h" 00021 #include "itkSingleValuedVnlCostFunctionAdaptor.h" 00022 #include "itkCommand.h" 00023 00024 00025 namespace itk 00026 { 00027 00036 class ITK_EXPORT SingleValuedNonLinearVnlOptimizer : 00037 public SingleValuedNonLinearOptimizer 00038 { 00039 public: 00041 typedef SingleValuedNonLinearVnlOptimizer Self; 00042 typedef SingleValuedNonLinearOptimizer Superclass; 00043 typedef SmartPointer<Self> Pointer; 00044 typedef SmartPointer<const Self> ConstPointer; 00045 00047 itkTypeMacro( SingleValuedNonLinearVnlOptimizer, 00048 SingleValueNonLinearOptimizer ); 00049 00054 typedef ReceptorMemberCommand< Self > CommandType; 00055 00062 virtual void SetCostFunction( SingleValuedCostFunction * costFunction ) = 0; 00063 00069 itkGetConstReferenceMacro( Maximize, bool ); 00070 itkSetMacro( Maximize, bool ); 00071 itkBooleanMacro( Maximize ); 00072 bool GetMinimize( ) const 00073 { return !m_Maximize; } 00074 void SetMinimize(bool v) 00075 { this->SetMaximize(!v); } 00076 void MinimizeOn() 00077 { this->MaximizeOff(); } 00078 void MinimizeOff() 00079 { this->MaximizeOn(); } 00081 00087 itkGetConstReferenceMacro(CachedValue, MeasureType); 00088 itkGetConstReferenceMacro(CachedDerivative, DerivativeType); 00089 itkGetConstReferenceMacro(CachedCurrentPosition, ParametersType); 00091 00092 protected: 00093 SingleValuedNonLinearVnlOptimizer(); 00094 virtual ~SingleValuedNonLinearVnlOptimizer(); 00095 00096 typedef SingleValuedVnlCostFunctionAdaptor CostFunctionAdaptorType; 00097 00098 void SetCostFunctionAdaptor( CostFunctionAdaptorType * adaptor ); 00099 const CostFunctionAdaptorType * GetCostFunctionAdaptor( void ) const; 00100 CostFunctionAdaptorType * GetCostFunctionAdaptor( void ); 00101 00104 CostFunctionAdaptorType * GetNonConstCostFunctionAdaptor( void ) const; 00105 00107 void PrintSelf(std::ostream& os, Indent indent) const; 00108 00109 private: 00111 void IterationReport( const EventObject & event ); 00112 00113 SingleValuedNonLinearVnlOptimizer(const Self&); //purposely not implemented 00114 void operator=(const Self&); //purposely not implemented 00115 00116 CostFunctionAdaptorType * m_CostFunctionAdaptor; 00117 00118 bool m_Maximize; 00119 00120 CommandType::Pointer m_Command; 00121 00122 mutable ParametersType m_CachedCurrentPosition; 00123 mutable MeasureType m_CachedValue; 00124 mutable DerivativeType m_CachedDerivative; 00125 }; 00126 00127 } // end namespace itk 00128 00129 #endif 00130