Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkPowellOptimizer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkPowellOptimizer.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-06-24 12:02:54 $
00007   Version:   $Revision: 1.12 $
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 __itkPowellOptimizer_h
00018 #define __itkPowellOptimizer_h
00019 
00020 #include <itkVector.h>
00021 #include <itkMatrix.h>
00022 #include <itkSingleValuedNonLinearOptimizer.h>
00023 
00024 namespace itk
00025 {
00026 
00060 class ITK_EXPORT PowellOptimizer: 
00061     public SingleValuedNonLinearOptimizer
00062 {
00063 public:
00065   typedef PowellOptimizer                Self;
00066   typedef SingleValuedNonLinearOptimizer Superclass;
00067   typedef SmartPointer<Self>             Pointer;
00068   typedef SmartPointer<const Self>       ConstPointer;
00069 
00070   typedef SingleValuedNonLinearOptimizer::ParametersType
00071                                               ParametersType;
00072   
00074   itkNewMacro(Self);
00075 
00077   itkTypeMacro(PowellOptimizer, SingleValuedNonLinearOptimizer );
00078 
00080   typedef  SingleValuedCostFunction         CostFunctionType;
00081   typedef  CostFunctionType::Pointer        CostFunctionPointer;
00082 
00084   itkSetMacro( Maximize, bool );
00085   itkGetConstReferenceMacro( Maximize, bool );
00087 
00089   itkSetMacro( MaximumIteration, unsigned int );
00090   itkGetConstReferenceMacro( MaximumIteration, unsigned int );
00092 
00094   itkSetMacro(MaximumLineIteration, unsigned int);
00095   itkGetConstMacro(MaximumLineIteration, unsigned int);
00097 
00100   itkSetMacro( StepLength, double );
00101   itkGetConstReferenceMacro( StepLength, double );
00103 
00106   itkSetMacro( StepTolerance, double );
00107   itkGetConstReferenceMacro( StepTolerance, double );
00109 
00113   itkSetMacro( ValueTolerance, double );
00114   itkGetConstReferenceMacro( ValueTolerance, double );
00116 
00118   itkGetConstReferenceMacro( CurrentCost, MeasureType );
00119   MeasureType GetValue() const { return this->GetCurrentCost(); }
00121 
00123   itkGetConstReferenceMacro( CurrentIteration, unsigned int);
00124 
00126   itkGetConstReferenceMacro( CurrentLineIteration, unsigned int);
00127 
00129   void StartOptimization();
00130 
00134   void StopOptimization() 
00135     { m_Stop = true; }
00136 
00137   itkGetMacro(CatchGetValueException, bool);
00138   itkSetMacro(CatchGetValueException, bool);
00139 
00140   itkGetMacro(MetricWorstPossibleValue, double);
00141   itkSetMacro(MetricWorstPossibleValue, double);
00142 
00143   const std::string GetStopConditionDescription() const;
00144 
00145 protected:
00146   PowellOptimizer();
00147   PowellOptimizer(const PowellOptimizer&);
00148   virtual ~PowellOptimizer();
00149   void PrintSelf(std::ostream& os, Indent indent) const;
00150 
00151   itkSetMacro(CurrentCost, double);
00152 
00155   void SetLine(const ParametersType & origin,
00156                const vnl_vector<double> & direction);
00157 
00161   double GetLineValue(double x) const;
00162 
00163   double GetLineValue(double x, ParametersType & tempCoord) const;
00164 
00167   void   SetCurrentLinePoint(double x, double fx);
00168 
00171   void   Swap(double *a, double *b) const;
00172 
00175   void   Shift(double *a, double *b, double *c, double d) const;
00176 
00186   virtual void   LineBracket(double *ax, double *bx, double *cx,
00187                              double *fa, double *fb, double *fc);
00188 
00189   virtual void   LineBracket(double *ax, double *bx, double *cx,
00190                              double *fa, double *fb, double *fc,
00191                              ParametersType & tempCoord);
00192 
00198   virtual void   BracketedLineOptimize(double ax, double bx, double cx,
00199                                        double fa, double fb, double fc,
00200                                        double * extX, double * extVal);
00201 
00202   virtual void   BracketedLineOptimize(double ax, double bx, double cx,
00203                                        double fa, double fb, double fc,
00204                                        double * extX, double * extVal,
00205                                        ParametersType & tempCoord);
00206 
00207   itkGetMacro(SpaceDimension, unsigned int);
00208   void SetSpaceDimension( unsigned int dim )
00209     {
00210     this->m_SpaceDimension = dim;
00211     this->m_LineDirection.set_size( dim );
00212     this->m_LineOrigin.set_size( dim );
00213     this->m_CurrentPosition.set_size( dim );
00214     this->Modified();
00215     }
00216 
00217   itkSetMacro(CurrentIteration, unsigned int);
00218 
00219   itkGetMacro(Stop, bool);
00220   itkSetMacro(Stop, bool);
00221 
00222 private:
00223   unsigned int       m_SpaceDimension;
00224 
00226   unsigned int       m_CurrentIteration;
00227   unsigned int       m_CurrentLineIteration;
00228 
00230   unsigned int       m_MaximumIteration;
00231   unsigned int       m_MaximumLineIteration;
00232 
00233   bool               m_CatchGetValueException;
00234   double             m_MetricWorstPossibleValue;
00235 
00237   bool               m_Maximize;
00238 
00240   double             m_StepLength;
00241   double             m_StepTolerance;
00242 
00243   ParametersType     m_LineOrigin;
00244   vnl_vector<double> m_LineDirection;
00245 
00246   double             m_ValueTolerance;
00247 
00249   MeasureType        m_CurrentCost;
00250 
00255   bool               m_Stop;
00256 
00257   OStringStream      m_StopConditionDescription;
00258 }; // end of class
00259 
00260 } // end of namespace itk
00261 
00262 #endif
00263 

Generated at Tue Sep 15 04:24:03 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000