X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=registration%2FclitkLBFGSBOptimizer.h;h=8eec63a1f32046891728d3cfc7c29cad4e3666b7;hb=31ae3f744e457adcd92677eaddd4c54d2702a392;hp=5485b7652b9b334218210727ce2007765019954c;hpb=c18059db4f507fd31b5898667f57eced7d48c5f7;p=clitk.git diff --git a/registration/clitkLBFGSBOptimizer.h b/registration/clitkLBFGSBOptimizer.h index 5485b76..8eec63a 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; @@ -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,6 +159,9 @@ public: * function. */ itkGetConstReferenceMacro( InfinityNormOfProjectedGradient, double ); + /** Get the reason for termination */ + const std::string GetStopConditionDescription() const; + protected: LBFGSBOptimizer(); virtual ~LBFGSBOptimizer(); @@ -193,7 +179,11 @@ private: bool m_OptimizerInitialized; InternalOptimizerType * m_VnlOptimizer; - +#if ITK_VERSION_MAJOR > 3 + mutable std::ostringstream m_StopConditionDescription; +#else + mutable itk::OStringStream m_StopConditionDescription; +#endif BoundValueType m_LowerBound; BoundValueType m_UpperBound; BoundSelectionType m_BoundSelection;