X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=registration%2FclitkLBFGSBOptimizer.h;h=c5d89664ecbcaad4a99bf2fb17adfc6a7e57d7ef;hb=1e6e00bdcdb79d94c23432f848ba7fdbd057e64c;hp=5485b7652b9b334218210727ce2007765019954c;hpb=c18059db4f507fd31b5898667f57eced7d48c5f7;p=clitk.git diff --git a/registration/clitkLBFGSBOptimizer.h b/registration/clitkLBFGSBOptimizer.h index 5485b76..c5d8966 100644 --- a/registration/clitkLBFGSBOptimizer.h +++ b/registration/clitkLBFGSBOptimizer.h @@ -1,9 +1,9 @@ /*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: + Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,27 +14,9 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ - -/*========================================================================= - - Program: Insight Segmentation & Registration Toolkit - Module: $RCSfile: clitkLBFGSBOptimizer.h,v $ - Language: C++ - Date: $Date: 2010/06/14 17:32:07 $ - Version: $Revision: 1.1 $ - - Copyright (c) Insight Software Consortium. All rights reserved. - See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ +===========================================================================**/ #ifndef __clitkLBFGSBOptimizer_h #define __clitkLBFGSBOptimizer_h - #include "itkSingleValuedNonLinearVnlOptimizer.h" namespace clitk @@ -61,21 +43,21 @@ class ITK_EXPORT LBFGSBOptimizerHelper; * * References: * - * [1] R. H. Byrd, P. Lu and J. Nocedal. - * A Limited Memory Algorithm for Bound Constrained Optimization, (1995), - * SIAM Journal on Scientific and Statistical Computing , - * 16, 5, pp. 1190-1208. + * [1] R. H. Byrd, P. Lu and J. Nocedal. + * A Limited Memory Algorithm for Bound Constrained Optimization, (1995), + * SIAM Journal on Scientific and Statistical Computing , + * 16, 5, pp. 1190-1208. * - * [2] C. Zhu, R. H. Byrd and J. Nocedal. - * L-BFGS-B: Algorithm 778: L-BFGS-B, FORTRAN routines for large scale - * bound constrained optimization (1997), - * ACM Transactions on Mathematical Software, - * Vol 23, Num. 4, pp. 550 - 560. + * [2] C. Zhu, R. H. Byrd and J. Nocedal. + * L-BFGS-B: Algorithm 778: L-BFGS-B, FORTRAN routines for large scale + * bound constrained optimization (1997), + * ACM Transactions on Mathematical Software, + * Vol 23, Num. 4, pp. 550 - 560. * * \ingroup Numerics Optimizers */ -class ITK_EXPORT LBFGSBOptimizer : - public itk::SingleValuedNonLinearVnlOptimizer +class ITK_EXPORT LBFGSBOptimizer : + public itk::SingleValuedNonLinearVnlOptimizer { public: /** Standard "Self" typedef. */ @@ -83,7 +65,7 @@ public: typedef itk::SingleValuedNonLinearVnlOptimizer Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; - + /** Method for creation through the object factory. */ itkNewMacro(Self); @@ -91,12 +73,12 @@ public: itkTypeMacro( LBFGSBOptimizer, SingleValuedNonLinearVnlOptimizer ); /** BoundValue type. - * Use for defining the lower and upper bounds on the variables. + * Use for defining the lower and upper bounds on the variables. */ typedef itk::Array BoundValueType; /** BoundSelection type - * Use for defining the boundary condition for each variables. + * Use for defining the boundary condition for each variables. */ typedef itk::Array BoundSelectionType; @@ -111,10 +93,10 @@ public: /** Start optimization with an initial value. */ - void StartOptimization( void ); + virtual void StartOptimization( void ) ITK_OVERRIDE; /** Plug in a Cost Function into the optimizer */ - virtual void SetCostFunction( itk::SingleValuedCostFunction * costFunction ); + virtual void SetCostFunction( itk::SingleValuedCostFunction * costFunction ) ITK_OVERRIDE; /** Set the lower bound value for each variable. */ virtual void SetLowerBound( const BoundValueType & value ); @@ -136,7 +118,7 @@ public: /** Set/Get the CostFunctionConvergenceFactor. Algorithm terminates * when the reduction in cost function is less than factor * epsmcj * where epsmch is the machine precision. - * Typical values for factor: 1e+12 for low accuracy; + * Typical values for factor: 1e+12 for low accuracy; * 1e+7 for moderate accuracy and 1e+1 for extremely high accuracy. */ virtual void SetCostFunctionConvergenceFactor( double ); @@ -162,9 +144,10 @@ public: itkGetMacro( MaximumNumberOfCorrections, unsigned int ); /** This optimizer does not support scaling of the derivatives. */ - void SetScales( const ScalesType & ) { + void SetScales( const ScalesType & ) + { itkExceptionMacro( << "This optimizer does not support scales." ); - } + } /** Get the current iteration number. */ itkGetConstReferenceMacro( CurrentIteration, unsigned int ); @@ -176,10 +159,13 @@ public: * function. */ itkGetConstReferenceMacro( InfinityNormOfProjectedGradient, double ); + /** Get the reason for termination */ + virtual const std::string GetStopConditionDescription() const ITK_OVERRIDE; + protected: LBFGSBOptimizer(); virtual ~LBFGSBOptimizer(); - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType; @@ -193,7 +179,7 @@ private: bool m_OptimizerInitialized; InternalOptimizerType * m_VnlOptimizer; - + mutable std::ostringstream m_StopConditionDescription; BoundValueType m_LowerBound; BoundValueType m_UpperBound; BoundSelectionType m_BoundSelection;