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-09-23 16:07:42 $
00007   Version:   $Revision: 1.14 $
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   itkBooleanMacro( Maximize);
00086   itkGetConstReferenceMacro( Maximize, bool );
00088 
00090   itkSetMacro( MaximumIteration, unsigned int );
00091   itkGetConstReferenceMacro( MaximumIteration, unsigned int );
00093 
00095   itkSetMacro(MaximumLineIteration, unsigned int);
00096   itkGetConstMacro(MaximumLineIteration, unsigned int);
00098 
00101   itkSetMacro( StepLength, double );
00102   itkGetConstReferenceMacro( StepLength, double );
00104 
00107   itkSetMacro( StepTolerance, double );
00108   itkGetConstReferenceMacro( StepTolerance, double );
00110 
00114   itkSetMacro( ValueTolerance, double );
00115   itkGetConstReferenceMacro( ValueTolerance, double );
00117 
00119   itkGetConstReferenceMacro( CurrentCost, MeasureType );
00120   MeasureType GetValue() const { return this->GetCurrentCost(); }
00122 
00124   itkGetConstReferenceMacro( CurrentIteration, unsigned int);
00125 
00127   itkGetConstReferenceMacro( CurrentLineIteration, unsigned int);
00128 
00130   void StartOptimization();
00131 
00135   void StopOptimization() 
00136     { m_Stop = true; }
00137 
00138   itkGetConstReferenceMacro(CatchGetValueException, bool);
00139   itkSetMacro(CatchGetValueException, bool);
00140 
00141   itkGetConstReferenceMacro(MetricWorstPossibleValue, double);
00142   itkSetMacro(MetricWorstPossibleValue, double);
00143 
00144   const std::string GetStopConditionDescription() const;
00145 
00146 protected:
00147   PowellOptimizer();
00148   PowellOptimizer(const PowellOptimizer&);
00149   virtual ~PowellOptimizer();
00150   void PrintSelf(std::ostream& os, Indent indent) const;
00151 
00152   itkSetMacro(CurrentCost, double);
00153 
00156   void SetLine(const ParametersType & origin,
00157                const vnl_vector<double> & direction);
00158 
00162   double GetLineValue(double x) const;
00163 
00164   double GetLineValue(double x, ParametersType & tempCoord) const;
00165 
00168   void   SetCurrentLinePoint(double x, double fx);
00169 
00172   void   Swap(double *a, double *b) const;
00173 
00176   void   Shift(double *a, double *b, double *c, double d) const;
00177 
00187   virtual void   LineBracket(double *ax, double *bx, double *cx,
00188                              double *fa, double *fb, double *fc);
00189 
00190   virtual void   LineBracket(double *ax, double *bx, double *cx,
00191                              double *fa, double *fb, double *fc,
00192                              ParametersType & tempCoord);
00193 
00199   virtual void   BracketedLineOptimize(double ax, double bx, double cx,
00200                                        double fa, double fb, double fc,
00201                                        double * extX, double * extVal);
00202 
00203   virtual void   BracketedLineOptimize(double ax, double bx, double cx,
00204                                        double fa, double fb, double fc,
00205                                        double * extX, double * extVal,
00206                                        ParametersType & tempCoord);
00207 
00208   itkGetMacro(SpaceDimension, unsigned int);
00209   void SetSpaceDimension( unsigned int dim )
00210     {
00211     this->m_SpaceDimension = dim;
00212     this->m_LineDirection.set_size( dim );
00213     this->m_LineOrigin.set_size( dim );
00214     this->m_CurrentPosition.set_size( dim );
00215     this->Modified();
00216     }
00217 
00218   itkSetMacro(CurrentIteration, unsigned int);
00219 
00220   itkGetMacro(Stop, bool);
00221   itkSetMacro(Stop, bool);
00222 
00223 private:
00224   unsigned int       m_SpaceDimension;
00225 
00227   unsigned int       m_CurrentIteration;
00228   unsigned int       m_CurrentLineIteration;
00229 
00231   unsigned int       m_MaximumIteration;
00232   unsigned int       m_MaximumLineIteration;
00233 
00234   bool               m_CatchGetValueException;
00235   double             m_MetricWorstPossibleValue;
00236 
00238   bool               m_Maximize;
00239 
00241   double             m_StepLength;
00242   double             m_StepTolerance;
00243 
00244   ParametersType     m_LineOrigin;
00245   vnl_vector<double> m_LineDirection;
00246 
00247   double             m_ValueTolerance;
00248 
00250   MeasureType        m_CurrentCost;
00251 
00256   bool               m_Stop;
00257 
00258   OStringStream      m_StopConditionDescription;
00259 }; // end of class
00260 
00261 } // end of namespace itk
00262 
00263 #endif
00264 

Generated at Fri Apr 16 19:19:53 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000