ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkAmoebaOptimizer.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 __itkAmoebaOptimizer_h
00019 #define __itkAmoebaOptimizer_h
00020 
00021 #include "itkSingleValuedNonLinearVnlOptimizer.h"
00022 #include "vnl/algo/vnl_amoeba.h"
00023 
00024 namespace itk
00025 {
00061 class ITK_EXPORT AmoebaOptimizer:
00062   public SingleValuedNonLinearVnlOptimizer
00063 {
00064 public:
00066   typedef AmoebaOptimizer                   Self;
00067   typedef SingleValuedNonLinearVnlOptimizer Superclass;
00068   typedef SmartPointer< Self >              Pointer;
00069   typedef SmartPointer< const Self >        ConstPointer;
00070   typedef unsigned int                      NumberOfIterationsType;
00071 
00073   itkNewMacro(Self);
00074 
00076   itkTypeMacro(AmoebaOptimizer, SingleValuedNonLinearVnlOptimizer);
00077 
00080   typedef Superclass::ParametersType ParametersType;
00081 
00083   typedef   vnl_vector< double > InternalParametersType;
00084 
00086   void StartOptimization(void);
00087 
00089   virtual void SetCostFunction(SingleValuedCostFunction *costFunction);
00090 
00094   itkSetMacro( MaximumNumberOfIterations, NumberOfIterationsType );
00095   itkGetConstMacro( MaximumNumberOfIterations, NumberOfIterationsType );
00097 
00106   itkSetMacro(AutomaticInitialSimplex, bool);
00107   itkBooleanMacro(AutomaticInitialSimplex);
00108   itkGetConstMacro(AutomaticInitialSimplex, bool);
00110 
00117   itkSetMacro(OptimizeWithRestarts, bool);
00118   itkBooleanMacro(OptimizeWithRestarts);
00119   itkGetConstMacro(OptimizeWithRestarts, bool);
00121 
00124   void SetInitialSimplexDelta(ParametersType initialSimplexDelta,
00125                               bool automaticInitialSimplex = false);
00126   itkGetConstMacro(InitialSimplexDelta, ParametersType);
00128 
00133   itkSetMacro(ParametersConvergenceTolerance, double);
00134   itkGetConstMacro(ParametersConvergenceTolerance, double);
00136 
00141   itkSetMacro(FunctionConvergenceTolerance, double);
00142   itkGetConstMacro(FunctionConvergenceTolerance, double);
00144 
00146   const std::string GetStopConditionDescription() const;
00147 
00149   MeasureType GetValue() const;
00150 
00152   vnl_amoeba * GetOptimizer(void) const;
00153 
00154 protected:
00155   AmoebaOptimizer();
00156   virtual ~AmoebaOptimizer();
00157   void PrintSelf(std::ostream & os, Indent indent) const;
00158 
00159   typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType;
00160 private:
00162   void ValidateSettings();
00163   //purposely not implemented
00164   AmoebaOptimizer(const Self &);
00165   //purposely not implemented
00166   void operator=(const Self &);
00168 
00169   NumberOfIterationsType          m_MaximumNumberOfIterations;
00170   ParametersType::ValueType       m_ParametersConvergenceTolerance;
00171   CostFunctionType::MeasureType   m_FunctionConvergenceTolerance;
00172   bool                            m_AutomaticInitialSimplex;
00173   ParametersType                  m_InitialSimplexDelta;
00174   bool                            m_OptimizeWithRestarts;
00175   vnl_amoeba *                    m_VnlOptimizer;
00176 
00177   std::ostringstream m_StopConditionDescription;
00178 };
00179 } // end namespace itk
00180 
00181 #endif
00182