ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkSingleValuedNonLinearVnlOptimizer_h 00019 #define __itkSingleValuedNonLinearVnlOptimizer_h 00020 00021 #include "itkSingleValuedNonLinearOptimizer.h" 00022 #include "itkSingleValuedVnlCostFunctionAdaptor.h" 00023 #include "itkCommand.h" 00024 00025 namespace itk 00026 { 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); 00090 protected: 00091 SingleValuedNonLinearVnlOptimizer(); 00092 virtual ~SingleValuedNonLinearVnlOptimizer(); 00094 00095 typedef SingleValuedVnlCostFunctionAdaptor CostFunctionAdaptorType; 00096 00097 void SetCostFunctionAdaptor(CostFunctionAdaptorType *adaptor); 00098 00099 const CostFunctionAdaptorType * GetCostFunctionAdaptor(void) const; 00100 00101 CostFunctionAdaptorType * GetCostFunctionAdaptor(void); 00102 00105 CostFunctionAdaptorType * GetNonConstCostFunctionAdaptor(void) const; 00106 00108 void PrintSelf(std::ostream & os, Indent indent) const; 00109 00110 private: 00112 void IterationReport(const EventObject & event); 00113 00114 SingleValuedNonLinearVnlOptimizer(const Self &); //purposely not implemented 00115 void operator=(const Self &); //purposely not implemented 00116 00117 CostFunctionAdaptorType *m_CostFunctionAdaptor; 00118 00119 bool m_Maximize; 00120 00121 CommandType::Pointer m_Command; 00122 00123 mutable ParametersType m_CachedCurrentPosition; 00124 mutable MeasureType m_CachedValue; 00125 mutable DerivativeType m_CachedDerivative; 00126 }; 00127 } // end namespace itk 00128 00129 #endif 00130