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 __itkOnePlusOneEvolutionaryOptimizer_h 00019 #define __itkOnePlusOneEvolutionaryOptimizer_h 00020 00021 #include "itkSingleValuedNonLinearOptimizer.h" 00022 #include "itkRandomVariateGeneratorBase.h" 00023 #include <string> 00024 00025 namespace itk 00026 { 00070 class ITK_EXPORT OnePlusOneEvolutionaryOptimizer: 00071 public SingleValuedNonLinearOptimizer 00072 { 00073 public: 00075 typedef OnePlusOneEvolutionaryOptimizer Self; 00076 typedef SingleValuedNonLinearOptimizer Superclass; 00077 typedef SmartPointer< Self > Pointer; 00078 typedef SmartPointer< const Self > ConstPointer; 00079 00081 itkNewMacro(Self); 00082 00084 itkTypeMacro(OnePlusOneEvolutionaryOptimizer, SingleValuedNonLinearOptimizer); 00085 00087 typedef SingleValuedCostFunction CostFunctionType; 00088 typedef CostFunctionType::Pointer CostFunctionPointer; 00089 00091 typedef Statistics::RandomVariateGeneratorBase NormalVariateGeneratorType; 00092 00094 itkSetMacro(Maximize, bool); 00095 itkBooleanMacro(Maximize); 00096 itkGetConstReferenceMacro(Maximize, bool); 00098 00099 bool GetMinimize() const 00100 { return !m_Maximize; } 00101 void SetMinimize(bool v) 00102 { this->SetMaximize(!v); } 00103 void MinimizeOn(void) 00104 { SetMaximize(false); } 00105 void MinimizeOff(void) 00106 { SetMaximize(true); } 00107 00109 itkSetMacro(MaximumIteration, unsigned int); 00110 itkGetConstReferenceMacro(MaximumIteration, unsigned int); 00112 00114 itkSetMacro(GrowthFactor, double); 00115 itkGetConstReferenceMacro(GrowthFactor, double); 00117 00119 itkSetMacro(ShrinkFactor, double); 00120 itkGetConstReferenceMacro(ShrinkFactor, double); 00122 00124 itkSetMacro(InitialRadius, double); 00125 itkGetConstReferenceMacro(InitialRadius, double); 00127 00130 itkSetMacro(Epsilon, double); 00131 itkGetConstReferenceMacro(Epsilon, double); 00133 00135 itkGetConstReferenceMacro(FrobeniusNorm, double); 00136 00137 void SetNormalVariateGenerator(NormalVariateGeneratorType *generator); 00138 00145 void Initialize(double initialRadius, double grow = -1, double shrink = -1); 00146 00148 itkGetConstReferenceMacro(CurrentCost, MeasureType); 00149 MeasureType GetValue() const { return this->GetCurrentCost(); } 00151 00153 itkGetConstReferenceMacro(CurrentIteration, unsigned int); 00154 00156 itkGetConstReferenceMacro(Initialized, bool); 00157 00161 void StartOptimization(); 00162 00166 void StopOptimization() 00167 { m_Stop = true; } 00168 00169 itkGetConstReferenceMacro(CatchGetValueException, bool); 00170 itkSetMacro(CatchGetValueException, bool); 00171 00172 itkGetConstReferenceMacro(MetricWorstPossibleValue, double); 00173 itkSetMacro(MetricWorstPossibleValue, double); 00174 00175 const std::string GetStopConditionDescription() const; 00176 00177 protected: 00178 OnePlusOneEvolutionaryOptimizer(); 00179 OnePlusOneEvolutionaryOptimizer(const OnePlusOneEvolutionaryOptimizer &); 00180 virtual ~OnePlusOneEvolutionaryOptimizer(); 00181 void PrintSelf(std::ostream & os, Indent indent) const; 00182 00183 private: 00184 00186 NormalVariateGeneratorType::Pointer m_RandomGenerator; 00187 00189 unsigned int m_MaximumIteration; 00190 00192 unsigned int m_CurrentIteration; 00193 00194 bool m_CatchGetValueException; 00195 double m_MetricWorstPossibleValue; 00196 00198 bool m_Maximize; 00199 00202 double m_Epsilon; 00203 00205 double m_InitialRadius; 00206 00208 double m_GrowthFactor; 00209 00211 double m_ShrinkFactor; 00212 00214 bool m_Initialized; 00215 00217 MeasureType m_CurrentCost; 00218 00223 bool m_Stop; 00224 00226 std::ostringstream m_StopConditionDescription; 00227 00230 double m_FrobeniusNorm; 00231 }; // end of class 00232 } // end of namespace itk 00233 00234 #endif 00235