00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkSingleValuedNonLinearVnlOptimizer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/04/02 23:11:49 $ 00007 Version: $Revision: 1.25 $ 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(); } 00080 00086 itkGetConstReferenceMacro(CachedValue, MeasureType); 00087 itkGetConstReferenceMacro(CachedDerivative, DerivativeType); 00088 itkGetConstReferenceMacro(CachedCurrentPosition, ParametersType); 00089 00090 protected: 00091 SingleValuedNonLinearVnlOptimizer(); 00092 virtual ~SingleValuedNonLinearVnlOptimizer(); 00093 00094 typedef SingleValuedVnlCostFunctionAdaptor CostFunctionAdaptorType; 00095 00096 void SetCostFunctionAdaptor( CostFunctionAdaptorType * adaptor ); 00097 const CostFunctionAdaptorType * GetCostFunctionAdaptor( void ) const; 00098 CostFunctionAdaptorType * GetCostFunctionAdaptor( void ); 00099 00102 CostFunctionAdaptorType * GetNonConstCostFunctionAdaptor( void ) const; 00103 00105 void PrintSelf(std::ostream& os, Indent indent) const; 00106 00107 private: 00109 void IterationReport( const EventObject & event ); 00110 00111 SingleValuedNonLinearVnlOptimizer(const Self&); //purposely not implemented 00112 void operator=(const Self&); //purposely not implemented 00113 00114 CostFunctionAdaptorType * m_CostFunctionAdaptor; 00115 00116 bool m_Maximize; 00117 00118 CommandType::Pointer m_Command; 00119 00120 mutable ParametersType m_CachedCurrentPosition; 00121 mutable MeasureType m_CachedValue; 00122 mutable DerivativeType m_CachedDerivative; 00123 }; 00124 00125 } // end namespace itk 00126 00127 00128 00129 00130 00131 #endif 00132 00133 00134