| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | 
| 2 |  | 
| 3 | /* | 
| 4 | Copyright (C) 2009 Frédéric Degraeve | 
| 5 |  | 
| 6 | This file is part of QuantLib, a free-software/open-source library | 
| 7 | for financial quantitative analysts and developers - http://quantlib.org/ | 
| 8 |  | 
| 9 | QuantLib is free software: you can redistribute it and/or modify it | 
| 10 | under the terms of the QuantLib license.  You should have received a | 
| 11 | copy of the license along with this program; if not, please email | 
| 12 | <quantlib-dev@lists.sf.net>. The license is also available online at | 
| 13 | <http://quantlib.org/license.shtml>. | 
| 14 |  | 
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT | 
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 
| 17 | FOR A PARTICULAR PURPOSE.  See the license for more details. | 
| 18 | */ | 
| 19 |  | 
| 20 | /*! \file bfgs.hpp | 
| 21 | \brief Broyden-Fletcher-Goldfarb-Shanno optimization method | 
| 22 | */ | 
| 23 |  | 
| 24 | #ifndef quantlib_optimization_bfgs_hpp | 
| 25 | #define quantlib_optimization_bfgs_hpp | 
| 26 |  | 
| 27 | #include "optimization/LineSearchBasedMethod.hpp" | 
| 28 | #include "math/DynamicRectMatrix.hpp" | 
| 29 |  | 
| 30 | using namespace OpenMD; | 
| 31 | namespace QuantLib { | 
| 32 |  | 
| 33 | //! Broyden-Fletcher-Goldfarb-Shanno algorithm | 
| 34 | /*! See <http://en.wikipedia.org/wiki/BFGS_method>. | 
| 35 |  | 
| 36 | Adapted from Numerical Recipes in C, 2nd edition. | 
| 37 |  | 
| 38 | User has to provide line-search method and optimization end criteria. | 
| 39 | */ | 
| 40 | class BFGS: public LineSearchBasedMethod { | 
| 41 | public: | 
| 42 | BFGS(LineSearch* lineSearch = NULL) | 
| 43 | : LineSearchBasedMethod(lineSearch) {} | 
| 44 | private: | 
| 45 | //! \name LineSearchBasedMethod interface | 
| 46 | //@{ | 
| 47 | DynamicVector<RealType> getUpdatedDirection(const Problem &P, | 
| 48 | RealType gold2, | 
| 49 | const DynamicVector<RealType>& oldGradient); | 
| 50 | //@} | 
| 51 | //! inverse of hessian matrix | 
| 52 | DynamicRectMatrix<RealType> inverseHessian_; | 
| 53 | }; | 
| 54 |  | 
| 55 | } | 
| 56 |  | 
| 57 | #endif |